Cambio posizione aggoirnamento dati (da concludere)
This commit is contained in:
@@ -1,132 +0,0 @@
|
|||||||
{
|
|
||||||
"cmake" :
|
|
||||||
{
|
|
||||||
"generator" :
|
|
||||||
{
|
|
||||||
"multiConfig" : false,
|
|
||||||
"name" : "Unix Makefiles"
|
|
||||||
},
|
|
||||||
"paths" :
|
|
||||||
{
|
|
||||||
"cmake" : "/usr/bin/cmake",
|
|
||||||
"cpack" : "/usr/bin/cpack",
|
|
||||||
"ctest" : "/usr/bin/ctest",
|
|
||||||
"root" : "/usr/share/cmake-4.2"
|
|
||||||
},
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"isDirty" : false,
|
|
||||||
"major" : 4,
|
|
||||||
"minor" : 2,
|
|
||||||
"patch" : 3,
|
|
||||||
"string" : "4.2.3",
|
|
||||||
"suffix" : ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"objects" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"jsonFile" : "codemodel-v2-1d54dc62b65d9b1e65df.json",
|
|
||||||
"kind" : "codemodel",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 2,
|
|
||||||
"minor" : 9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "cache-v2-374534acf1e5fd169877.json",
|
|
||||||
"kind" : "cache",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 2,
|
|
||||||
"minor" : 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "cmakeFiles-v1-e320a106f03fb9214dd8.json",
|
|
||||||
"kind" : "cmakeFiles",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 1,
|
|
||||||
"minor" : 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "toolchains-v1-f6f24f4dd93f5f594387.json",
|
|
||||||
"kind" : "toolchains",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 1,
|
|
||||||
"minor" : 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reply" :
|
|
||||||
{
|
|
||||||
"client-vscode" :
|
|
||||||
{
|
|
||||||
"query.json" :
|
|
||||||
{
|
|
||||||
"requests" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"kind" : "cache",
|
|
||||||
"version" : 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind" : "codemodel",
|
|
||||||
"version" : 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind" : "toolchains",
|
|
||||||
"version" : 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind" : "cmakeFiles",
|
|
||||||
"version" : 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses" :
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"jsonFile" : "cache-v2-374534acf1e5fd169877.json",
|
|
||||||
"kind" : "cache",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 2,
|
|
||||||
"minor" : 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "codemodel-v2-1d54dc62b65d9b1e65df.json",
|
|
||||||
"kind" : "codemodel",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 2,
|
|
||||||
"minor" : 9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "toolchains-v1-f6f24f4dd93f5f594387.json",
|
|
||||||
"kind" : "toolchains",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 1,
|
|
||||||
"minor" : 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonFile" : "cmakeFiles-v1-e320a106f03fb9214dd8.json",
|
|
||||||
"kind" : "cmakeFiles",
|
|
||||||
"version" :
|
|
||||||
{
|
|
||||||
"major" : 1,
|
|
||||||
"minor" : 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(sf::Clock cl) = 0;
|
virtual void update(unsigned int pos) = 0;
|
||||||
virtual sf::Shape* draw(ReferencePlane plane) = 0;
|
virtual sf::Shape* draw(ReferencePlane plane) = 0;
|
||||||
virtual ~PieceInterface(){}
|
virtual ~PieceInterface(){}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class Sensore : public PieceInterface{
|
|||||||
|
|
||||||
//in che punto sto controllando il segnale
|
//in che punto sto controllando il segnale
|
||||||
unsigned int dataPos;
|
unsigned int dataPos;
|
||||||
unsigned int dataIntvl;
|
std::vector<int> dataIntvl;
|
||||||
|
unsigned int curTime;
|
||||||
|
|
||||||
//funzioni ausiliarie
|
//funzioni ausiliarie
|
||||||
void calcRotWithG(unsigned int index);
|
void calcRotWithG(unsigned int index);
|
||||||
@@ -27,14 +27,16 @@ 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, unsigned int dataIntvl, std::vector<std::vector<float>> data);
|
Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, int min, int max, std::vector<std::vector<float>> data);
|
||||||
~Sensore();
|
~Sensore();
|
||||||
|
|
||||||
void update(sf::Clock cl) override;
|
void update(unsigned int pos) override;
|
||||||
sf::Shape* draw(ReferencePlane plane) override;
|
sf::Shape* draw(ReferencePlane plane) override;
|
||||||
|
|
||||||
//funzioni specifiche
|
//funzioni specifiche
|
||||||
void initCSV(std::vector<std::vector<float>> data);
|
void initCSV(std::vector<std::vector<float>> data);
|
||||||
|
void setIntervall(int min, int max);
|
||||||
|
void setPos(int &pos);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ 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, unsigned int dataIntvl, std::vector<std::vector<float>> data) : Sensore(coords, mass){
|
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, int min, int max, std::vector<std::vector<float>> data) : Sensore(coords, mass){
|
||||||
dataPos = st;
|
dataPos = st;
|
||||||
this->dataIntvl = dataIntvl;
|
this->dataIntvl = {min, max};
|
||||||
initCSV(data);
|
initCSV(data);
|
||||||
|
curTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +46,14 @@ 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
|
// Aggiorno la posizione nei dati
|
||||||
int64_t currTime = cl.getElapsedTime().asMicroseconds() *100000;
|
curTime += cl.getElapsedTime().asMilliseconds();
|
||||||
|
/*
|
||||||
|
if (timeData[dataPos]){
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
if (timeData[dataPos] < currTime && dataIntvl - dataPos > 0) { //aggiorno solo se ho cambiato posizione
|
if (timeData[dataPos] < currTime && dataIntvl - dataPos > 0) { //aggiorno solo se ho cambiato posizione
|
||||||
dataPos++;
|
dataPos++;
|
||||||
|
|
||||||
@@ -56,6 +64,7 @@ void Sensore::update(sf::Clock cl){
|
|||||||
body.setAcc(rb::Vector3{accData[dataPos]});
|
body.setAcc(rb::Vector3{accData[dataPos]});
|
||||||
body.step(cl);
|
body.step(cl);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,9 +117,14 @@ void Sensore::calcRotWithG(unsigned int index){ // calcolo rotazione con valori
|
|||||||
body.setRot(rb::Vector3{tmpAY, tmpAX, tmpAZ });
|
body.setRot(rb::Vector3{tmpAY, tmpAX, tmpAZ });
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
void Sensore::calcRotWithConstraint(){
|
|
||||||
|
|
||||||
};*/
|
void Sensore::setIntervall(int min, int max){
|
||||||
|
this->dataIntvl = {min, max};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sensore::setPos(int &pos){
|
||||||
|
this->dataPos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////// cinematica inversa
|
/////////////// cinematica inversa
|
||||||
+13
-9
@@ -34,16 +34,20 @@ struct State
|
|||||||
sf::Vector2i mouse_pos;
|
sf::Vector2i mouse_pos;
|
||||||
|
|
||||||
/// per settare l'ntervallo di visualizzazione
|
/// per settare l'ntervallo di visualizzazione
|
||||||
unsigned int pos = 0;
|
unsigned int* pos ;
|
||||||
unsigned int intervalMajLimit = 1000;
|
unsigned int* intervalMajLimit ;
|
||||||
unsigned int intervalMinLimit = 0;
|
unsigned int* intervalMinLimit ;
|
||||||
unsigned int maxEntries = 10000;
|
unsigned int maxEntries = 1000;
|
||||||
|
bool play = true;
|
||||||
|
|
||||||
State(unsigned w, unsigned h, std::string title)
|
State(unsigned w, unsigned h, std::string title, unsigned int* maj, unsigned int* min, unsigned int* pos)
|
||||||
{
|
{
|
||||||
window = sf::RenderWindow(sf::VideoMode({w, h}), title);
|
window = sf::RenderWindow(sf::VideoMode({w, h}), title);
|
||||||
ImGui::SFML::Init(window);
|
ImGui::SFML::Init(window);
|
||||||
clock.restart();
|
clock.restart();
|
||||||
|
intervalMajLimit = maj;
|
||||||
|
intervalMinLimit = min;
|
||||||
|
this->pos = pos;
|
||||||
}
|
}
|
||||||
void update();
|
void update();
|
||||||
void setIntervall(int n){
|
void setIntervall(int n){
|
||||||
@@ -61,7 +65,7 @@ void State::update(){
|
|||||||
|
|
||||||
|
|
||||||
for(PieceInterface* p : pieces){
|
for(PieceInterface* p : pieces){
|
||||||
p->update(clock);
|
p->update(*pos);
|
||||||
}
|
}
|
||||||
for(JointInterface* j : joints){
|
for(JointInterface* j : joints){
|
||||||
j->movechild();
|
j->movechild();
|
||||||
@@ -207,13 +211,13 @@ void doGUI(State &gs)
|
|||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
ImGui::Begin("Set data position");
|
ImGui::Begin("Set data position");
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.3);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.3);
|
||||||
ImGui::SliderScalar("Min", ImGuiDataType_U32 ,&gs.intervalMinLimit,&zero,&gs.intervalMajLimit);
|
ImGui::SliderScalar("Min", ImGuiDataType_U32 ,gs.intervalMinLimit,&zero,gs.intervalMajLimit);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.5);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.5);
|
||||||
ImGui::SliderScalar("Pos", ImGuiDataType_U32 ,&gs.pos,&gs.intervalMinLimit,&gs.intervalMajLimit);
|
ImGui::SliderScalar("Pos", ImGuiDataType_U32 ,gs.pos,gs.intervalMinLimit,gs.intervalMajLimit);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.8);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.8);
|
||||||
ImGui::SliderScalar("Max", ImGuiDataType_U32 ,&gs.intervalMajLimit,&gs.intervalMinLimit,&gs.maxEntries);
|
ImGui::SliderScalar("Max", ImGuiDataType_U32 ,gs.intervalMajLimit,gs.intervalMinLimit,&gs.maxEntries);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
|||||||
+22
-3
@@ -28,8 +28,15 @@ int main() {
|
|||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inizializzo variabili per gestire l'intervallo di visualizzazione
|
||||||
|
|
||||||
|
unsigned int max = 1000;
|
||||||
|
unsigned int min = 0;
|
||||||
|
unsigned int pos = 0;
|
||||||
|
unsigned int maj = 100;
|
||||||
|
|
||||||
//Costruisco la GUI
|
//Costruisco la GUI
|
||||||
State gs(800, 600, "Visualizzatore passo");
|
State gs(800, 600, "Visualizzatore passo",&maj,&min,&pos);
|
||||||
gs.window.setFramerateLimit(60);
|
gs.window.setFramerateLimit(60);
|
||||||
printf("Costruisco gli oggetti\n");
|
printf("Costruisco gli oggetti\n");
|
||||||
|
|
||||||
@@ -40,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,3000,coscia));
|
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,300},_Float16( 0.2 ),900,900,3000,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});
|
||||||
@@ -48,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,3000,caviglia));
|
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,500},_Float16( 0.2 ),900,900,3000,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));
|
||||||
|
|
||||||
@@ -71,10 +78,22 @@ int main() {
|
|||||||
printf("%s\n",e);
|
printf("%s\n",e);
|
||||||
}
|
}
|
||||||
printf("Avvio l'interfaccia grafica\n");
|
printf("Avvio l'interfaccia grafica\n");
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int curTime;
|
||||||
|
unsigned int freq = 50;
|
||||||
|
const unsigned int T = 1000/freq; //i sensori hanno una freq di campionamento di 50hz
|
||||||
|
|
||||||
//Avvio il loop della GUI
|
//Avvio il loop della GUI
|
||||||
gs.clock.start();
|
gs.clock.start();
|
||||||
while (gs.window.isOpen())
|
while (gs.window.isOpen())
|
||||||
{
|
{
|
||||||
|
curTime += gs.clock.getElapsedTime().asMilliseconds();
|
||||||
|
if (curTime > T){
|
||||||
|
curTime = 0;
|
||||||
|
if (gs.play && pos < maj) pos += 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Show update
|
// Show update
|
||||||
gs.update();
|
gs.update();
|
||||||
doGraphics(gs);
|
doGraphics(gs);
|
||||||
|
|||||||
Reference in New Issue
Block a user