Writing a teleop node using webots_ros
In this section, we will implement a ROS node to directly control the wheels' velocity of the e-puck
robot starting from a geometry_msgs::Twist
message. To do this, we need to exploit webots_ros
as a dependency. Let's create a webots_demo_pkg
package, specifying webots_ros
as a dependency, as follows:
catkin_create_pkg webots_demo_pkg roscpp webots_ros geometry_msgs
The complete source code can be found in the book source code, and it is explained next. Let's start by defining some useful header files implementing the messages needed to use the Webots services, as follows:
#include "ros/ros.h" #include <webots_ros/Int32Stamped.h> #include <webots_ros/set_float.h> #include <webots_ros/set_int.h> #include <webots_ros/robot_get_device_list.h> #include <std_msgs/String.h> #include <geometry_msgs/Twist.h>
Then, declare some variable to save the data received by the ROS callbacks...