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

Get the instance to the dynamixel server in the constructor.

parent 2e609ab3
No related branches found
No related tags found
No related merge requests found
# driver source files # driver source files
SET(sources ir_feet.cpp ir_feet_exceptions.cpp) SET(sources ir_feet_exceptions.cpp)
# application header files # application header files
SET(headers ir_feet.h ir_feet_exceptions.h) SET(headers ir_feet.h ir_feet_exceptions.h)
SET(fw_headers ../../ir_feet_fw/include/adc_dma_registers.h ../../ir_feet_fw/include/ir_feet_dyn_slave_registers.h ../../ir_feet_fw/include/thresholds_registers.h ../../ir_feet_fw/include/ir_feet_conf.h) SET(fw_headers ../../ir_feet_fw/include/adc_dma_registers.h ../../ir_feet_fw/include/ir_feet_dyn_slave_registers.h ../../ir_feet_fw/include/thresholds_registers.h ../../ir_feet_fw/include/ir_feet_conf.h)
......
...@@ -12,6 +12,7 @@ int main(int argc, char *argv[]) ...@@ -12,6 +12,7 @@ int main(int argc, char *argv[])
try{ try{
CIRFeet<CDynamixelServerFTDI> foot_sensor(foot_sensor_name,dyn_serial,115200,0x01); CIRFeet<CDynamixelServerFTDI> foot_sensor(foot_sensor_name,dyn_serial,115200,0x01);
CIRFeet<CDynamixelServerFTDI> foot_sensor2(foot_sensor_name,dyn_serial,115200,0x02);
for(i=0;i<1000;i++) for(i=0;i<1000;i++)
{ {
std::cout << "Down left middle sensor: " << foot_sensor.get_sensor_voltage(DOWN_LEFT_MIDDLE_CH) << " threshold set to: " << foot_sensor.get_sensor_threshold(DOWN_LEFT_MIDDLE_CH) << std::endl; std::cout << "Down left middle sensor: " << foot_sensor.get_sensor_voltage(DOWN_LEFT_MIDDLE_CH) << " threshold set to: " << foot_sensor.get_sensor_threshold(DOWN_LEFT_MIDDLE_CH) << std::endl;
......
...@@ -32,12 +32,13 @@ class CIRFeet ...@@ -32,12 +32,13 @@ class CIRFeet
void set_sensor_threshold(adc_dma_ch_t channel_id, double threshold); void set_sensor_threshold(adc_dma_ch_t channel_id, double threshold);
bool is_sensor_active(adc_dma_ch_t channel_id); bool is_sensor_active(adc_dma_ch_t channel_id);
std::vector<bool> get_all_sensor_status(void); std::vector<bool> get_all_sensor_status(void);
~CIRFeet(); virtual ~CIRFeet();
}; };
template <class T> template <class T>
CIRFeet<T>::CIRFeet(const std::string& ir_feet_id,std::string& bus_id,int baudrate,unsigned char dev_id) CIRFeet<T>::CIRFeet(const std::string& ir_feet_id,std::string& bus_id,int baudrate,unsigned char dev_id)
{ {
this->dyn_server=T::instance();
this->dyn_device=NULL; this->dyn_device=NULL;
try{ try{
this->dyn_server->config_bus(bus_id,baudrate); this->dyn_server->config_bus(bus_id,baudrate);
...@@ -49,6 +50,7 @@ CIRFeet<T>::CIRFeet(const std::string& ir_feet_id,std::string& bus_id,int baudra ...@@ -49,6 +50,7 @@ CIRFeet<T>::CIRFeet(const std::string& ir_feet_id,std::string& bus_id,int baudra
if(this->dyn_device!=NULL) if(this->dyn_device!=NULL)
delete this->dyn_device; delete this->dyn_device;
this->dyn_device=NULL; this->dyn_device=NULL;
this->dyn_server->free_device(dev_id);
throw; throw;
} }
} }
......
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