backend_nodelet.hpp
Go to the documentation of this file.
1 #ifndef RADIAL_MENU_BACKEND_BACKEND_NODELET_HPP
2 #define RADIAL_MENU_BACKEND_BACKEND_NODELET_HPP
3 
4 #include <nodelet/nodelet.h>
8 #include <radial_menu_msgs/State.h>
9 #include <ros/exception.h>
10 #include <ros/node_handle.h>
11 #include <ros/publisher.h>
12 #include <ros/subscriber.h>
13 #include <sensor_msgs/Joy.h>
14 
15 namespace radial_menu_backend {
16 
18 public:
20 
21  virtual ~BackendNodelet() {}
22 
23 protected:
24  virtual void onInit() {
26 
27  model_.reset(new radial_menu_model::Model());
28  if (!model_->setDescriptionFromParam(nh.resolveName("menu_description"))) {
29  throw ros::Exception("Cannot set a model description from the param '" +
30  nh.resolveName("menu_description") + "'");
31  }
32  NODELET_INFO_STREAM("Menu:\n" << model_->toString());
33 
34  controller_.reset(
36 
37  state_pub_ = nh.advertise< radial_menu_msgs::State >("menu_state", 1, true);
38  state_pub_.publish(model_->exportState());
39  joy_sub_ = nh.subscribe("joy", 1, &BackendNodelet::onJoyRecieved, this);
40  }
41 
42  void onJoyRecieved(const sensor_msgs::JoyConstPtr &joy) {
43  // update menu state and publish
44  state_pub_.publish(controller_->update(*joy));
45  // NODELET_DEBUG_STREAM("Updated menu:\n" << menu_->toString());
46  }
47 
48 protected:
51 
54 };
55 } // namespace radial_menu_backend
56 
57 #endif
void onJoyRecieved(const sensor_msgs::JoyConstPtr &joy)
#define NODELET_INFO_STREAM(...)
ros::NodeHandle & getNodeHandle() const
ros::NodeHandle & getPrivateNodeHandle() const
static BackendConfig fromParamNs(const std::string &ns)
void publish(const boost::shared_ptr< M > &message) const
std::shared_ptr< Model > ModelPtr
const std::string & getNamespace() const
radial_menu_model::ModelPtr model_
std::shared_ptr< BackendController > BackendControllerPtr


radial_menu_backend
Author(s):
autogenerated on Mon Feb 28 2022 23:22:01