Caricamento v0.3

This commit is contained in:
2026-05-31 11:06:50 +02:00
parent e50e2987c9
commit 5169bc4096
18 changed files with 208 additions and 62 deletions
+20 -10
View File
@@ -1,17 +1,18 @@
#include "../headers/caviglia.hpp"
Caviglia::Caviglia(rb::Vector3 coords, _Float16 mass){
size = caviglia_Dim;
rb::Vector3 com = {size.x/2,0, size.y/2};
rb::Vector3 com = {caviglia_Dim.x/2,caviglia_Dim.x/2, caviglia_Dim.y/2};
body = rb::rigidbody(coords, com, mass);
color = caviglia_Col;
shape = new sf::RectangleShape(size);
shape->setOrigin({size.x/2,size.y/2});
globalPos = {0,0,0};
initialize_shapes(caviglia_Dim);
}
Caviglia::~Caviglia(){
delete shape;
delete shapeXZ;
delete shapeYZ;
}
void Caviglia::update(sf::Clock cl){
@@ -19,22 +20,31 @@ void Caviglia::update(sf::Clock cl){
}
sf::Shape* Caviglia::draw(ReferencePlane plane){
shape->setFillColor(color);
rb::Vector3 tmpPos = body.getPos();
rb::Vector3_s tmpRot = body.getRot();
switch (plane)
{
case ReferencePlane::XZ:
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
{
sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
return shape;}
break;
case ReferencePlane::YZ:
{
sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
return shape;}
break;
default:
break;
}
return shape;
return nullptr;
}
+19 -9
View File
@@ -1,17 +1,16 @@
#include "../headers/coscia.hpp"
Coscia::Coscia(rb::Vector3 coords, _Float16 mass){
size = coscia_Dim;
rb::Vector3 com = {size.x/2,0, size.y/2};
rb::Vector3 com = {coscia_Dim.x/2,coscia_Dim.z/2,coscia_Dim.y/2};
body = rb::rigidbody(coords, com, mass);
color = coscia_Col;
shape = new sf::RectangleShape(size);
shape->setOrigin({size.x/2,size.y/2});
globalPos = {0,0,0};
initialize_shapes(coscia_Dim);
}
Coscia::~Coscia(){
delete shape;
delete shapeXZ;
delete shapeYZ;
}
void Coscia::update(sf::Clock cl){
@@ -19,22 +18,33 @@ void Coscia::update(sf::Clock cl){
}
sf::Shape* Coscia::draw(ReferencePlane plane){
shape->setFillColor(color);
rb::Vector3 tmpPos = body.getPos();
rb::Vector3_s tmpRot = body.getRot();
switch (plane)
{
case ReferencePlane::XZ:
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
{
sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
return shape;}
break;
case ReferencePlane::YZ:
{
sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
return shape;}
break;
default:
break;
}
return shape;
return nullptr;
}
+25 -14
View File
@@ -2,12 +2,11 @@
Sensore::Sensore(rb::Vector3 coords, _Float16 mass){
size = sensore_Dim;
rb::Vector3 com = {size.x/2,0, size.y/2};
rb::Vector3 com = {sensore_Dim.x/2,sensore_Dim.z/2, sensore_Dim.y/2};
body = rb::rigidbody(coords, com, mass);
color = sensore_Col;
shape = new sf::RectangleShape(size);
globalPos = {0,0,0};
initialize_shapes(sensore_Dim);
}
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, unsigned int dataIntvl, std::vector<std::vector<float>> data) : Sensore(coords, mass){
@@ -18,7 +17,8 @@ Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, unsigned in
Sensore::~Sensore(){
delete shape;
delete shapeXZ;
delete shapeYZ;
}
void Sensore::initCSV(std::vector<std::vector<float>> data){
@@ -48,6 +48,8 @@ void Sensore::update(sf::Clock cl){
//calcolo la posizione e velocità
calcRotWithG(dataPos);
body.setAcc(rb::Vector3{accData[dataPos]});
body.step(cl);
}
@@ -55,30 +57,33 @@ void Sensore::update(sf::Clock cl){
}
sf::Shape* Sensore::draw(ReferencePlane plane){
shape->setFillColor(color);
shape->setOrigin({sensore_Dim.x/2, sensore_Dim.y/2});
rb::Vector3_s tmpRot = body.getRot();
rb::Vector3 tmpPos = body.getPos();
switch (plane)
{
case ReferencePlane::XZ:
{
sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
return shape;}
break;
case ReferencePlane::YZ:
{
sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
return shape;}
break;
default:
break;
}
return shape;
return nullptr;
}
@@ -99,4 +104,10 @@ void Sensore::calcRotWithG(unsigned int index){ // calcolo rotazione con valori
body.setRot(rb::Vector3_s{_Float16( tmpAX),_Float16( tmpAY),_Float16( tmpAZ) });
}
}
/*
void Sensore::calcRotWithConstraint(){
};*/
/////////////// cinematica inversa
+50
View File
@@ -0,0 +1,50 @@
#include "../headers/torso.hpp"
Torso::Torso(rb::Vector3 coords, _Float16 mass){
rb::Vector3 com = {torso_Dim.x/2, torso_Dim.y/2, torso_Dim.z/2};
body = rb::rigidbody(coords,com, mass);
color = torso_Col;
globalPos = {0,0,0};
initialize_shapes(torso_Dim);
}
Torso::~Torso(){
delete shapeXZ;
delete shapeYZ;
}
void Torso::update(sf::Clock cl){
}
sf::Shape* Torso::draw(ReferencePlane plane){
rb::Vector3_s tmpRot = body.getRot();
rb::Vector3 tmpPos = body.getPos();
switch (plane)
{
case ReferencePlane::XZ:
{
sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
return shape;}
break;
case ReferencePlane::YZ:
{
sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
return shape;}
break;
default:
break;
}
return nullptr;
}