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

Updated the slave interface to version 2.

parent 73bed5bb
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
#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;
......
......@@ -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++)
{
......
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