Adding the ROS teleop node

The ROS teleop node publishes the ROS Twist command by taking keyboard inputs. From this node, we can generate both linear and angular velocity and there is already
a standard teleop node implementation available; we can simply reuse the node.

The teleop implemented in chapter_3_code/diff_wheeled_robot_control package. The script folder contains the diff_wheeled_robot_key node, which
is the teleop node.

Here is the launch file called keyboard_teleop.launch to start the teleop node:

 <launch> 
  <!-- differential_teleop_key already has its own built in velocity smoother --> 
  <node pkg="diff_wheeled_robot_control" type="diff_wheeled_robot_key" name="diff_wheeled_robot_key"  output="screen"> 
 
    <param name="scale_linear" value="0.5" type="double"/> 
    <param name="scale_angular" value="1.5" type="double"/> 
    <remap from="turtlebot_teleop_keyboard/cmd_vel" to="/cmd_vel"/>  
  </node> 
</launch> 

Let's start moving the robot.

Launch the Gazebo with complete simulation settings using the following command:

    $ roslaunch diff_wheeled_robot_gazebo diff_wheeled_gazebo_full.launch

Start the teleop node:

    $ roslaunch diff_wheeled_robot_control keyboard_teleop.launch

Start RViz to visualize the robot state and laser data:

    $ rosrun rviz rviz

Add Fixed Frame : /odom, add Laser Scan and the topic as /scan to view the laser scan data and add the Robot model to view the robot model.

In the teleop terminal, we can use some keys (U, I, O, J, K, L, M, "," , ".") for direction adjustment and other keys (Q, Z, W, X, E, C, K, space key) for speed adjustments. Here is the screenshot showing the robot moving in Gazebo using teleop and its visualization in RViz.

We can add primitive shapes from the Gazebo toolbar to the robot environment or we can add objects from the online library, which is on the left side panel.

Figure 13 : Moving differential drive robot in Gazebo using teleoperation

The robot will only move when we press the appropriate key inside the teleop node terminal. If this terminal is not active, pressing the key will not move the robot. If everything works well, we can explore the area using the robot and visualizing the laser data in RViz.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.74.154