Teleoperating Erle-Rover

Simulate, build and deploy your algorithms with Erle-Rover

Source code

Using MAVROS we are going to be able to override a 8 channel RC. Filling the 8 values of the array channels msg_override.channels.

The class ErleRoverManager manages the keyboard input. Forward and backwards arrows control the linear velocity increasing or decreasing the speed. Right and left arros control the angular velocity. The spacebar reset linear and angular velocities.

In this code it shows how to override sterring and throttle channels. The other 6 channels are not going to be override, this mean that this channels will get the value from the RC.

#include <string>
#include <csignal>
#include <termios.h> // for keyboard input
#include <boost/thread.hpp>

#include <ros/ros.h>

#include <mavros_msgs/OverrideRCIn.h>

...

int main(int argc, char** argv)
{
    signal(SIGINT, signalHandler);

    ros::init(argc, argv, "mavros_rc_override");
    ros::NodeHandle n;

    ErleRoverManager erlerover_manager;
    erlerover_manager.init();

    int rate = 10;
    ros::Rate r(rate);

    ros::Publisher rc_override_pub = n.advertise<mavros_msgs::OverrideRCIn>("/mavros/rc/override", 1);
    mavros_msgs::OverrideRCIn msg_override;

    while (n.ok()){

        msg_override.channels[0] = erlerover_manager.getAngularVelocity();
        msg_override.channels[1] = 0;
        msg_override.channels[2] = erlerover_manager.getLinearVelocity();
        msg_override.channels[3] = 0;
        msg_override.channels[4] = 0;
        msg_override.channels[5] = 0;
        msg_override.channels[6] = 0;
        msg_override.channels[7] = 0;

        rc_override_pub.publish(msg_override);
        ros::spinOnce();
        r.sleep();
    }
  return 0;
}

Download the github repository and compile the code following these instructions:

mkdir -p ~/erle_ws/src
cd ~/erle_ws/src
git clone https://github.com/erlerobot/gazebo_cpp_examples
cd ..
catkin_make --pkg ros_erle_cpp_teleoperation_erle_rover

Now we are able to execute the teleoperation node:

rosrun ros_erle_cpp_teleoperation_erle_rover teleoperation
ErleRoverManager : using linear  vel step [10].
ErleRoverManager : using linear  vel max  [1560, 1440].
ErleRoverManager : using angular vel step [50].
ErleRoverManager : using angular vel max  [1900, 1100].
Reading from keyboard
---------------------------
Forward/back arrows : linear velocity incr/decr.
Right/left arrows : angular velocity incr/decr.
Spacebar : reset linear/angular velocities.
q : quit.

We can check if the messages from teleoperation node are been published, just typing rostopic echo:

rostopic echo /mavros/rc/in
---
header:
  seq: 54213
  stamp:
    secs: 1472205752
    nsecs: 413261178
  frame_id: ''
rssi: 0
channels: [1400, 0, 1534, 0, 0, 0, 0, 0]
---