hokuyo_laser3d_driver.cpp
Go to the documentation of this file.
00001 #include "hokuyo_laser3d_driver.h"
00002 #include <sstream>
00003 #include <stdlib.h>
00004 
00005 HokuyoLaser3dDriver::HokuyoLaser3dDriver()
00006 {
00007   //setDriverId(driver string id);
00008   std::string h3d_id(ros::this_node::getName());
00009   replace(h3d_id.begin(), h3d_id.end(), '/', '_');
00010   ROS_INFO("Laser ID: %s", h3d_id.c_str());
00011   this->id = h3d_id;
00012 
00013   try
00014   {
00015     this->h3d = new CH3D();
00016     setDriverId(h3d_id);
00017   }
00018   catch (CException & e)
00019   {
00020     ROS_FATAL("'%s'",e.what().c_str());
00021   }
00022 }
00023 
00024 bool HokuyoLaser3dDriver::openDriver(void)
00025 {
00026   //setDriverId(driver string id);
00027   try{
00028     this->h3d->setLaserPort(this->config_.laser_port);
00029     this->h3d->setVerbose(true);
00030     this->h3d->init();
00031   }catch (CException & e)
00032   {
00033     ROS_FATAL("'%s'",e.what().c_str());
00034   }
00035   return true;
00036 }
00037 
00038 bool HokuyoLaser3dDriver::closeDriver(void)
00039 {
00040   try{
00041     this->h3d->close();
00042   }catch (CException & e)
00043   {
00044     ROS_FATAL("'%s'",e.what().c_str());
00045   }
00046   return true;
00047 }
00048 
00049 bool HokuyoLaser3dDriver::startDriver(void)
00050 {
00051   try{
00052     this->h3d->setLaserMode(this->config_.laser_mode);
00053     this->h3d->setResolution(this->config_.resolution);
00054     if(this->config_.continuous)
00055       this->h3d->startAcquisition();
00056   }catch (CException & e)
00057   {
00058     ROS_FATAL("'%s'",e.what().c_str());
00059   }
00060   return true;
00061 }
00062 
00063 bool HokuyoLaser3dDriver::stopDriver(void)
00064 {
00065   try{
00066     if(this->config_.continuous)
00067       this->h3d->stopAcquisition();
00068   }catch (CException & e)
00069   {
00070     ROS_FATAL("'%s'",e.what().c_str());
00071   }
00072   return true;
00073 }
00074 
00075 void HokuyoLaser3dDriver::config_update(const Config& new_cfg, uint32_t level)
00076 {
00077   this->lock();
00078 
00079   //update driver with new_cfg data
00080 
00081   // save the current configuration
00082   this->config_=new_cfg;
00083 
00084   this->unlock();
00085 }
00086 
00087 HokuyoLaser3dDriver::~HokuyoLaser3dDriver()
00088 {
00089   delete this->h3d;
00090 }
00091 
00092 // -----------------------------------------------------------------------------
00093 
00094 
00095 std::list<std::string> HokuyoLaser3dDriver::getENDList()
00096 {
00097   return this->h3d->END_list;
00098 }
00099 
00100 void HokuyoLaser3dDriver::getSlice(PointCloudTimeStamped &slc)
00101 {
00102   return this->h3d->getSlice(slc);
00103 }
00104 
00105 void HokuyoLaser3dDriver::getCloud(PointCloudTimeStamped &cld)
00106 {
00107   return this->h3d->getCloud(cld);
00108 }
00109 
00110 
00111 


iri_hokuyo_laser3d
Author(s): Marti Morta, mmorta at iri.upc.edu
autogenerated on Fri Dec 6 2013 21:51:18