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

Changed the class name of the IR sensor driver wrapper.

parent 172267cf
No related branches found
No related tags found
1 merge request!4Filtered localization
cmake_minimum_required(VERSION 2.8.3) cmake_minimum_required(VERSION 2.8.3)
project(ir_feet_sensor) project(ir_foot_sensor)
## Find catkin macros and libraries ## Find catkin macros and libraries
find_package(catkin REQUIRED) find_package(catkin REQUIRED)
# ******************************************************************** # ********************************************************************
# Add catkin additional components here # Add catkin additional components here
# ******************************************************************** # ********************************************************************
find_package(catkin REQUIRED COMPONENTS iri_base_driver) find_package(catkin REQUIRED COMPONENTS iri_base_driver humanoid_common_msgs)
## System dependencies are found with CMake's conventions ## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system) # find_package(Boost REQUIRED COMPONENTS system)
...@@ -17,7 +17,7 @@ find_package(catkin REQUIRED COMPONENTS iri_base_driver) ...@@ -17,7 +17,7 @@ find_package(catkin REQUIRED COMPONENTS iri_base_driver)
# find_package(<dependency> REQUIRED) # find_package(<dependency> REQUIRED)
find_package(iriutils REQUIRED) find_package(iriutils REQUIRED)
find_package(comm REQUIRED) find_package(comm REQUIRED)
find_package(iriutils REQUIRED) find_package(dynamixel REQUIRED)
find_package(ir_feet REQUIRED) find_package(ir_feet REQUIRED)
# ******************************************************************** # ********************************************************************
...@@ -64,7 +64,7 @@ catkin_package( ...@@ -64,7 +64,7 @@ catkin_package(
# ******************************************************************** # ********************************************************************
# Add ROS and IRI ROS run time dependencies # Add ROS and IRI ROS run time dependencies
# ******************************************************************** # ********************************************************************
CATKIN_DEPENDS iri_base_driver CATKIN_DEPENDS iri_base_driver humanoid_common_msgs
# ******************************************************************** # ********************************************************************
# Add system and labrobotica run time dependencies here # Add system and labrobotica run time dependencies here
# ******************************************************************** # ********************************************************************
...@@ -91,7 +91,7 @@ include_directories(${ir_feet_INCLUDE_DIR}) ...@@ -91,7 +91,7 @@ include_directories(${ir_feet_INCLUDE_DIR})
# add_library(${PROJECT_NAME} <list of source files>) # add_library(${PROJECT_NAME} <list of source files>)
## Declare a cpp executable ## Declare a cpp executable
add_executable(${PROJECT_NAME} src/ir_feet_sensor_driver.cpp src/ir_feet_sensor_driver_node.cpp) add_executable(${PROJECT_NAME} src/ir_foot_sensor_driver.cpp src/ir_foot_sensor_driver_node.cpp)
# ******************************************************************** # ********************************************************************
# Add the libraries # Add the libraries
...@@ -107,6 +107,7 @@ target_link_libraries(${PROJECT_NAME} ${ir_feet_LIBRARY}) ...@@ -107,6 +107,7 @@ target_link_libraries(${PROJECT_NAME} ${ir_feet_LIBRARY})
# Add message headers dependencies # Add message headers dependencies
# ******************************************************************** # ********************************************************************
# add_dependencies(${PROJECT_NAME} <msg_package_name>_generate_messages_cpp) # add_dependencies(${PROJECT_NAME} <msg_package_name>_generate_messages_cpp)
add_dependencies(${PROJECT_NAME} humanoid_common_msgs_generate_messages_cpp)
# ******************************************************************** # ********************************************************************
# Add dynamic reconfigure dependencies # Add dynamic reconfigure dependencies
# ******************************************************************** # ********************************************************************
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
# Author: # Author:
PACKAGE='ir_feet_sensor' PACKAGE='ir_foot_sensor'
from driver_base.msg import SensorLevels from driver_base.msg import SensorLevels
from dynamic_reconfigure.parameter_generator_catkin import * from dynamic_reconfigure.parameter_generator_catkin import *
...@@ -44,4 +44,4 @@ gen.add("dyn_serial", str_t, SensorLevels.RECONFIGURE_STOP, ...@@ -44,4 +44,4 @@ gen.add("dyn_serial", str_t, SensorLevels.RECONFIGURE_STOP,
gen.add("dyn_baudrate", int_t, SensorLevels.RECONFIGURE_STOP, "Dynamixel serial baudrate", 1000000, 9600, 3000000) gen.add("dyn_baudrate", int_t, SensorLevels.RECONFIGURE_STOP, "Dynamixel serial baudrate", 1000000, 9600, 3000000)
gen.add("ir_foot_id", int_t, SensorLevels.RECONFIGURE_STOP, "IR foot identifier", 1, 0, 254) gen.add("ir_foot_id", int_t, SensorLevels.RECONFIGURE_STOP, "IR foot identifier", 1, 0, 254)
exit(gen.generate(PACKAGE, "IrFeetSensorDriver", "IrFeetSensor")) exit(gen.generate(PACKAGE, "IrFootSensorDriver", "IrFootSensor"))
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
// refer to the IRI wiki page for more information: // refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab // http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _ir_feet_sensor_driver_h_ #ifndef _ir_foot_sensor_driver_h_
#define _ir_feet_sensor_driver_h_ #define _ir_foot_sensor_driver_h_
#include <iri_base_driver/iri_base_driver.h> #include <iri_base_driver/iri_base_driver.h>
#include <ir_feet_sensor/IrFeetSensorConfig.h> #include <ir_foot_sensor/IrFootSensorConfig.h>
//include ir_feet_sensor_driver main library //include ir_foot_sensor_driver main library
#include "dynamixelserver_serial.h" #include "dynamixelserver_serial.h"
#include "ir_feet.h" #include "ir_feet.h"
...@@ -41,29 +41,29 @@ ...@@ -41,29 +41,29 @@
* ROS driver structure. ROS driver_base state transitions are already managed * ROS driver structure. ROS driver_base state transitions are already managed
* by IriBaseDriver. * by IriBaseDriver.
* *
* The IrFeetSensorDriver class must implement all specific driver requirements to * The IrFootSensorDriver class must implement all specific driver requirements to
* safetely open, close, run and stop the driver at any time. It also must * safetely open, close, run and stop the driver at any time. It also must
* guarantee an accessible interface for all driver's parameters. * guarantee an accessible interface for all driver's parameters.
* *
* The IrFeetSensorConfig.cfg needs to be filled up with those parameters suitable * The IrFootSensorConfig.cfg needs to be filled up with those parameters suitable
* to be changed dynamically by the ROS dyanmic reconfigure application. The * to be changed dynamically by the ROS dyanmic reconfigure application. The
* implementation of the CIriNode class will manage those parameters through * implementation of the CIriNode class will manage those parameters through
* methods like postNodeOpenHook() and reconfigureNodeHook(). * methods like postNodeOpenHook() and reconfigureNodeHook().
* *
*/ */
class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver class IrFootSensorDriver : public iri_base_driver::IriBaseDriver
{ {
private: private:
// private attributes and methods // private attributes and methods
CIRFeet<CDynamixelServerSerial> *device; CIRFoot<CDynamixelServerSerial> *device;
public: public:
/** /**
* \brief define config type * \brief define config type
* *
* Define a Config type with the IrFeetSensorConfig. All driver implementations * Define a Config type with the IrFootSensorConfig. All driver implementations
* will then use the same variable type Config. * will then use the same variable type Config.
*/ */
typedef ir_feet_sensor::IrFeetSensorConfig Config; typedef ir_foot_sensor::IrFootSensorConfig Config;
/** /**
* \brief config variable * \brief config variable
...@@ -81,7 +81,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver ...@@ -81,7 +81,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver
* Attributes from the main node driver class IriBaseDriver such as loop_rate, * Attributes from the main node driver class IriBaseDriver such as loop_rate,
* may be also overload here. * may be also overload here.
*/ */
IrFeetSensorDriver(void); IrFootSensorDriver(void);
/** /**
* \brief open driver * \brief open driver
...@@ -144,7 +144,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver ...@@ -144,7 +144,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver
*/ */
void config_update(Config& new_cfg, uint32_t level=0); void config_update(Config& new_cfg, uint32_t level=0);
// here define all ir_feet_sensor_driver interface methods to retrieve and set // here define all ir_foot_sensor_driver interface methods to retrieve and set
// the driver parameters // the driver parameters
std::vector<double> get_all_sensor_voltages(void); std::vector<double> get_all_sensor_voltages(void);
std::vector<double> get_all_sensor_thresholds(void); std::vector<double> get_all_sensor_thresholds(void);
...@@ -157,7 +157,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver ...@@ -157,7 +157,7 @@ class IrFeetSensorDriver : public iri_base_driver::IriBaseDriver
* This destructor is called when the object is about to be destroyed. * This destructor is called when the object is about to be destroyed.
* *
*/ */
~IrFeetSensorDriver(void); ~IrFootSensorDriver(void);
}; };
#endif #endif
...@@ -22,13 +22,14 @@ ...@@ -22,13 +22,14 @@
// refer to the IRI wiki page for more information: // refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab // http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _ir_feet_sensor_driver_node_h_ #ifndef _ir_foot_sensor_driver_node_h_
#define _ir_feet_sensor_driver_node_h_ #define _ir_foot_sensor_driver_node_h_
#include <iri_base_driver/iri_base_driver_node.h> #include <iri_base_driver/iri_base_driver_node.h>
#include "ir_feet_sensor_driver.h" #include "ir_foot_sensor_driver.h"
// [publisher subscriber headers] // [publisher subscriber headers]
#include <humanoid_common_msgs/ir_foot_data.h>
// [service client headers] // [service client headers]
...@@ -51,10 +52,13 @@ ...@@ -51,10 +52,13 @@
* http://www.ros.org/wiki/diagnostics/ (Tutorials: Creating a Diagnostic Analyzer) * http://www.ros.org/wiki/diagnostics/ (Tutorials: Creating a Diagnostic Analyzer)
* http://www.ros.org/wiki/self_test/ (Example: Self Test) * http://www.ros.org/wiki/self_test/ (Example: Self Test)
*/ */
class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetSensorDriver> class IrFootSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFootSensorDriver>
{ {
private: private:
// [publisher attributes] // [publisher attributes]
ros::Publisher sensor_data_publisher_;
humanoid_common_msgs::ir_foot_data sensor_data_ir_foot_data_msg_;
// [subscriber attributes] // [subscriber attributes]
...@@ -79,7 +83,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS ...@@ -79,7 +83,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS
/** /**
* \brief constructor * \brief constructor
* *
* This constructor mainly creates and initializes the IrFeetSensorDriverNode topics * This constructor mainly creates and initializes the IrFootSensorDriverNode topics
* through the given public_node_handle object. IriBaseNodeDriver attributes * through the given public_node_handle object. IriBaseNodeDriver attributes
* may be also modified to suit node specifications. * may be also modified to suit node specifications.
* *
...@@ -93,7 +97,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS ...@@ -93,7 +97,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS
* *
* \param nh a reference to the node handle object to manage all ROS topics. * \param nh a reference to the node handle object to manage all ROS topics.
*/ */
IrFeetSensorDriverNode(ros::NodeHandle& nh); IrFootSensorDriverNode(ros::NodeHandle& nh);
/** /**
* \brief Destructor * \brief Destructor
...@@ -101,7 +105,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS ...@@ -101,7 +105,7 @@ class IrFeetSensorDriverNode : public iri_base_driver::IriBaseNodeDriver<IrFeetS
* This destructor is called when the object is about to be destroyed. * This destructor is called when the object is about to be destroyed.
* *
*/ */
~IrFeetSensorDriverNode(void); ~IrFootSensorDriverNode(void);
protected: protected:
/** /**
......
<?xml version="1.0"?> <?xml version="1.0"?>
<package> <package>
<name>ir_feet_sensor</name> <name>ir_foot_sensor</name>
<version>0.0.0</version> <version>0.0.0</version>
<description>The ir_feet_sensor package</description> <description>The ir_foot_sensor package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag --> <!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: --> <!-- Example: -->
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<!-- Url tags are optional, but multiple are allowed, one per tag --> <!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository --> <!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: --> <!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/ir_feet_sensor</url> --> <!-- <url type="website">http://wiki.ros.org/ir_foot_sensor</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag --> <!-- Author tags are optional, multiple are allowed, one per tag -->
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
<!-- <test_depend>gtest</test_depend> --> <!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>catkin</buildtool_depend>
<build_depend>iri_base_driver</build_depend> <build_depend>iri_base_driver</build_depend>
<build_depend>humanoid_common_msgs</build_depend>
<run_depend>iri_base_driver</run_depend> <run_depend>iri_base_driver</run_depend>
<run_depend>humanoid_common_msgs</run_depend>
<!-- The export tag contains other, unspecified, tags --> <!-- The export tag contains other, unspecified, tags -->
......
#include "ir_feet_sensor_driver.h" #include "ir_foot_sensor_driver.h"
IrFeetSensorDriver::IrFeetSensorDriver(void) IrFootSensorDriver::IrFootSensorDriver(void)
{ {
//setDriverId(driver string id); //setDriverId(driver string id);
this->device=NULL; this->device=NULL;
} }
bool IrFeetSensorDriver::openDriver(void) bool IrFootSensorDriver::openDriver(void)
{ {
std::stringstream name;
try{ try{
if(this->device!=NULL) if(this->device!=NULL)
{ {
delete this->device; delete this->device;
this->device=NULL; this->device=NULL;
} }
this->device=new CIRFeet<CDynamixelServerSerial>("feet",this->config_.dyn_serial,this->config_.dyn_baudrate,this->config_.ir_foot_id); name << foot << "_" << this->config_.ir_foot_id;
this->device=new CIRFoot<CDynamixelServerSerial>(name.str(),this->config_.dyn_serial,this->config_.dyn_baudrate,this->config_.ir_foot_id);
return true; return true;
}catch(CException &e){ }catch(CException &e){
...@@ -23,13 +26,13 @@ bool IrFeetSensorDriver::openDriver(void) ...@@ -23,13 +26,13 @@ bool IrFeetSensorDriver::openDriver(void)
} }
} }
bool IrFeetSensorDriver::closeDriver(void) bool IrFootSensorDriver::closeDriver(void)
{ {
try{ try{
if(this->darwin!=NULL) if(this->device!=NULL)
{ {
delete this->darwin; delete this->device;
this->darwin=NULL; this->device=NULL;
} }
return true; return true;
}catch(CException &e){ }catch(CException &e){
...@@ -38,17 +41,17 @@ bool IrFeetSensorDriver::closeDriver(void) ...@@ -38,17 +41,17 @@ bool IrFeetSensorDriver::closeDriver(void)
} }
} }
bool IrFeetSensorDriver::startDriver(void) bool IrFootSensorDriver::startDriver(void)
{ {
return true; return true;
} }
bool IrFeetSensorDriver::stopDriver(void) bool IrFootSensorDriver::stopDriver(void)
{ {
return true; return true;
} }
void IrFeetSensorDriver::config_update(Config& new_cfg, uint32_t level) void IrFootSensorDriver::config_update(Config& new_cfg, uint32_t level)
{ {
this->lock(); this->lock();
...@@ -56,13 +59,13 @@ void IrFeetSensorDriver::config_update(Config& new_cfg, uint32_t level) ...@@ -56,13 +59,13 @@ void IrFeetSensorDriver::config_update(Config& new_cfg, uint32_t level)
// update driver with new_cfg data // update driver with new_cfg data
switch(this->getState()) switch(this->getState())
{ {
case IrFeetSensorDriver::CLOSED: case IrFootSensorDriver::CLOSED:
break; break;
case IrFeetSensorDriver::OPENED: case IrFootSensorDriver::OPENED:
break; break;
case IrFeetSensorDriver::RUNNING: case IrFootSensorDriver::RUNNING:
break; break;
} }
...@@ -72,27 +75,37 @@ void IrFeetSensorDriver::config_update(Config& new_cfg, uint32_t level) ...@@ -72,27 +75,37 @@ void IrFeetSensorDriver::config_update(Config& new_cfg, uint32_t level)
this->unlock(); this->unlock();
} }
std::vector<double> IrFeetSensorDriver::get_all_sensor_voltages(void) std::vector<double> IrFootSensorDriver::get_all_sensor_voltages(void)
{ {
if(this->device!=NULL)
return this->device->get_all_sensor_voltages();
else
return std::vector<double>();
} }
std::vector<double> IrFeetSensorDriver::get_all_sensor_thresholds(void) std::vector<double> IrFootSensorDriver::get_all_sensor_thresholds(void)
{ {
if(this->device!=NULL)
return this->device->get_all_sensor_thresholds();
else
return std::vector<double>();
} }
void IrFeetSensorDriver::set_sensor_threshold(adc_dma_ch_t channel_id, double threshold) void IrFootSensorDriver::set_sensor_threshold(adc_dma_ch_t channel_id, double threshold)
{ {
if(this->device!=NULL)
return this->device->set_sensor_threshold(channel_id, threshold);
} }
std::vector<bool> IrFeetSensorDriver::get_all_sensor_status(void) std::vector<bool> IrFootSensorDriver::get_all_sensor_status(void)
{ {
if(this->device!=NULL)
return this->device->get_all_sensor_status();
else
return std::vector<bool>();
} }
IrFeetSensorDriver::~IrFeetSensorDriver(void) IrFootSensorDriver::~IrFootSensorDriver(void)
{ {
if(this->device!=NULL) if(this->device!=NULL)
delete this->device; delete this->device;
......
#include "ir_feet_sensor_driver_node.h" #include "ir_foot_sensor_driver_node.h"
IrFeetSensorDriverNode::IrFeetSensorDriverNode(ros::NodeHandle &nh) : IrFootSensorDriverNode::IrFootSensorDriverNode(ros::NodeHandle &nh) :
iri_base_driver::IriBaseNodeDriver<IrFeetSensorDriver>(nh) iri_base_driver::IriBaseNodeDriver<IrFootSensorDriver>(nh)
{ {
//init class attributes if necessary //init class attributes if necessary
//this->loop_rate_ = 2;//in [Hz] //this->loop_rate_ = 2;//in [Hz]
// [init publishers] // [init publishers]
this->sensor_data_publisher_ = this->public_node_handle_.advertise<humanoid_common_msgs::ir_foot_data>("sensor_data", 1);
// [init subscribers] // [init subscribers]
...@@ -19,7 +20,7 @@ IrFeetSensorDriverNode::IrFeetSensorDriverNode(ros::NodeHandle &nh) : ...@@ -19,7 +20,7 @@ IrFeetSensorDriverNode::IrFeetSensorDriverNode(ros::NodeHandle &nh) :
// [init action clients] // [init action clients]
} }
void IrFeetSensorDriverNode::mainNodeThread(void) void IrFootSensorDriverNode::mainNodeThread(void)
{ {
//lock access to driver if necessary //lock access to driver if necessary
this->driver_.lock(); this->driver_.lock();
...@@ -27,12 +28,18 @@ void IrFeetSensorDriverNode::mainNodeThread(void) ...@@ -27,12 +28,18 @@ void IrFeetSensorDriverNode::mainNodeThread(void)
// [fill msg Header if necessary] // [fill msg Header if necessary]
// [fill msg structures] // [fill msg structures]
// Initialize the topic message structure
//this->sensor_data_ir_foot_data_msg_.data = my_var;
// [fill srv structure and make request to the server] // [fill srv structure and make request to the server]
// [fill action structure and make request to the action server] // [fill action structure and make request to the action server]
// [publish messages] // [publish messages]
// Uncomment the following line to publish the topic message
//this->sensor_data_publisher_.publish(this->sensor_data_ir_foot_data_msg_);
//unlock access to driver if previously blocked //unlock access to driver if previously blocked
this->driver_.unlock(); this->driver_.unlock();
...@@ -46,31 +53,31 @@ void IrFeetSensorDriverNode::mainNodeThread(void) ...@@ -46,31 +53,31 @@ void IrFeetSensorDriverNode::mainNodeThread(void)
/* [action requests] */ /* [action requests] */
void IrFeetSensorDriverNode::postNodeOpenHook(void) void IrFootSensorDriverNode::postNodeOpenHook(void)
{ {
} }
void IrFeetSensorDriverNode::addNodeDiagnostics(void) void IrFootSensorDriverNode::addNodeDiagnostics(void)
{ {
} }
void IrFeetSensorDriverNode::addNodeOpenedTests(void) void IrFootSensorDriverNode::addNodeOpenedTests(void)
{ {
} }
void IrFeetSensorDriverNode::addNodeStoppedTests(void) void IrFootSensorDriverNode::addNodeStoppedTests(void)
{ {
} }
void IrFeetSensorDriverNode::addNodeRunningTests(void) void IrFootSensorDriverNode::addNodeRunningTests(void)
{ {
} }
void IrFeetSensorDriverNode::reconfigureNodeHook(int level) void IrFootSensorDriverNode::reconfigureNodeHook(int level)
{ {
} }
IrFeetSensorDriverNode::~IrFeetSensorDriverNode(void) IrFootSensorDriverNode::~IrFootSensorDriverNode(void)
{ {
// [free dynamic memory] // [free dynamic memory]
} }
...@@ -78,5 +85,5 @@ IrFeetSensorDriverNode::~IrFeetSensorDriverNode(void) ...@@ -78,5 +85,5 @@ IrFeetSensorDriverNode::~IrFeetSensorDriverNode(void)
/* main function */ /* main function */
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
return driver_base::main<IrFeetSensorDriverNode>(argc, argv, "ir_feet_sensor_driver_node"); return driver_base::main<IrFootSensorDriverNode>(argc, argv, "ir_foot_sensor_driver_node");
} }
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