From 9d1c3644ecb920680ef5451c7ee3538f218e3ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu> Date: Wed, 15 Apr 2015 13:01:17 +0000 Subject: [PATCH] In the group module, the path for the main configuration file is also used for each of the seros in the group. Solved some problems when the XSD library is not present. --- src/dynamixel_motor_group.cpp | 7 ++++++- src/examples/test_dynamixel_motor_group.cpp | 23 +++++++++++---------- src/xml/dyn_group_config.xml | 8 +++---- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/dynamixel_motor_group.cpp b/src/dynamixel_motor_group.cpp index d780f18..8cd9adf 100644 --- a/src/dynamixel_motor_group.cpp +++ b/src/dynamixel_motor_group.cpp @@ -934,7 +934,9 @@ void CDynamixelMotorGroup::load_config(std::string &filename) dyn_motor_group_config_t::dyn_motor_config_iterator iterator; std::vector<TDynamixel_compliance> compliance; std::vector<TDynamixel_pid> pid; + std::string full_path,path; struct stat buffer; + size_t found; unsigned int i=0; this->clear(); @@ -947,11 +949,14 @@ void CDynamixelMotorGroup::load_config(std::string &filename) this->dyn_server->config_bus(cfg->bus_id(),cfg->baudrate()); pid.resize(cfg->dyn_motor_config().size()); compliance.resize(cfg->dyn_motor_config().size()); + found=filename.find_last_of("/"); + path=filename.substr(0,found+1); for(iterator=cfg->dyn_motor_config().begin(),i=0;iterator!=cfg->dyn_motor_config().end();iterator++,i++) { this->init_motor(iterator->id()); // load the configuration file - std::auto_ptr<dynamixel_motor_config_t> motor(dynamixel_motor_config(iterator->config_file().c_str(),xml_schema::flags::dont_validate)); + full_path=path+iterator->config_file(); + std::auto_ptr<dynamixel_motor_config_t> motor(dynamixel_motor_config(full_path.c_str(),xml_schema::flags::dont_validate)); this->set_position_range(i,motor->min_angle(),motor->max_angle()); this->set_temperature_limit(i,motor->temp_limit()); this->set_voltage_limits(i,motor->min_voltage(),motor->max_voltage()); diff --git a/src/examples/test_dynamixel_motor_group.cpp b/src/examples/test_dynamixel_motor_group.cpp index f80dd30..9c44294 100644 --- a/src/examples/test_dynamixel_motor_group.cpp +++ b/src/examples/test_dynamixel_motor_group.cpp @@ -25,32 +25,33 @@ int main(int argc, char *argv[]) group.load_config(config_file); angles.resize(2); angles[0]=90; - angles[1]=-90; + angles[1]=-10; speeds.resize(2); speeds[0]=100; - speeds[1]=50; + speeds[1]=20; group.move_absolute_angle(angles,speeds); sleep(5); angles.resize(2); angles[0]=-90; - angles[1]=90; + angles[1]=10; group.move_absolute_angle(angles,speeds); - sleep(5); + sleep(5); // relative motion angles[0]=10; - angles[1]=-10; + angles[1]=-1; for(i=0;i<10;i++) { + std::cout << "relative move" << std::endl; group.move_relative_angle(angles,speeds); sleep(1); } // torque motion - torques.resize(2); - torques[0]=100.0; - torques[1]=-50; - group.move_torque(torques); - sleep(4); - group.stop(); +// torques.resize(2); +// torques[0]=100.0; +// torques[1]=-50; +// group.move_torque(torques); +// sleep(4); +// group.stop(); #endif } }catch(CException &e){ diff --git a/src/xml/dyn_group_config.xml b/src/xml/dyn_group_config.xml index 48864fe..ac4a867 100755 --- a/src/xml/dyn_group_config.xml +++ b/src/xml/dyn_group_config.xml @@ -3,14 +3,14 @@ <dyn_motor_group_config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="dyn_motor_group_cfg_file.xsd"> - <bus_id>A4012B3G</bus_id> + <bus_id>A400gaIt</bus_id> <baudrate>1000000</baudrate> <dyn_motor_config> <id>1</id> - <config_file>../src/xml/dyn_config.xml</config_file> + <config_file>dyn_config.xml</config_file> </dyn_motor_config> <dyn_motor_config> - <id>3</id> - <config_file>../src/xml/dyn_config.xml</config_file> + <id>2</id> + <config_file>dyn_config.xml</config_file> </dyn_motor_config> </dyn_motor_group_config> -- GitLab