bhand_driver_node.cpp
Go to the documentation of this file.
00001 #include "bhand_driver_node.h"
00002 
00003 BhandDriverNode::BhandDriverNode(ros::NodeHandle &nh) : iri_base_driver::IriBaseNodeDriver<BhandDriver>(nh)
00004 {
00005   //init class attributes if necessary
00006   //this->loop_rate_ = 2;//in [Hz]
00007 
00008   // [init publishers]
00009   
00010   // [init subscribers]
00011   
00012   // [init services]
00013   this->bhand_cmd_server_ = this->public_node_handle_.advertiseService("bhand_cmd", &BhandDriverNode::bhand_cmdCallback, this);
00014   
00015   // [init clients]
00016   
00017   // [init action servers]
00018   
00019   // [init action clients]
00020 }
00021 
00022 void BhandDriverNode::mainNodeThread(void)
00023 {
00024   //lock access to driver if necessary
00025   this->driver_.lock();
00026 
00027   // [fill msg Header if necessary]
00028   //<publisher_name>.header.stamp = ros::Time::now();
00029   //<publisher_name>.header.frame_id = "<publisher_topic_name>";
00030 
00031   // [fill msg structures]
00032   
00033   // [fill srv structure and make request to the server]
00034   
00035   // [fill action structure and make request to the action server]
00036 
00037   // [publish messages]
00038 
00039   //unlock access to driver if previously blocked
00040   this->driver_.unlock();
00041 }
00042 
00043 /*  [subscriber callbacks] */
00044 
00045 /*  [service callbacks] */
00046 bool BhandDriverNode::bhand_cmdCallback(iri_wam_common_msgs::bhand_cmd::Request &req, iri_wam_common_msgs::bhand_cmd::Response &res) 
00047 { 
00048   bool result;
00049   //lock access to driver if necessary 
00050   this->driver_.lock(); 
00051 
00052   if(this->driver_.isRunning()) 
00053   { 
00054     //do operations with req and output on res 
00055     //res.data2 = req.data1 + my_var; 
00056         this->driver_.rawCommand(req.bhandcmd);
00057         result = true;
00058   } 
00059   else 
00060   { 
00061     std::cout << "ERROR: Driver is not on run mode yet." << std::endl; 
00062   } 
00063 
00064   //unlock driver if previously blocked 
00065   this->driver_.unlock(); 
00066   
00067   return result; 
00068 }
00069 
00070 /*  [action callbacks] */
00071 
00072 /*  [action requests] */
00073 
00074 void BhandDriverNode::postNodeOpenHook(void)
00075 {
00076 }
00077 
00078 void BhandDriverNode::addNodeDiagnostics(void)
00079 {
00080 }
00081 
00082 void BhandDriverNode::addNodeOpenedTests(void)
00083 {
00084 }
00085 
00086 void BhandDriverNode::addNodeStoppedTests(void)
00087 {
00088 }
00089 
00090 void BhandDriverNode::addNodeRunningTests(void)
00091 {
00092 }
00093 
00094 void BhandDriverNode::reconfigureNodeHook(int level)
00095 {
00096 }
00097 
00098 BhandDriverNode::~BhandDriverNode()
00099 {
00100   // [free dynamic memory]
00101 }
00102 
00103 /* main function */
00104 int main(int argc,char *argv[])
00105 {
00106   return driver_base::main<BhandDriverNode>(argc,argv,"bhand_driver_node");
00107 }


iri_bhand
Author(s):
autogenerated on Fri Dec 6 2013 20:50:22