diff --git a/src/bioloid_robot.cpp b/src/bioloid_robot.cpp index bb3238ecfe5e91654d6192dda6eec134fc855c85..f6daf9ec13d68c076d0cc99d70a1bec5a33ccba3 100644 --- a/src/bioloid_robot.cpp +++ b/src/bioloid_robot.cpp @@ -5,22 +5,15 @@ CBioloidRobot::CBioloidRobot(const std::string &name,std::string &serial_dev,int baudrate, unsigned char id,gpio_ports port, int pin) : ext_int(port,pin) { this->robot_device=NULL; - this->serial_device=NULL; if(name!="") { this->robot_name=name; - this->dyn_server=CDynamixelServer::instance(); + this->dyn_server=CDynamixelServerSerial::instance(); try{ /* open and configure the serial port */ - this->serial_device=new CRS232(this->robot_name+"_serial_port"); - this->serial_device->open((void *)&serial_dev); - this->serial_config.baud=baudrate; - this->serial_config.num_bits=8; - this->serial_config.parity=none; - this->serial_config.stop_bits=1; - this->serial_device->config(&this->serial_config); - this->dyn_server->config_comm(this->serial_device); - this->robot_device=dyn_server->get_device(id); + this->serial_device=serial_dev; + this->dyn_server->config_bus(this->serial_device,baudrate); + this->robot_device=dyn_server->get_device(id,dyn_version2); this->robot_id=id; /* configure the gpio pin for the external interrupt */ this->ext_int.set_direction(input); @@ -56,11 +49,6 @@ CBioloidRobot::CBioloidRobot(const std::string &name,std::string &serial_dev,int }catch(CException &e){ if(this->robot_device!=NULL) this->dyn_server->free_device(id); - if(this->serial_device!=NULL) - { - delete this->serial_device; - this->serial_device=NULL; - } /* handle exceptions */ throw; } @@ -843,11 +831,6 @@ CBioloidRobot::~CBioloidRobot() this->event_server->delete_event(this->finish_thread_event_id); this->finish_thread_event_id=""; - if(this->serial_device!=NULL) - { - delete this->serial_device; - this->serial_device=NULL; - } if(this->robot_device!=NULL) this->dyn_server->free_device(this->robot_id); } diff --git a/src/bioloid_robot.h b/src/bioloid_robot.h index 8ae30f568bb8fefc1cd1dbf06ad2ddaee8c1fdb0..c678dee34441b29270335072115c38674126a0da 100644 --- a/src/bioloid_robot.h +++ b/src/bioloid_robot.h @@ -1,7 +1,7 @@ #ifndef _BIOLOID_ROBOT_H #define _BIOLOID_ROBOT_H -#include "dynamixelserver.h" +#include "dynamixelserver_serial.h" #include "dynamixel.h" #include "rs232.h" #include "bbb_gpio.h" @@ -25,12 +25,10 @@ class CBioloidRobot { private: /* dynamixel interface */ - CDynamixelServer *dyn_server; + CDynamixelServerSerial *dyn_server; CDynamixel *robot_device; + std::string serial_device; unsigned char robot_id; - /* communication interface */ - CRS232 *serial_device; - TRS232_config serial_config; /* external interrupt GPIO pin */ CGPIO ext_int; std::string ext_int_event_id; diff --git a/src/examples/bioloid_robot_test.cpp b/src/examples/bioloid_robot_test.cpp index ab50a70a732c5b34feef42cbd0b3b66f13149f7e..e060430109b4532372755ada3e182dc86e85d7a2 100644 --- a/src/examples/bioloid_robot_test.cpp +++ b/src/examples/bioloid_robot_test.cpp @@ -190,14 +190,17 @@ int main(int argc, char *argv[]) std::cout << " and assigned to module " << tina.mm_get_module(i) << std::endl; } tina.mm_start(); - tina.mm_enable_balance(); + //tina.mm_enable_balance(); tina.mm_enable_power(); tina.action_load_page(WALK_READY); tina.action_start(); while(tina.action_is_page_running()) usleep(100000); sleep(2); - tina.action_load_page(LT_S_L); + tina.mm_disable_power(); + tina.mm_stop(); + return 0; + tina.action_load_page(RT_S_R); tina.action_start(); for(i=0;i<100;i++) {