Go to the documentation of this file.00001 #include "segway_rmp400_driver_node.h"
00002
00003 SegwayRmp400DriverNode::SegwayRmp400DriverNode(ros::NodeHandle &nh) :
00004 iri_base_driver::IriBaseNodeDriver<SegwayRmp400Driver>(nh),
00005 tf_broadcaster_()
00006 {
00007 std::string vel_topic_name;
00008 std::string status_topic_name;
00009
00010
00011 private_node_handle_.param<std::string>("status_topic", status_topic_name, "status");
00012 status_publisher_ = public_node_handle_.advertise<iri_segway_rmp_msgs::SegwayRMP400Status>
00013 (status_topic_name, 100);
00014 ROS_DEBUG("Publishing status topic at: %s'", status_topic_name.c_str());
00015
00016
00017 private_node_handle_.param<std::string>("cmd_vel", vel_topic_name, "cmd_vel");
00018 cmd_vel_subscriber_ = public_node_handle_.subscribe(vel_topic_name, 100,
00019 & SegwayRmp400DriverNode::cmd_vel_callback, this);
00020 ROS_DEBUG("Subscribing to cmd_vel_callback topic at: '%s'", vel_topic_name.c_str());
00021 }
00022
00023 void
00024 SegwayRmp400DriverNode::mainNodeThread(void)
00025 {
00026 update_status();
00027 status_publisher_.publish(segway_status_msg_);
00028 }
00029
00030 void
00031 SegwayRmp400DriverNode::update_status(void)
00032 {
00033 segway_status_msg_ = driver_.get_status();
00034 }
00035
00036 void
00037 SegwayRmp400DriverNode::cmd_vel_callback(const geometry_msgs::Twist::ConstPtr & msg)
00038 {
00039 if (! driver_.isRunning()) {
00040 ROS_ERROR("Impossible to move, driver is not running");
00041 return;
00042 }
00043
00044 try
00045 {
00046 driver_.move(msg);
00047 }
00048 catch (CException & e)
00049 {
00050 driver_.closeDriver();
00051 ROS_FATAL("Error while moving via cmd_vel_callback: '%s'", e.what().c_str());
00052 }
00053 }
00054
00055 void
00056 SegwayRmp400DriverNode::postNodeOpenHook(void)
00057 {
00058 }
00059
00060 void
00061 SegwayRmp400DriverNode::addNodeDiagnostics(void)
00062 {
00063 }
00064
00065 void
00066 SegwayRmp400DriverNode::addNodeOpenedTests(void)
00067 {
00068 }
00069
00070 void
00071 SegwayRmp400DriverNode::addNodeStoppedTests(void)
00072 {
00073 }
00074
00075 void
00076 SegwayRmp400DriverNode::addNodeRunningTests(void)
00077 {
00078 }
00079
00080 void
00081 SegwayRmp400DriverNode::reconfigureNodeHook(int level)
00082 {
00083 }
00084
00085 SegwayRmp400DriverNode::~SegwayRmp400DriverNode()
00086 {
00087
00088 }
00089
00090
00091 int main(int argc,char *argv[])
00092 {
00093 return driver_base::main<SegwayRmp400DriverNode>(argc,argv,"segway_rmp400_driver_node");
00094 }