-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SW-764] Consolidate examples into a single ROS package (#279)
## Change Overview This PR puts all spot related examples in `spot_ros2` into a single package called `spot_examples`. Previously, all examples of using the Spot driver were organized into separate ROS packages in the `examples` directory. Each of these ROS 2 packages only held a single node, resulting in a lot of bloat and making it more of a hassle to add new examples. Old structure: ``` examples/ ├── README.md ├── inverse_kinematics_example (ROS2 package) │ ├── inverse_kinematics_example │ │ └── send_inverse_kinematics_requests.py │ ├── package.xml │ ├── README.md │ ├── ... ├── simple_arm_motion (ROS2 package) │ ├── ... ├── simple_walk_forward (ROS2 package) │ ├── ... ├── utilities (ROS2 package) │ ├── ... ``` New file structure implemented in this PR ``` ├── spot_examples (ROS 2 package) │ └── spot_examples │ ├── __init__.py │ ├── arm_simple.py │ ├── send_inverse_kinematics_requests.py │ ├── simple_spot_commander.py │ └── walk_forward.py │ ├── docs │ │ ├── arm_simple.md │ │ ├── send_inverse_kinematics_requests.md │ │ └── walk_forward.md │ ├── package.xml │ ├── setup.py │ ├── README.md │ ├── ... ``` Now, when a new example is added, instead of creating an entirely new package, these steps can be followed. * create `new_example.py` in `spot_examples/spot_examples` and add it to `spot_examples/setup.py` * add documentation `new_example.md` to `spot_examples/docs` and link to it in `spot_examples/README.md` ## Additional consideration In our internal repo, there is a single file that uses `SimpleSpotCommander` which used to be in `examples/utilities` ROS 2 package (can be found by searching for the string `from utilities.simple_spot_commander import SimpleSpotCommander`). This would now need to be updated to `from spot_examples.simple_spot_commander import SimpleSpotCommander` with this implementation. ## Testing Done - [x] Robot tests all successful in one terminal ran `ros2 launch spot_driver spot_driver.launch.py config_file:=spot_ros.yaml spot_name:=Pluto` In another terminal, was successfully able to run ``` ros2 run spot_examples walk_forward --robot Pluto ros2 run spot_examples arm_simple --robot Pluto ros2 run spot_examples send_inverse_kinematics_requests --robot Pluto ```
- Loading branch information
1 parent
4a27bb4
commit dbf6105
Showing
34 changed files
with
176 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# spot_examples | ||
This is a ROS 2 package that demonstrates how to use the Spot driver to control the robot. | ||
|
||
Before running any of these nodes, make sure that the robot is in an open space and that you've built and sourced your ROS 2 workspace. | ||
```bash | ||
cd <ros2_workspace> | ||
colcon build --symlink-install | ||
source install/setup.bash | ||
``` | ||
After this, it's time to start the Spot driver. Define the environment variables `BOSDYN_CLIENT_USERNAME`, `BOSDYN_CLIENT_PASSWORD`, and `SPOT_IP` appropriately for your robot, or put the login credentials into a configuration file yaml ([example](../spot_driver/config/spot_ros_example.yaml)). The driver can be started via the following launchfile: | ||
```bash | ||
ros2 launch spot_driver spot_driver.launch.py | ||
``` | ||
* If you are defining your login credentials in a configuration yaml instead of as environment variables, add the launch argument `config_file:=path/to/config.yaml` | ||
* If you want to launch with a namespace, use the launch argument `spot_name:=<spot_name>` | ||
|
||
|
||
## Nodes | ||
Once the driver has been started, different examples can be run with the following command: | ||
```bash | ||
ros2 run spot_examples <example_node> | ||
``` | ||
Follow the links on each of the node names for more detailed documentation about how each example works, possible command line arguments, and other safety considerations you may need to take into account. | ||
|
||
* [`walk_forward`](docs/walk_forward.md): A simple example that shows how to use ROS 2 to send `RobotCommand` goals to the Spot driver. If you are new to Spot and ROS 2, we recommend starting here. | ||
* [`arm_simple`](docs/arm_simple.md): An example of converting the [BD Simple Arm Motion](https://dev.bostondynamics.com/python/examples/arm_simple/readme) example to use ROS 2. | ||
* [`send_inverse_kinematic_requests`](docs/send_inverse_kinematics_requests.md): An example that shows how to send inverse kinematics requests to the Spot Arm using ROS 2. | ||
|
||
|
||
## Adding new examples | ||
To add examples that demonstrate other features of the Spot driver, create a new node `new_example.py` in [spot_examples](spot_examples) and add it to `setup.py`. Make sure to also write a documentation file (`new_example.md`) in [docs](docs) that explains how to run the example and how the code works, and link to it in this central README. |
Oops, something went wrong.