Controllo posizione con gui completa
This commit is contained in:
+2
-2
@@ -23,8 +23,8 @@ Pos=68,96
|
|||||||
Size=740,472
|
Size=740,472
|
||||||
|
|
||||||
[Window][Set data position]
|
[Window][Set data position]
|
||||||
Pos=18,542
|
Pos=10,520
|
||||||
Size=534,60
|
Size=521,73
|
||||||
|
|
||||||
[Window][Dear ImGui Demo/ResizableChild_478B81A3]
|
[Window][Dear ImGui Demo/ResizableChild_478B81A3]
|
||||||
IsChild=1
|
IsChild=1
|
||||||
|
|||||||
Binary file not shown.
@@ -32,7 +32,7 @@ class PieceInterface{
|
|||||||
rb::rigidbody body;
|
rb::rigidbody body;
|
||||||
sf::Color color;
|
sf::Color color;
|
||||||
|
|
||||||
virtual void update(unsigned int pos) = 0;
|
virtual void update(sf::Clock cl) = 0;
|
||||||
virtual sf::Shape* draw(ReferencePlane plane) = 0;
|
virtual sf::Shape* draw(ReferencePlane plane) = 0;
|
||||||
virtual ~PieceInterface(){}
|
virtual ~PieceInterface(){}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,12 +14,9 @@ class Sensore : public PieceInterface{
|
|||||||
std::vector<std::vector<float>> gData;
|
std::vector<std::vector<float>> gData;
|
||||||
std::vector<std::vector<float>> rotData;
|
std::vector<std::vector<float>> rotData;
|
||||||
std::vector<float> timeData;
|
std::vector<float> timeData;
|
||||||
rb::Vector3 stPos;
|
|
||||||
|
|
||||||
//in che punto sto controllando il segnale
|
//in che punto sto controllando il segnale
|
||||||
unsigned int dataPos;
|
unsigned int* dataPos;
|
||||||
std::vector<int> dataIntvl;
|
|
||||||
unsigned int curTime;
|
|
||||||
|
|
||||||
//funzioni ausiliarie
|
//funzioni ausiliarie
|
||||||
void calcRotWithG(unsigned int index);
|
void calcRotWithG(unsigned int index);
|
||||||
@@ -27,10 +24,10 @@ class Sensore : public PieceInterface{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Sensore(rb::Vector3 coords, _Float16 mass);
|
Sensore(rb::Vector3 coords, _Float16 mass);
|
||||||
Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, int min, int max, std::vector<std::vector<float>> data);
|
Sensore(rb::Vector3 coords, _Float16 mass, unsigned int* st, std::vector<std::vector<float>> data);
|
||||||
~Sensore();
|
~Sensore();
|
||||||
|
|
||||||
void update(unsigned int pos) override;
|
void update(sf::Clock cl) override;
|
||||||
sf::Shape* draw(ReferencePlane plane) override;
|
sf::Shape* draw(ReferencePlane plane) override;
|
||||||
|
|
||||||
//funzioni specifiche
|
//funzioni specifiche
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ Sensore::Sensore(rb::Vector3 coords, _Float16 mass){
|
|||||||
initialize_shapes(sensore_Dim);
|
initialize_shapes(sensore_Dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, int min, int max, std::vector<std::vector<float>> data) : Sensore(coords, mass){
|
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int* st, std::vector<std::vector<float>> data) : Sensore(coords, mass){
|
||||||
dataPos = st;
|
dataPos = st;
|
||||||
this->dataIntvl = {min, max};
|
|
||||||
initCSV(data);
|
initCSV(data);
|
||||||
curTime = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,26 +43,13 @@ void Sensore::initCSV(std::vector<std::vector<float>> data){
|
|||||||
|
|
||||||
|
|
||||||
void Sensore::update(sf::Clock cl){
|
void Sensore::update(sf::Clock cl){
|
||||||
// Aggiorno la posizione nei dati
|
|
||||||
curTime += cl.getElapsedTime().asMilliseconds();
|
|
||||||
/*
|
|
||||||
if (timeData[dataPos]){
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (timeData[dataPos] < currTime && dataIntvl - dataPos > 0) { //aggiorno solo se ho cambiato posizione
|
|
||||||
dataPos++;
|
|
||||||
|
|
||||||
//calcolo la posizione e velocità
|
//calcolo la posizione e velocità
|
||||||
calcRotWithG(dataPos);
|
calcRotWithG(*dataPos);
|
||||||
|
|
||||||
|
|
||||||
body.setAcc(rb::Vector3{accData[dataPos]});
|
body.setAcc(rb::Vector3{accData[*dataPos]});
|
||||||
body.step(cl);
|
body.step(cl);
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,13 +103,5 @@ void Sensore::calcRotWithG(unsigned int index){ // calcolo rotazione con valori
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sensore::setIntervall(int min, int max){
|
|
||||||
this->dataIntvl = {min, max};
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sensore::setPos(int &pos){
|
|
||||||
this->dataPos = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////// cinematica inversa
|
/////////////// cinematica inversa
|
||||||
+1
-1
@@ -65,7 +65,7 @@ void State::update(){
|
|||||||
|
|
||||||
|
|
||||||
for(PieceInterface* p : pieces){
|
for(PieceInterface* p : pieces){
|
||||||
p->update(*pos);
|
p->update(clock);
|
||||||
}
|
}
|
||||||
for(JointInterface* j : joints){
|
for(JointInterface* j : joints){
|
||||||
j->movechild();
|
j->movechild();
|
||||||
|
|||||||
+7
-5
@@ -37,7 +37,7 @@ int main() {
|
|||||||
|
|
||||||
//Costruisco la GUI
|
//Costruisco la GUI
|
||||||
State gs(800, 600, "Visualizzatore passo",&maj,&min,&pos);
|
State gs(800, 600, "Visualizzatore passo",&maj,&min,&pos);
|
||||||
gs.window.setFramerateLimit(60);
|
gs.window.setFramerateLimit(140);
|
||||||
printf("Costruisco gli oggetti\n");
|
printf("Costruisco gli oggetti\n");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -47,7 +47,7 @@ int main() {
|
|||||||
|
|
||||||
|
|
||||||
gs.pieces.push_back(new Coscia (rb::Vector3{300,300,300},2));
|
gs.pieces.push_back(new Coscia (rb::Vector3{300,300,300},2));
|
||||||
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,300},_Float16( 0.2 ),900,900,3000,coscia));
|
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,300},_Float16( 0.2 ),&pos,coscia));
|
||||||
gs.pieces.push_back(new Caviglia (rb::Vector3{300,300,500},1));
|
gs.pieces.push_back(new Caviglia (rb::Vector3{300,300,500},1));
|
||||||
|
|
||||||
gs.pieces[1]->body.setRot({0,0,0});
|
gs.pieces[1]->body.setRot({0,0,0});
|
||||||
@@ -55,7 +55,7 @@ int main() {
|
|||||||
|
|
||||||
processor.readCSVFile(DATA_PATH + "caviglia_filt.csv");
|
processor.readCSVFile(DATA_PATH + "caviglia_filt.csv");
|
||||||
const auto& caviglia = processor.getData();
|
const auto& caviglia = processor.getData();
|
||||||
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,500},_Float16( 0.2 ),900,900,3000,caviglia));
|
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,500},_Float16( 0.2 ),&pos,caviglia));
|
||||||
|
|
||||||
gs.pieces.push_back(new Torso(rb::Vector3{300,400,150},2));
|
gs.pieces.push_back(new Torso(rb::Vector3{300,400,150},2));
|
||||||
|
|
||||||
@@ -86,12 +86,14 @@ int main() {
|
|||||||
|
|
||||||
//Avvio il loop della GUI
|
//Avvio il loop della GUI
|
||||||
gs.clock.start();
|
gs.clock.start();
|
||||||
|
|
||||||
|
sf::Clock mainClock;
|
||||||
while (gs.window.isOpen())
|
while (gs.window.isOpen())
|
||||||
{
|
{
|
||||||
curTime += gs.clock.getElapsedTime().asMilliseconds();
|
curTime += mainClock.restart().asMilliseconds();
|
||||||
if (curTime > T){
|
if (curTime > T){
|
||||||
|
if (gs.play && pos < maj) pos += curTime / T;
|
||||||
curTime = 0;
|
curTime = 0;
|
||||||
if (gs.play && pos < maj) pos += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show update
|
// Show update
|
||||||
|
|||||||
Reference in New Issue
Block a user