Applicazione correzione rotazione bacino

This commit is contained in:
2026-06-22 10:38:24 +02:00
parent 7c2897aae1
commit f131849292
8 changed files with 66083 additions and 13 deletions
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+16516
View File
File diff suppressed because it is too large Load Diff
+16515
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -76,7 +76,7 @@ float Gamba::getZ_Acc(){
totZ_Acc += i->getZ_Acc(); totZ_Acc += i->getZ_Acc();
}*/ }*/
totZ_Acc = sensori[0]->getZ_Acc();// + sensori[1]->getZ_Acc(); totZ_Acc = sensori[0]->getZ_Acc() + sensori[1]->getZ_Acc();
//printf("TotAccGamba %f\n", totZ_Acc); //printf("TotAccGamba %f\n", totZ_Acc);
return totZ_Acc; return totZ_Acc;
+16 -9
View File
@@ -77,8 +77,8 @@ bool Lower_Body::setTransparency(float alpha){
} }
void Lower_Body::update(sf::Clock cl){ void Lower_Body::update(sf::Clock cl){
float sxAcc = sx->getZ_Acc() * 10; float sxAcc = sx->getZ_Acc() ;
float dxAcc = dx->getZ_Acc(); float dxAcc = dx->getZ_Acc() ;
//float totAcc = sxAcc + dxAcc; //float totAcc = sxAcc + dxAcc;
//t->body.setTanAcc({0,totAcc,0}); // non funziona, cambio sistema //t->body.setTanAcc({0,totAcc,0}); // non funziona, cambio sistema
@@ -86,7 +86,7 @@ void Lower_Body::update(sf::Clock cl){
/* Posso considerare lo spostamento come A*sin(alpha)*/ /* Posso considerare lo spostamento come A*sin(alpha)*/
/* Mi calcolo le velocità totali sull'asse z */ /* Mi calcolo le velocità totali sull'asse z */
printf("Acc: %f\n", dxAcc); //printf("Acc: %f\n", dxAcc);
int64_t Dtime = cl.getElapsedTime().asMicroseconds(); int64_t Dtime = cl.getElapsedTime().asMicroseconds();
if (prevT == 0) prevT = Dtime; if (prevT == 0) prevT = Dtime;
@@ -96,14 +96,14 @@ void Lower_Body::update(sf::Clock cl){
float tmpVelS = sxAcc*dt; float tmpVelS = sxAcc*dt;
float tmpVelD = dxAcc*dt; float tmpVelD = dxAcc*dt;
printf("Vel: %f\n", tmpVelD); //printf("Vel: %f\n", tmpVelD);
float tmpPosD = velD * 100 * dt + tmpVelD *dt *100 ; float tmpPosD = tmpVelD *dt *500 + velD * 500 * dt;
float tmpPosS = velS * 100 * dt + tmpVelD * 100 *dt; float tmpPosS = tmpVelS * 500 *dt + velS * 500 * dt;
printf("DPos: %f\n\n", tmpPosD); //printf("DPos: %f\n\n", tmpPosD);
velD += tmpVelD; velD += tmpVelD;
velS += tmpVelS; velS += tmpVelS;
@@ -111,10 +111,17 @@ void Lower_Body::update(sf::Clock cl){
posS += tmpPosS; posS += tmpPosS;
// PosD + PosS + Z = 0 // PosD + PosS + Z = 0
float alpha = atan(tmpPosD/60.0); float alpha = atan(tmpPosD/60.0 - tmpPosS/60); //il 60 è il raggio (dimesione del bacino)
//applico smoothing e ritorno a zero
velD -= velD * fabs(alpha);
velS -= velS * fabs(alpha) ;
printf("Svel: %f\n", velS);
printf("Dvel: %f\n\n", velD);
t->body.setRot({alpha,0,0}); t->body.setRot({alpha,0,0});
auto tPos = t->body.getPos(); auto tPos = t->body.getPos();
//t->body.setPos({tPos[0],tPos[1],tPos[2]+posD}); //t->body.setPos({tPos[0],tPos[1],tPos[2]+posD-posS});
} }
+2 -1
View File
@@ -82,10 +82,11 @@ void State::update(){
std::vector<PieceInterface*> collPieces; std::vector<PieceInterface*> collPieces;
std::vector<JointInterface*> collJoints; std::vector<JointInterface*> collJoints;
*/ */
if (play){
for (auto i : collections){ for (auto i : collections){
i->update(PieceClock); i->update(PieceClock);
} }
}
for (auto i : createdColl){ for (auto i : createdColl){
if (play){ if (play){