|
| 1 | +# Overview |
| 2 | + |
| 3 | +**IMPORTANT: This tutorial only works with ROS Groovy.** |
| 4 | + |
| 5 | +This tutorial will explain how to drive simulated Atlas around as if it were a wheeled robot (i.e., without walking or balancing). |
| 6 | + |
| 7 | +## Setup |
| 8 | + |
| 9 | +We assume that you've already done the [installation step](http://gazebosim.org/tutorials/?tut=drcsim_install). |
| 10 | + |
| 11 | +If you haven't done so, add the environment setup.sh files to your .bashrc. |
| 12 | + |
| 13 | +~~~ |
| 14 | +echo 'source /usr/share/drcsim/setup.sh' >> ~/.bashrc |
| 15 | +source ~/.bashrc |
| 16 | +~~~ |
| 17 | + |
| 18 | +We're going to use the [pr2_teleop](http://ros.org/wiki/pr2_teleop) package to drive Atlas around with keyboard commands. Install the Ubuntu package that contains it: |
| 19 | + |
| 20 | +~~~ |
| 21 | +sudo apt-get install ros-groovy-pr2-teleop-app |
| 22 | +~~~ |
| 23 | + |
| 24 | +## Background |
| 25 | + |
| 26 | +Note that this tutorial does not use the [walking controller](http://gazebosim.org/tutorials/?tut=drcsim_walking&cat=drcsim). It simply spawns Atlas with position controllers enabled that keep it standing upright, as shown in the following image: |
| 27 | + |
| 28 | +[[file:files/Gazebo_with_drc_robot.png|640px]] |
| 29 | + |
| 30 | +Note that all of the robot's joints, including the legs, are physically simulated and actively controlled. |
| 31 | + |
| 32 | +So the simulated robot in this tutorial can't walk, but we still want to move it around in the world. Fortunately, the simulated robot accepts velocity commands via ROS to translate and rotate in the plane, as if it were a wheeled robot. |
| 33 | + |
| 34 | +## The code |
| 35 | + |
| 36 | +1. Start the simulator: |
| 37 | + |
| 38 | + ~~~ |
| 39 | + VRC_CHEATS_ENABLED=1 roslaunch drcsim_gazebo atlas.launch |
| 40 | + ~~~ |
| 41 | + |
| 42 | + >**For drcsim < 3.1.0**: The package and launch file had a different name: |
| 43 | + |
| 44 | + >~~~ |
| 45 | + VRC_CHEATS_ENABLED=1 roslaunch atlas_utils atlas.launch |
| 46 | + >~~~ |
| 47 | + |
| 48 | + Note: Setting the variable `VRC_CHEATS_ENABLED=1` exposes several development aid topics including `/atlas/cmd_vel`, which are by default disabled for the VRC competition. |
| 49 | +
|
| 50 | +2. In another shell, start `pr2_teleop/pr2_teleop_keyboard`: |
| 51 | +
|
| 52 | + ~~~ |
| 53 | + rosrun pr2_teleop teleop_pr2_keyboard cmd_vel:=atlas/cmd_vel |
| 54 | + ~~~ |
| 55 | + |
| 56 | + You should see something like: |
| 57 | + |
| 58 | + Reading from keyboard |
| 59 | + --------------------------- |
| 60 | + Use 'WASD' to translate |
| 61 | + Use 'QE' to yaw |
| 62 | + Press 'Shift' to run |
| 63 | +
|
| 64 | +3. Follow the instructions: get the robot moving with those keys. Press any other key to stop. Control-C to stop the teleop utility. |
| 65 | +
|
| 66 | +## How does that work? |
| 67 | +
|
| 68 | +
|
| 69 | +The simulated robot is awaiting [ROS Twist](http://ros.org/doc/api/geometry_msgs/html/msg/Twist.html) messages, which specify 6-D velocities, on the `atlas/cmd_vel` topic. Check that with [rostopic](http://ros.org/wiki/rostopic): |
| 70 | +
|
| 71 | +~~~ |
| 72 | +rostopic info atlas/cmd_vel |
| 73 | +~~~ |
| 74 | +
|
| 75 | +You should see something like: |
| 76 | +
|
| 77 | +~~~ |
| 78 | +Type: geometry_msgs/Twist |
| 79 | + |
| 80 | +Publishers: |
| 81 | + * /pr2_base_keyboard (http://osrf-Latitude-E6420:36506/) |
| 82 | + |
| 83 | +Subscribers: |
| 84 | + * /gazebo (http://osrf-Latitude-E6420:35339/) |
| 85 | +~~~ |
| 86 | +
|
| 87 | +The teleop utility is simply converting your keyboard input to messages of that type and publishing them to that topic. You can publish such messages from anywhere, including from the command line, using rostopic. First, let's see what's in a Twist message, using [rosmsg](http://ros.org/wiki/rosmsg): |
| 88 | +
|
| 89 | +~~~ |
| 90 | +rosmsg show Twist |
| 91 | +~~~ |
| 92 | +
|
| 93 | +You should see: |
| 94 | +
|
| 95 | +~~~ |
| 96 | +[geometry_msgs/Twist]: |
| 97 | +geometry_msgs/Vector3 linear |
| 98 | + float64 x |
| 99 | + float64 y |
| 100 | + float64 z |
| 101 | +geometry_msgs/Vector3 angular |
| 102 | + float64 x |
| 103 | + float64 y |
| 104 | + float64 z |
| 105 | +~~~ |
| 106 | +
|
| 107 | +It's a 6-D velocity: 3 linear velocities (X, Y, and Z) and 3 angular velocities (rotations about X, Y, Z, also called roll, pitch, and yaw). Our robot is constrained to move in the plane, so we only care about X, Y, and yaw (rotation about Z). Make the robot drive counter-clockwise in a circle: |
| 108 | +
|
| 109 | +~~~ |
| 110 | +rostopic pub --once atlas/cmd_vel geometry_msgs/Twist '{ linear: { x: 0.5, y: 0.0, z: 0.0 }, angular: { x: 0.0, y: 0.0, z: 0.5 } }' |
| 111 | +~~~ |
| 112 | +
|
| 113 | +Note that the robot keeps moving after rostopic exits; that's because there's no watchdog that requires recent receipt of a velocity command (that may change in the future). You can verify that no commands are being sent with this with the command: |
| 114 | +
|
| 115 | +~~~ |
| 116 | +rostopic echo atlas/cmd_vel |
| 117 | +~~~ |
| 118 | +
|
| 119 | +To stop the robot, send zero velocities: |
| 120 | +
|
| 121 | +~~~ |
| 122 | +rostopic pub --once atlas/cmd_vel geometry_msgs/Twist '{ linear: { x: 0.0, y: 0.0, z: 0.0 }, angular: { x: 0.0, y: 0.0, z: 0.0 } }' |
| 123 | +~~~ |
| 124 | +
|
| 125 | +From here, you're ready to write code that moves the robot around the world. |
0 commit comments