Browse Source

Update documentation with stretch_ros2 restruct

pull/16/head
hello-chintan 1 year ago
parent
commit
252bfc21aa
5 changed files with 19 additions and 19 deletions
  1. +3
    -3
      ros2/moveit_basics.md
  2. +4
    -4
      ros2/moveit_movegroup_demo.md
  3. +1
    -1
      ros2/moveit_rviz_demo.md
  4. +7
    -7
      ros2/navigation_simple_commander.md
  5. +4
    -4
      ros2/navigation_stack.md

+ 3
- 3
ros2/moveit_basics.md View File

@ -24,7 +24,7 @@ stretch_robot_home.py
The easiest way to run MoveIt 2 on your robot is through RViz. With RViz you can plan, visualize, and also execute trajectories for various planning groups on your robot. To launch RViz with MoveIt 2, run the following command. (Press Ctrl+C in the terminal to terminate)
```{.bash .shell-prompt}
ros2 launch stretch_moveit_config movegroup_moveit2.launch.py
ros2 launch stretch_moveit2 movegroup_moveit2.launch.py
```
Follow the instructions in this [tutorial](https://docs.hello-robot.com/0.2/stretch-tutorials/ros2/moveit_rviz_demo) to plan and execute trajectories using the interactive markers in RViz.
@ -39,10 +39,10 @@ To plan with obstacles, you can insert objects like a box, cyclinder or sphere,
### Planning with MoveIt 2 Using the MoveGroup C++ API
If you want to integrate MoveIt 2 into your planning pipeline and want greater control over its various functionalities, using the MoveGroup API is the way to go. Execute the launch file again and go through the comments in the [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_moveit_config/src/movegroup_test.cpp) to understand what's going on. (Press Ctrl+C in the terminal to terminate)
If you want to integrate MoveIt 2 into your planning pipeline and want greater control over its various functionalities, using the MoveGroup API is the way to go. Execute the launch file again and go through the comments in the [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_moveit2/src/movegroup_test.cpp) to understand what's going on. (Press Ctrl+C in the terminal to terminate)
```{.bash .shell-prompt}
ros2 launch stretch_moveit_config movegroup_moveit2.launch.py
ros2 launch stretch_moveit2 movegroup_moveit2.launch.py
```
Follow the instructions in this [tutorial](https://docs.hello-robot.com/0.2/stretch-tutorials/ros2/moveit_movegroup_demo) to plan and execute trajectories using the MoveGroup C++ API.

+ 4
- 4
ros2/moveit_movegroup_demo.md View File

@ -2,13 +2,13 @@
If you want to integrate MoveIt 2 into your planning pipeline and want greater control over its various functionalities, using the MoveGroup API is the way to go. For this tutorial, we are going to use the RViz Visual Tools plugin to execute the C++ source code part by part to explore more sophisticated functionalities.
Execute the launch file again to begin the tutorial. You can follow along in the C++ [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_moveit_config/src/movegroup_test.cpp) to inspect finer details. (Press Ctrl+C in the terminal to terminate) (Ensure you have enough room around the robot before running the script)
Execute the launch file again to begin the tutorial. You can follow along in the C++ [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_moveit2/src/movegroup_test.cpp) to inspect finer details. (Press Ctrl+C in the terminal to terminate) (Ensure you have enough room around the robot before running the script)
```{.bash .shell-prompt}
ros2 launch stretch_moveit_config movegroup_moveit2.launch.py
ros2 launch stretch_moveit2 movegroup_moveit2.launch.py
```
To execute the script and interact with the robot, all you need to do is press the Next button in the RViz Visual Tools window at the bottom left. Follow the prompts on the terminal to run through the tutorial. While executing the script, it's also a good idea to study and understand the script that is being executed. Find it [here](https://github.com/hello-robot/stretch_ros2/blob/feature/hybrid_planning/stretch_moveit_config/src/movegroup_test.cpp).
To execute the script and interact with the robot, all you need to do is press the Next button in the RViz Visual Tools window at the bottom left. Follow the prompts on the terminal to run through the tutorial. While executing the script, it's also a good idea to study and understand the script that is being executed. Find it [here](https://github.com/hello-robot/stretch_ros2/blob/feature/hybrid_planning/stretch_moveit2/src/movegroup_test.cpp).
![RVizVisualTools](https://user-images.githubusercontent.com/97639181/181854836-6f9b43cd-edf9-46e8-8ca1-1ac782d5b70b.png)
@ -45,7 +45,7 @@ Press Ctrl+C to end this demo.
8. To wrap it up, the final act! This one is a surprise that's only a click away. Go on and execute the following command:
```bash
ros2 launch stretch_moveit_config moveit_draw.launch.py
ros2 launch stretch_moveit2 moveit_draw.launch.py
```
![draw](https://user-images.githubusercontent.com/97639181/196334258-3c585f45-c976-483c-b2cb-1f540460596f.gif)

+ 1
- 1
ros2/moveit_rviz_demo.md View File

@ -3,7 +3,7 @@
1. The easiest way to run MoveIt 2 on your robot is through the RViz plugin. With RViz you can plan, visualize, and also execute trajectories for various planning groups on your robot. To get started using MoveIt 2 with RViz, execute the following command in a terminal. (Press Ctrl+C in the terminal to terminate)
```{.bash .shell-prompt}
ros2 launch stretch_moveit_config movegroup_moveit2.launch.py
ros2 launch stretch_moveit2 movegroup_moveit2.launch.py
```
2. You should see Stretch visualized in RViz with joint positions exactly as they appear on the actual robot (If not, home the robot and start from step 1!). You can select a Planning Group from the drop down menu that allows you to choose a group of joints to plan for and control using MoveIt. When you select a Planning Group the joints that can be controlled are highlighted with interactive markers. Let’s go ahead and select the stretch_arm planning group.

+ 7
- 7
ros2/navigation_simple_commander.md View File

@ -2,7 +2,7 @@
In this tutorial, we will work with Stretch to explore the Simple Commander Python API to enable autonomous navigation programmatically. We will also demonstrate a security patrol routine for Stretch developed using this API. If you just landed here, it might be a good idea to first review the previous tutorial which covered mapping and navigation using RViz as an interface.
## The Simple Commander Python API
To develop complex behaviors with Stretch where navigation is just one aspect of the autonomy stack, we need to be able to plan and execute navigation routines as part of a bigger program. Luckily, the Nav2 stack exposes a Python API that abstracts the ROS layer and the Behavior Tree framework (more on that later!) from the user through a pre-configured library called the [robot navigator](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_navigation/stretch_navigation/robot_navigator.py). This library defines a class called BasicNavigator which wraps the planner, controller and recovery action servers and exposes methods such as `goToPose()`, `goToPoses()` and `followWaypoints()` to execute navigation behaviors.
To develop complex behaviors with Stretch where navigation is just one aspect of the autonomy stack, we need to be able to plan and execute navigation routines as part of a bigger program. Luckily, the Nav2 stack exposes a Python API that abstracts the ROS layer and the Behavior Tree framework (more on that later!) from the user through a pre-configured library called the [robot navigator](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_nav2/stretch_nav2/robot_navigator.py). This library defines a class called BasicNavigator which wraps the planner, controller and recovery action servers and exposes methods such as `goToPose()`, `goToPoses()` and `followWaypoints()` to execute navigation behaviors.
Let's first see the demo in action and then explore the code to understand how this works!
@ -16,15 +16,15 @@ stretch_robot_stow.py
```
## Setup
Let's set the patrol route up before you can execute this demo in your map. This requires reading the position of the robot at various locations in the map and entering the co-ordinates in the array called `security_route` in the [simple_commander_demo.py](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_navigation/stretch_navigation/simple_commander_demo.py#L30) file.
Let's set the patrol route up before you can execute this demo in your map. This requires reading the position of the robot at various locations in the map and entering the co-ordinates in the array called `security_route` in the [simple_commander_demo.py](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_nav2/stretch_nav2/simple_commander_demo.py#L30) file.
First, execute the following command while passing the correct map YAML. Then, press the 'Startup' button:
```{.bash .shell-prompt}
ros2 launch stretch_navigation navigation.launch.py map:=${HELLO_ROBOT_FLEET}/maps/<map_name>.yaml
ros2 launch stretch_nav2 navigation.launch.py map:=${HELLO_ROBOT_FLEET}/maps/<map_name>.yaml
```
Since we expect the first point in the patrol route to be at the origin of the map, the first coordinates should be (0.0, 0.0). Next, to define the route, the easiest way to define the waypoints in the `security_route` array is by setting the robot at random locations in the map using the '2D Pose Estimate' button in RViz as shown below. For each location, note the x, and y coordinates in the position field of the base_footprint frame and add it to the `security_route` array in [simple_commander_demo.py](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_navigation/stretch_navigation/simple_commander_demo.py#L30).
Since we expect the first point in the patrol route to be at the origin of the map, the first coordinates should be (0.0, 0.0). Next, to define the route, the easiest way to define the waypoints in the `security_route` array is by setting the robot at random locations in the map using the '2D Pose Estimate' button in RViz as shown below. For each location, note the x, and y coordinates in the position field of the base_footprint frame and add it to the `security_route` array in [simple_commander_demo.py](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_nav2/stretch_nav2/simple_commander_demo.py#L30).
<p align="center">
<img height=500 src="https://user-images.githubusercontent.com/97639181/206782270-e84b33c4-e155-468d-8a46-d926b88ba428.gif"/>
@ -42,7 +42,7 @@ Go ahead and execute the following command to run the demo and visualize the res
Terminal 1:
```{.bash .shell-prompt}
ros2 launch stretch_navigation demo_security.launch.py map:=${HELLO_ROBOT_FLEET}/maps/<map_name>.yaml
ros2 launch stretch_nav2 demo_security.launch.py map:=${HELLO_ROBOT_FLEET}/maps/<map_name>.yaml
```
<p align="center">
@ -50,12 +50,12 @@ ros2 launch stretch_navigation demo_security.launch.py map:=${HELLO_ROBOT_FLEET}
</p>
## Code Breakdown
Now, let's jump into the code to see how things work under the hood. Follow along in the [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_navigation/stretch_navigation/simple_commander_demo.py) to have a look at the entire script.
Now, let's jump into the code to see how things work under the hood. Follow along in the [code](https://github.com/hello-robot/stretch_ros2/blob/galactic/stretch_nav2/stretch_nav2/simple_commander_demo.py) to have a look at the entire script.
First, we import the `BasicNavigator` class from the robot_navigator library which comes standard with the Nav2 stack. This class wraps around the planner, controller and recovery action servers.
```python
from stretch_navigation.robot_navigator import BasicNavigator, TaskResult
from stretch_nav2.robot_navigator import BasicNavigator, TaskResult
```
In the main method, we initialize the node and create an instance of the BasicNavigator class called navigator.

+ 4
- 4
ros2/navigation_stack.md View File

@ -9,7 +9,7 @@ Stretch's mobile base enables this capability and this tutorial will explore how
The first step is to map the space that the robot will navigate in. The `offline_mapping.launch.py` file will enable you to do this. First, run:
```{.bash .shell-prompt}
ros2 launch stretch_navigation offline_mapping.launch.py
ros2 launch stretch_nav2 offline_mapping.launch.py
```
Rviz will show the robot and the map that is being constructed. Now, use the Xbox controller (see instructions below for using a keyboard) to teleoperate the robot around. To teleoperate the robot using the Xbox controller, keep the front left (LB) button pressed while using the right joystick for translation and rotation.
@ -45,7 +45,7 @@ eog ${HELLO_FLEET_PATH}/maps/.pgm
Next, with `<map_name>.yaml`, we can navigate the robot around the mapped space. Run:
```{.bash .shell-prompt}
ros2 launch stretch_navigation navigation.launch.py map:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
ros2 launch stretch_nav2 navigation.launch.py map:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
```
A new RViz window should pop up with a `Startup` button in a menu at the bottom left of the window. Press the `Startup` button to kick-start all navigation related lifecycle nodes. Rviz will show the robot in the previously mapped space, however, it's likely that the robot's location on the map does not match the robot's location in the real space. To correct this, from the top bar of Rviz, use `2D Pose Estimate` to lay an arrow down roughly where the robot is located in real space. This gives an initial estimate of the robot's location to AMCL, the localization package. AMCL will better localize the robot once we pass the robot a `2D Nav Goal`.
@ -65,13 +65,13 @@ The launch files expose the launch argument "teleop_type". By default, this argu
If the Xbox controller is not available, the following commands will launch mapping or navigation, respectively, with keyboard teleop:
```{.bash .shell-prompt}
ros2 launch stretch_navigation offline_mapping.launch.py teleop_type:=keyboard
ros2 launch stretch_nav2 offline_mapping.launch.py teleop_type:=keyboard
```
or
```{.bash .shell-prompt}
ros2 launch stretch_navigation navigation.launch.py teleop_type:=keyboard map:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
ros2 launch stretch_nav2 navigation.launch.py teleop_type:=keyboard map:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
```
## Simple Commander API

Loading…
Cancel
Save