You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.5 KiB

2 years ago
  1. ## Teleoperating Stretch
  2. ### Xbox Controller Teleoperating
  3. <p align="center">
  4. <img src="https://raw.githubusercontent.com/hello-robot/stretch_tutorials/main/images/xbox_controller_commands.png"/>
  5. </p>
  6. Stretch comes ready to run out of the box. The Xbox Teleoperation demo will let you quickly test out the robot capabilities by teleoperating it with an Xbox Controller.
  7. Note: Make sure the USB Dongle is plugged into the the USB port of the base trunk.
  8. To start the demo:
  9. * Remove the 'trunk' cover and power on the robot
  10. Wait for about 45 seconds. You will hear the Ubuntu startup sound, followed by two beeps (indicating the demo is running).
  11. * Hit the Connect button on the controller. The upper two LEDs of the ring will illuminate.
  12. * Hit the Home Robot button. Stretch will go through its homing calibration routine.
  13. * **Note**: make sure the space around the robot is clear before running the Home function
  14. You're ready to go! A few things to try:
  15. * Hit the Stow Robot button. The robot will assume the stow pose.
  16. * Practice driving the robot around.
  17. * Pull the Fast Base trigger while driving. When stowed, it will make Stretch drive faster
  18. * Manually stop the arm or lift from moving to make it stop upon contact.
  19. * Try picking up your cellphone from the floor
  20. * Try grasping cup from a counter top
  21. * Try delivering an object to a person
  22. If you're done, hold down the Shutdown PC button for 2 seconds. This will cause the PC to turn off. You can then power down the robot.
  23. ### Keyboard Teleoperating: Mobile Base
  24. Begin by running the following command in your terminal:
  25. ```bash
  26. # Terminal 1
  27. roslaunch stretch_core stretch_driver.launch
  28. ```
  29. To teleoperate a Stretch's mobile base with the keyboard, you first need to switch the mode to *nagivation* for the robot to receive *Twist* messages. This is done using a rosservice call in a new terminal. In the same terminal run the teleop_twist_keyboard node with the argument remapping the *cmd_vel* topic name to *stretch/cmd_vel*.
  30. ```bash
  31. # Terminal 2
  32. rosservice call /switch_to_navigation_mode
  33. rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=stretch/cmd_vel
  34. ```
  35. Below are the keyboard commands that allow a user to move Stretch's base.
  36. ```
  37. Reading from the keyboard and Publishing to Twist!
  38. ---------------------------
  39. Moving around:
  40. u i o
  41. j k l
  42. m , .
  43. For Holonomic mode (strafing), hold down the shift key:
  44. ---------------------------
  45. U I O
  46. J K L
  47. M < >
  48. t : up (+z)
  49. b : down (-z)
  50. anything else : stop
  51. q/z : increase/decrease max speeds by 10%
  52. w/x : increase/decrease only linear speed by 10%
  53. e/c : increase/decrease only angular speed by 10%
  54. CTRL-C to quit
  55. currently: speed 0.5 turn 1.0
  56. ```
  57. To stop the node from sending twist messages, type **Ctrl** + **c**.
  58. ### Create a node for Mobile Base Teleoperating
  59. To move Stretch's mobile base using a python script, please look at [example 1](example_1.md) for reference.
  60. ### Keyboard Teleoperating: Full Body
  61. For full body teleoperation with the keyboard, you first need to run the `stretch_driver.launch` in a terminal.
  62. ```bash
  63. # Terminal 1
  64. roslaunch stretch_core stretch_driver.launch
  65. ```
  66. Then in a new terminal, type the following command
  67. ```bash
  68. # Terminal 2
  69. rosrun stretch_core keyboard_teleop
  70. ```
  71. Below are the keyboard commands that allow a user to control all of Stretch's joints.
  72. ```
  73. ---------- KEYBOARD TELEOP MENU -----------
  74. i HEAD UP
  75. j HEAD LEFT l HEAD RIGHT
  76. , HEAD DOWN
  77. 7 BASE ROTATE LEFT 9 BASE ROTATE RIGHT
  78. home page-up
  79. 8 LIFT UP
  80. up-arrow
  81. 4 BASE FORWARD 6 BASE BACK
  82. left-arrow right-arrow
  83. 2 LIFT DOWN
  84. down-arrow
  85. w ARM OUT
  86. a WRIST FORWARD d WRIST BACK
  87. x ARM IN
  88. 5 GRIPPER CLOSE
  89. 0 GRIPPER OPEN
  90. step size: b BIG, m MEDIUM, s SMALL
  91. q QUIT
  92. -------------------------------------------
  93. ```
  94. To stop the node from sending twist messages, type **Ctrl** + **c**.
  95. ## Teleoperating in Gazebo
  96. ### Keyboard Teleoperating: Mobile Base
  97. For keyboard teleoperation of the Stretch's mobile base, first [startup Stretch in simulation](gazebo_basics.md). Then run the following command in a new terminal.
  98. ```bash
  99. # Terminal 1
  100. roslaunch stretch_gazebo gazebo.launch
  101. ```
  102. In a new terminal, type the following
  103. ```bash
  104. # Terminal 2
  105. roslaunch stretch_core teleop_twist.launch twist_topic:=/stretch_diff_drive_controller/cmd_vel linear:=1.0 angular:=2.0 teleop_type:=keyboard # or use teleop_type:=joystick if you have a controller
  106. ```
  107. The same keyboard commands will be presented to a user to move the robot.
  108. ### Xbox Controller Teleoperating
  109. An alternative for robot base teleoperation is to use an Xbox controller. Stop the keyboard teleoperation node by typing **Ctrl** + **c** in the terminal where the command was executed. Then connect the Xbox controller device to your local machine and run the following command.
  110. ```bash
  111. # Terminal 2
  112. roslaunch stretch_core teleop_twist.launch twist_topic:=/stretch_diff_drive_controller/cmd_vel linear:=1.0 angular:=2.0 teleop_type:=joystick
  113. ```
  114. Note that the teleop_twist_joy package has a deadman switch by default which disables the drive commands to be published unless pressed. For a Logitech F310 joystick, this button is A.