runaway.cpp
Go to the documentation of this file.
00001 /*
00002 Author: Minglong Li
00003 Affiliation: State Key Laboratory of High Performance Computing (HPCL)
00004              College of Computer, National University of Defense Technology
00005 Email: minglong_l@163.com
00006 Created on: July 11th, 2016
00007 */
00008 #include <ros/ros.h>
00009 #include <nodelet/nodelet.h>
00010 #include <iostream>
00011 
00012 #include <micros_mars_task_alloc/Force.h>
00013 #include <micros_mars_task_alloc/Heading.h>
00014 #include <pluginlib/class_list_macros.h>
00015 
00016 namespace micros_mars_task_alloc {
00017 using namespace std;
00018 
00019 class Runaway : public nodelet::Nodelet
00020 {
00021 public:
00022     Runaway(): significant_force_(0.5){}
00023     ~Runaway(){}
00024     virtual void onInit();
00025     void callback(const micros_mars_task_alloc::ForcePtr & msg);
00026 private:
00027     float significant_force_;
00028     ros::NodeHandle nh_;
00029     ros::Publisher pub_;
00030     ros::Subscriber sub_;
00031 };
00032 
00033 void Runaway::onInit()
00034 {
00035     nh_ = getPrivateNodeHandle();
00036     cout << "Initialising nodelet ..." << endl;        
00037     sub_ = nh_.subscribe("/feelforce/force", 10, &Runaway::callback, this);
00038     pub_ = nh_.advertise<micros_mars_task_alloc::Heading>("test/turn/heading", 10);//The topic prefix runaway (nodelet name) will be added automically.
00039 }
00040 
00041 void Runaway::callback(const micros_mars_task_alloc::ForcePtr & msg)
00042 {
00043     micros_mars_task_alloc::HeadingPtr  heading_ptr(new micros_mars_task_alloc::Heading);
00044     heading_ptr -> distance = msg -> magnitude;
00045     heading_ptr -> angle = msg -> direction;
00046     pub_.publish(heading_ptr);
00047     //cout << "hello" << endl;
00048 }
00049 
00050 }//namespace micros_mars_task_alloc
00051 PLUGINLIB_EXPORT_CLASS(micros_mars_task_alloc::Runaway, nodelet::Nodelet)


micros_mars_task_alloc
Author(s): Minglong Li , Xiaodong Yi , Yanzhen Wang , Zhongxuan Cai
autogenerated on Mon Jul 1 2019 19:55:03