fake_image_processing_alg_node.cpp
Go to the documentation of this file.
00001 #include "fake_image_processing_alg_node.h"
00002 
00003 FakeImageProcessingAlgNode::FakeImageProcessingAlgNode(void) :
00004   algorithm_base::IriBaseAlgorithm<FakeImageProcessingAlgorithm>(), it_(this->public_node_handle_)
00005 {
00006   //init class attributes if necessary
00007         this->loop_rate_ = 5;//in [Hz]
00008 
00009   // [init publishers]
00010         image_pub_ = it_.advertise("image_out", 1);
00011           
00012   // [init subscribers]
00013         image_sub_ = it_.subscribe("image_in", 1, &FakeImageProcessingAlgNode::image_callback, this);
00014   
00015   // [init services]
00016   
00017   // [init clients]
00018   
00019   // [init action servers]
00020   
00021   // [init action clients]
00022 }
00023 
00024 FakeImageProcessingAlgNode::~FakeImageProcessingAlgNode(void)
00025 {
00026   // [free dynamic memory]
00027 }
00028 
00029 void FakeImageProcessingAlgNode::mainNodeThread(void)
00030 {
00031         //locks mutex
00032         this->alg_.lock();
00033         
00034         //call external library processing
00035         if (cv_ptr!=NULL)
00036         {
00037                 myLib.setInputImage(cv_ptr->image);
00038                 myLib.fakeProcessing();
00039                 myLib.getOutputImage(cv_ptr->image);
00040         }
00041         
00042         //publish image
00043         if (cv_ptr!=NULL)
00044                 image_pub_.publish(cv_ptr->toImageMsg());
00045 
00046         //unlocks mutex
00047         this->alg_.unlock();
00048         
00049   // [fill msg structures]
00050   
00051   // [fill srv structure and make request to the server]
00052   
00053   // [fill action structure and make request to the action server]
00054 
00055   // [publish messages]
00056 }
00057 
00058 /*  [subscriber callbacks] */
00059 void FakeImageProcessingAlgNode::image_callback(const sensor_msgs::ImageConstPtr& msg)
00060 {
00061         this->alg_.lock();
00062         try
00063         {
00064                 cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
00065         }
00066         catch (cv_bridge::Exception& e)
00067         {
00068                 ROS_ERROR("cv_bridge exception: %s", e.what());
00069                 return;
00070         }
00071         this->alg_.unlock();
00072 }
00073 
00074 /*  [service callbacks] */
00075 
00076 /*  [action callbacks] */
00077 
00078 /*  [action requests] */
00079 
00080 void FakeImageProcessingAlgNode::node_config_update(Config &config, uint32_t level)
00081 {
00082   this->alg_.lock();
00083 
00084   this->alg_.unlock();
00085 }
00086 
00087 void FakeImageProcessingAlgNode::addNodeDiagnostics(void)
00088 {
00089 }
00090 
00091 /* main function */
00092 int main(int argc,char *argv[])
00093 {
00094   return algorithm_base::main<FakeImageProcessingAlgNode>(argc, argv, "fake_image_processing_alg_node");
00095 }


iri_fake_image_processing
Author(s): Andreu Corominas Murtra, andreu@beta-robots.com
autogenerated on Fri Dec 6 2013 20:06:06