Skip to content
Snippets Groups Projects
Commit c3ad6d6e authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Modified the motion sequence XML files.

Changes the motion sequence example to test the insertion and addition of steps on-line.
parent 3fe9d40d
No related branches found
No related tags found
No related merge requests found
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
std::string cont_name1="AX-12+_1"; std::string cont_name1="AX-12+_1";
std::string cont_name2="AX-12+_2"; std::string cont_name2="AX-12+_2";
std::string cont_name3="AX-12+_3";
std::string seq_name="test_sequence"; std::string seq_name="test_sequence";
std::string seq_file="../src/xml/test_motion.xml"; std::string seq_file="../src/xml/test_motion.xml";
std::string seq_file2="../src/xml/test_motion2.xml"; std::string seq_file2="../src/xml/test_motion2.xml";
std::string seq_file3="../src/xml/test_motion3.xml";
std::string group_name="test"; std::string group_name="test";
std::string cont_config_file="../src/xml/base_dyn_config.xml"; std::string cont_config_file="../src/xml/base_dyn_config.xml";
...@@ -21,15 +23,20 @@ int main(int argc, char * argv[]) ...@@ -21,15 +23,20 @@ int main(int argc, char * argv[])
CMotorGroup group(group_name); CMotorGroup group(group_name);
CMotionSequence sequence(seq_name); CMotionSequence sequence(seq_name);
CDynamixelMotor cont1(cont_name1,0,1000000,1); CDynamixelMotor cont1(cont_name1,0,1000000,1);
CDynamixelMotor cont2(cont_name2,0,1000000,15); CDynamixelMotor cont2(cont_name2,0,1000000,12);
CDynamixelMotor cont3(cont_name3,0,1000000,15);
std::vector<float> position(3);
std::vector<float> velocity(3);
events.push_back(sequence.get_sequence_complete_event_id()); events.push_back(sequence.get_sequence_complete_event_id());
#ifdef _HAVE_XSD #ifdef _HAVE_XSD
cont1.load_config(cont_config_file); cont1.load_config(cont_config_file);
cont2.load_config(cont_config_file); cont2.load_config(cont_config_file);
cont3.load_config(cont_config_file);
#endif #endif
group.add_motor_control(&cont1); group.add_motor_control(&cont1);
group.add_motor_control(&cont2); group.add_motor_control(&cont2);
group.add_motor_control(&cont3);
sequence.set_motor_group(&group); sequence.set_motor_group(&group);
#ifdef _HAVE_XSD #ifdef _HAVE_XSD
sequence.load_sequence(seq_file); sequence.load_sequence(seq_file);
...@@ -47,12 +54,32 @@ int main(int argc, char * argv[]) ...@@ -47,12 +54,32 @@ int main(int argc, char * argv[])
usleep(200000); usleep(200000);
} }
sequence.load_sequence(seq_file2); sequence.load_sequence(seq_file2);
position[0]=100;
position[1]=200;
position[2]=100;
velocity[0]=50;
velocity[1]=50;
velocity[2]=50;
sequence.add_step(position,velocity,0);
position[0]=200;
position[1]=100;
position[2]=200;
sequence.add_step(position,velocity,2000);
position[0]=100;
position[1]=200;
position[2]=100;
sequence.add_step(position,velocity,0);
position[0]=0;
position[1]=0;
position[2]=0;
sequence.insert_step(0,position,velocity,0);
sequence.start_sequence(); sequence.start_sequence();
while(!event_server->event_is_set(sequence.get_sequence_complete_event_id())) while(!event_server->event_is_set(sequence.get_sequence_complete_event_id()))
{ {
std::cout << sequence.get_completed_percentage() << "% of sequence completed" << std::endl; std::cout << sequence.get_completed_percentage() << "% of sequence completed" << std::endl;
usleep(200000); usleep(200000);
} }
sequence.save_sequence(seq_file3);
#else #else
std::cout << "Impossible to execute sequence because the XML library is not available" << std::endl; std::cout << "Impossible to execute sequence because the XML library is not available" << std::endl;
#endif #endif
......
<?xml version="1.0"?> <?xml version="1.0"?>
<sequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <motion_seq xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="motion_sequence_file.xsd"> xsi:noNamespaceSchemaLocation="motion_sequence_file.xsd">
<num_motors>2</num_motors> <num_motors>3</num_motors>
<num_steps>10</num_steps> <num_steps>1</num_steps>
<control>position</control> <control>position</control>
<motion>absolute</motion> <motion>absolute</motion>
<step> <step>
<position>0.0</position>
<position>150.0</position> <position>150.0</position>
<position>150.0</position>
<position>150.0</position>
<velocity>100.0</velocity>
<velocity>100.0</velocity> <velocity>100.0</velocity>
<velocity>100.0</velocity> <velocity>100.0</velocity>
<delay>0</delay> <delay>0</delay>
</step> </step>
</sequence> </motion_seq>
<?xml version="1.0"?>
<motion_seq xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="motion_sequence_file.xsd">
<num_motors>3</num_motors>
<num_steps>1</num_steps>
<control>position</control>
<motion>absolute</motion>
<step>
<position>150.0</position>
<position>150.0</position>
<position>150.0</position>
<velocity>150.0</velocity>
<velocity>150.0</velocity>
<velocity>150.0</velocity>
<delay>0</delay>
</step>
</motion_seq>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment