Skip to content
Snippets Groups Projects
Commit 38082645 authored by Arafat NOUREDDINE's avatar Arafat NOUREDDINE
Browse files

Bug Fix : Add AutoMutex m_lock_position

Bug Fix : If Translation And Rotation not requested, Don't send cmd because incremental_move is not initialized
parent abfb9a91
Branches
Tags
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<groupId>fr.soleil.device</groupId> <groupId>fr.soleil.device</groupId>
<artifactId>HexapodNewport-${aol}-${mode}</artifactId> <artifactId>HexapodNewport-${aol}-${mode}</artifactId>
<version>1.2.1-SNAPSHOT</version> <version>1.2.1</version>
<packaging>nar</packaging> <packaging>nar</packaging>
......
...@@ -335,6 +335,7 @@ void HWProxy::process_message(yat::Message& _msg) throw(Tango::DevFailed) ...@@ -335,6 +335,7 @@ void HWProxy::process_message(yat::Message& _msg) throw(Tango::DevFailed)
_msg.detach_data(pos); _msg.detach_data(pos);
if(pos) if(pos)
{ {
yat::AutoMutex<> guard(m_lock_position);
//- update the internal setpoints m_positions_setp //- update the internal setpoints m_positions_setp
std::stringstream cmd; std::stringstream cmd;
...@@ -541,6 +542,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -541,6 +542,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
std::stringstream cmd; std::stringstream cmd;
if(m_conf.positioning_type == HWP_POSIT_ABSOLUTE) if(m_conf.positioning_type == HWP_POSIT_ABSOLUTE)
{ {
yat::AutoMutex<> guard(m_lock_position);
INFO_STREAM << "HWProxy::set_hexapod_positions HWP_POSIT_ABSOLUTE" << std::endl; INFO_STREAM << "HWProxy::set_hexapod_positions HWP_POSIT_ABSOLUTE" << std::endl;
//- update the internal setpoints m_positions_setp //- update the internal setpoints m_positions_setp
cmd << "HexapodMoveAbsolute" cmd << "HexapodMoveAbsolute"
...@@ -557,7 +559,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -557,7 +559,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
<< std::endl; << std::endl;
} }
else else
{ { yat::AutoMutex<> guard(m_lock_position);
//- exception if request for ROTATION AND TRANSLATION //- exception if request for ROTATION AND TRANSLATION
bool translation_request = false; bool translation_request = false;
if( (m_positions_setp [0] != pos.positions [0]) || if( (m_positions_setp [0] != pos.positions [0]) ||
...@@ -605,11 +607,13 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -605,11 +607,13 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
"HWProxy::set_hexapod_positions"); "HWProxy::set_hexapod_positions");
} }
if(translation_request || rotation_request)
{
double incremental_move [6]; double incremental_move [6];
if(translation_request) if(translation_request)
{ {
INFO_STREAM<<"translation_request = true"<<std::endl;
m_positions_setp [0] = pos.positions [0]; m_positions_setp [0] = pos.positions [0];
incremental_move [0] = pos.positions [0] - m_positions_read [0]; incremental_move [0] = pos.positions [0] - m_positions_read [0];
m_positions_setp [1] = pos.positions [1]; m_positions_setp [1] = pos.positions [1];
...@@ -626,6 +630,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -626,6 +630,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
if(rotation_request) if(rotation_request)
{ {
INFO_STREAM<<"rotation_request = true"<<std::endl;
m_positions_setp [0] = pos.positions [0]; m_positions_setp [0] = pos.positions [0];
incremental_move [0] = 0.; incremental_move [0] = 0.;
m_positions_setp [1] = pos.positions [1]; m_positions_setp [1] = pos.positions [1];
...@@ -682,6 +687,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -682,6 +687,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
<< std::fixed; << std::fixed;
for(size_t i = index_first_virtual_axes;i < NB_VIRTUAL_AXES;i++) for(size_t i = index_first_virtual_axes;i < NB_VIRTUAL_AXES;i++)
{ {
cmd << "," << incremental_move [i]; cmd << "," << incremental_move [i];
} }
cmd << ")" cmd << ")"
...@@ -725,7 +731,14 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -725,7 +731,14 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
<< std::endl; << std::endl;
} }
} }
else
{
INFO_STREAM<<"No translation or Rotation movement Requested !"<<std::endl;
return;
}
}
INFO_STREAM<<"Cmd sent : "<<cmd.str()<<std::endl;
//write to the driver //write to the driver
write(cmd.str()); write(cmd.str());
} }
...@@ -736,6 +749,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf) ...@@ -736,6 +749,7 @@ void HWProxy::set_hexapod_positions(positions_t pos, Config conf)
// ============================================================================ // ============================================================================
double HWProxy::get_virtual_axis_position(VirtualAxisName n) double HWProxy::get_virtual_axis_position(VirtualAxisName n)
{ {
yat::AutoMutex<> guard(m_lock_position);
return m_positions_read [n]; return m_positions_read [n];
} }
...@@ -759,6 +773,7 @@ bool HWProxy::read_positions() ...@@ -759,6 +773,7 @@ bool HWProxy::read_positions()
if(write_read(cmd, response)) if(write_read(cmd, response))
{ {
yat::AutoMutex<> guard(m_lock_position);
//- parse the response and put it in the array //- parse the response and put it in the array
//- response form 0,0.1789513061472,0.02960289503446,0.0603300456024,-0.02644901123962,0.0699330284329,-0.0001644046095955,EndOfAPI //- response form 0,0.1789513061472,0.02960289503446,0.0603300456024,-0.02644901123962,0.0699330284329,-0.0001644046095955,EndOfAPI
//- response form cmd status,X,Y,Z,U,V,W,EndOfAPI //- response form cmd status,X,Y,Z,U,V,W,EndOfAPI
......
...@@ -251,7 +251,7 @@ private: ...@@ -251,7 +251,7 @@ private:
//- au cas ou.... //- au cas ou....
yat::Mutex m_lock_wr; yat::Mutex m_lock_wr;
yat::Mutex m_lock_w; yat::Mutex m_lock_w;
yat::Mutex m_lock_position;
//- the periodic execution time //- the periodic execution time
size_t m_periodic_exec_ms; size_t m_periodic_exec_ms;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment