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

Added an exception catch in the constructor.

parent fbed73da
No related branches found
No related tags found
No related merge requests found
#include "darwin_robot.h" #include "darwin_robot.h"
#include "darwin_robot_exceptions.h" #include "darwin_robot_exceptions.h"
#include "dynamixelexceptions.h"
#include <iostream> #include <iostream>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -82,23 +83,28 @@ CDarwinRobot::CDarwinRobot(const std::string &name,std::string &bus_id,int bus_s ...@@ -82,23 +83,28 @@ CDarwinRobot::CDarwinRobot(const std::string &name,std::string &bus_id,int bus_s
if(num_buses>0) if(num_buses>0)
{ {
sleep(1); sleep(1);
this->robot_device=dyn_server->get_device(id,dyn_version2); try{
this->robot_id=id; this->robot_device=dyn_server->get_device(id,dyn_version2);
/* wait for the firmware to finish the scan */ this->robot_id=id;
do{ /* wait for the firmware to finish the scan */
/* get the current manager status */ do{
this->robot_device->read_byte_register(DARWIN_MM_CNTRL,&this->manager_status); /* get the current manager status */
usleep(10000); this->robot_device->read_byte_register(DARWIN_MM_CNTRL,&this->manager_status);
}while(this->manager_status&MANAGER_SCANNING); usleep(10000);
/* get the number of servos detected */ }while(this->manager_status&MANAGER_SCANNING);
this->robot_device->read_byte_register(DARWIN_MM_NUM_SERVOS,&this->manager_num_servos); /* get the number of servos detected */
/* get the current action status */ this->robot_device->read_byte_register(DARWIN_MM_NUM_SERVOS,&this->manager_num_servos);
this->robot_device->read_byte_register(DARWIN_ACTION_CNTRL,&this->action_status); /* get the current action status */
/* get the current smart charger status (detected or not)*/ this->robot_device->read_byte_register(DARWIN_ACTION_CNTRL,&this->action_status);
this->robot_device->read_byte_register(DARWIN_SMART_CHARGER_CNTRL,&this->smart_charger_status); /* get the current smart charger status (detected or not)*/
this->min_limit_current=MIN_LIMIT_CURRENT; this->robot_device->read_byte_register(DARWIN_SMART_CHARGER_CNTRL,&this->smart_charger_status);
this->max_limit_current=MAX_LIMIT_CURRENT; this->min_limit_current=MIN_LIMIT_CURRENT;
this->max_limit_current=MAX_LIMIT_CURRENT;
}catch(CDynamixelServerException &e){
this->dyn_server->free_device(id);
std::cout << "exception" << std::endl;
throw e;
}
} }
else else
{ {
......
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