Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed ign to gz (backport #67) #126

Open
wants to merge 2 commits into
base: humble
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ignition ros2 control CI
name: Gazebo-Sim ros2 control CI

on:
pull_request:
Expand All @@ -8,45 +8,77 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [fortress]
include:
- docker-image: "ubuntu:22.04"
gz-version: "fortress"
ros-distro: "humble"
- docker-image: "ubuntu:22.04"
gz-version: "fortress"
ros-distro: "rolling"
- docker-image: "ubuntu:22.04"
gz-version: "garden"
ros-distro: "humble"
- docker-image: "ubuntu:22.04"
gz-version: "garden"
ros-distro: "rolling"
env:
IGNITION_VERSION: ${{ matrix.version }}
DOCKER_IMAGE: ${{ matrix.docker-image }}
GZ_VERSION: ${{ matrix.gz-version }}
ROS_DISTRO: ${{ matrix.ros-distro }}
container:
image: ubuntu:22.04
image: ${{ matrix.docker-image }}
steps:
- uses: actions/checkout@v2
- name: Setup colcon workspace
id: configure
shell: bash
run: |
export DEBIAN_FRONTEND=noninteractive
apt update -qq
apt install -qq -y lsb-release wget curl gnupg2
apt install -qq -y lsb-release wget curl gnupg2 git
cd ..
mkdir -p /home/ros2_ws/src
if [ "$ROS_DISTRO" == "rolling" ]; then
git clone https:/gazebosim/ros_gz/
fi
if [ "$ROS_DISTRO" == "humble" ]; then
git clone https:/gazebosim/ros_gz/ -b humble
fi
cp -r gz_ros2_control /home/ros2_ws/src/
sh -c 'echo "deb http://packages.ros.org/ros2-testing/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-testing.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
if [ "$GZ_VERSION" == "garden" ]; then
export GZ_DEPS="libgz-sim7-dev libgz-plugin2-dev"
fi

apt-get update && apt-get upgrade -q -y
apt-get update && apt-get install -qq -y \
dirmngr \
python3-colcon-ros \
python3-colcon-common-extensions \
python3-rosdep \
build-essential
build-essential \
${GZ_DEPS}

if [ "$GZ_VERSION" == "garden" ]; then
export ROSDEP_ARGS="--skip-keys ros_gz_sim --skip-keys gz-plugin2 --skip-keys gz-sim7 --skip-keys gz-transport12 --skip-keys gz-math7 --skip-keys gz-msgs9"
fi
cd /home/ros2_ws/src/
rosdep init
rosdep update
rosdep install --from-paths ./ -i -y --rosdistro humble --ignore-src
rosdep install --from-paths ./ -i -y --rosdistro ${ROS_DISTRO} --ignore-src ${ROSDEP_ARGS}
- name: Build project
id: build
run: |
cd /home/ros2_ws/
. /opt/ros/humble/local_setup.sh
colcon build --packages-up-to ign_ros2_control_demos
. /opt/ros/${ROS_DISTRO}/local_setup.sh
colcon build --packages-up-to gz_ros2_control_demos
- name: Run tests
id: test
run: |
cd /home/ros2_ws/
. /opt/ros/humble/local_setup.sh
colcon test --event-handlers console_direct+ --packages-select ign_ros2_control ign_ros2_control_demos
. /opt/ros/${ROS_DISTRO}/local_setup.sh
colcon test --event-handlers console_direct+ --packages-select gz_ros2_control gz_ros2_control_demos
colcon test-result
7 changes: 6 additions & 1 deletion Dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive
<<<<<<< HEAD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge artifact

ENV IGNITION_VERSION fortress
=======
ENV GZ_VERSION fortress
ENV ROS_DISTRO rolling
>>>>>>> ab810e7 (Renamed ign to gz (#67))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge artifact


# Make sure everything is up to date before building from source
RUN apt-get update \
Expand Down Expand Up @@ -39,4 +44,4 @@ RUN cd /home/ros2_ws/ \
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

CMD ros2 launch ign_ros2_control_demos cart_example_position.launch.py
CMD ros2 launch gz_ros2_control_demos cart_example_position.launch.py
147 changes: 110 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# ign_ros2_control
# gz_ros2_control

<<<<<<< HEAD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Artifact of a bad merge/rebase.

=======
ROS2 Distro | Build Status | Package build |
:---------: | :----: | :----------: |
[![Licence](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | [![Build Status](http://build.ros2.org/buildStatus/icon?job=Hdev__ign_ros2_control__ubuntu_focal_amd64)](http://build.ros2.org/job/Hdev__ign_ros2_control__ubuntu_focal_amd64) | [![Build Status](http://build.ros2.org/buildStatus/icon?job=Hbin_uF64__ign_ros2_control__ubuntu_focal_amd64__binary)](http://build.ros2.org/job/Hbin_uF64__ign_ros2_control__ubuntu_focal_amd64__binary) |

>>>>>>> ab810e7 (Renamed ign to gz (#67))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

artifact of bad merge/rebase

This is a ROS 2 package for integrating the `ros2_control` controller architecture with the [Ignition Gazebo](http://ignitionrobotics.org/) simulator.
More information about `ros2_control` can be found here: https://control.ros.org/

This package provides an Ignition Gazebo system plugin which instantiates a `ros2_control` controller manager and connects it to a Gazebo model.
This package provides a Gazebo-Sim system plugin which instantiates a `ros2_control` controller manager and connects it to a Gazebo model.

Tested on:

Expand All @@ -17,12 +24,11 @@ If you want to run this with `ROS 2 Foxy` please check the branch `foxy`.

# Compile from source

If you want compile this from source, you should choose the Ignition version. The default one is `citadel`:
If you want compile this from source, you should choose the Gazebo version. The default one is `garden`:

```bash
export IGNITION_VERSION=citadel
export IGNITION_VERSION=edifice
export IGNITION_VERSION=fortress
export GZ_VERSION=fortress
export GZ_VERSION=garden
```

Then create a workspace, clone the repo and compile it:
Expand All @@ -40,7 +46,7 @@ colcon build

## Video + Pictures

![](img/ign_ros2_control.gif)
![](img/gz_ros2_control.gif)

![](img/diff_drive.gif)

Expand All @@ -51,7 +57,7 @@ colcon build

```bash
cd Dockerfile
docker build -t ign_ros2_control .
docker build -t gz_ros2_control .
```

### To run the demo
Expand All @@ -61,7 +67,7 @@ docker build -t ign_ros2_control .
Docker allows us to run the demo without the GUI if configured properly. The following command runs the demo without the GUI:

```bash
docker run -it --rm --name ignition_ros2_control_demo --net host ign_ros2_control ros2 launch ign_ros2_control_demos cart_example_position.launch.py gui:=false
docker run -it --rm --name gz_ros2_control_demo --net host gz_ros2_control ros2 launch gz_ros2_control_demos cart_example_position.launch.py gui:=false
```

Then on your local machine, you can run the Gazebo client:
Expand All @@ -76,18 +82,18 @@ To run the demo with the GUI, we are going to use [rocker](https:/os
images with customized local support injected for things like nvidia support. Rocker also supports user id specific files for cleaner
mounting file permissions. You can install this tool with the following [instructions](https:/osrf/rocker/#installation) (make sure you meet all of the [prerequisites](https:/osrf/rocker/#prerequisites)).

The following command will launch Ignition:
The following command will launch Gazebo:

```bash
rocker --x11 --nvidia --name ignition_ros2_control_demo ign_ros2_control:latest
rocker --x11 --nvidia --name gz_ros2_control_demo gz_ros2_control:latest
```

The following commands allow the cart to be moved along the rail:

```bash
docker exec -it ignition_ros2_control_demo bash
docker exec -it gz_ros2_control_demo bash
source /home/ros2_ws/install/setup.bash
ros2 run ign_ros2_control_demos example_position
ros2 run gz_ros2_control_demos example_position
```

## Add ros2_control tag to a URDF
Expand All @@ -100,9 +106,9 @@ include:
- `<joint>` tag including the robot controllers: commands and states.

```xml
<ros2_control name="IgnitionSystem" type="system">
<ros2_control name="GazeboSimSystem" type="system">
<hardware>
<plugin>ign_ros2_control/IgnitionSystem</plugin>
<plugin>gz_ros2_control/GazeboSimSystem</plugin>
</hardware>
<joint name="slider_to_cart">
<command_interface name="effort">
Expand All @@ -118,56 +124,100 @@ include:
</ros2_control>
```

<<<<<<< HEAD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are bunch of these.

## Add the ign_ros2_control plugin
=======

### Using mimic joints in simulation

To use `mimic` joints in `gz_ros2_control` you should define its parameters to your URDF.
We should include:

- `<mimic>` tag to the mimicked joint ([detailed manual(https://wiki.ros.org/urdf/XML/joint))
- `mimic` and `multiplier` parameters to joint definition in `<ros2_control>` tag

```xml
<joint name="left_finger_joint" type="prismatic">
<mimic joint="right_finger_joint"/>
<axis xyz="0 1 0"/>
<origin xyz="0.0 0.48 1" rpy="0.0 0.0 3.1415926535"/>
<parent link="base"/>
<child link="finger_left"/>
<limit effort="1000.0" lower="0" upper="0.38" velocity="10"/>
</joint>
```

```xml
<joint name="left_finger_joint">
<param name="mimic">right_finger_joint</param>
<param name="multiplier">1</param>
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
```


## Add the gz_ros2_control plugin
>>>>>>> ab810e7 (Renamed ign to gz (#67))

In addition to the `ros2_control` tags, a Gazebo plugin needs to be added to your URDF that
actually parses the `ros2_control` tags and loads the appropriate hardware interfaces and
controller manager. By default the `ign_ros2_control` plugin is very simple, though it is also
controller manager. By default the `gz_ros2_control` plugin is very simple, though it is also
extensible via an additional plugin architecture to allow power users to create their own custom
robot hardware interfaces between `ros2_control` and Gazebo.

```xml
<gazebo>
<<<<<<< HEAD
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control">
=======
<plugin filename="libgz_ros2_control-system.so" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
>>>>>>> ab810e7 (Renamed ign to gz (#67))
<robot_param>robot_description</robot_param>
<robot_param_node>robot_state_publisher</robot_param_node>
<parameters>$(find ign_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
<parameters>$(find gz_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
</plugin>
</gazebo>
```

The `ign_ros2_control` `<plugin>` tag also has the following optional child elements:
The `gz_ros2_control` `<plugin>` tag also has the following optional child elements:

- `<parameters>`: YAML file with the configuration of the controllers

#### Default ign_ros2_control Behavior
#### Default gz_ros2_control Behavior

By default, without a `<plugin>` tag, `ign_ros2_control` will attempt to get all of the information it needs to interface with a ros2_control-based controller out of the URDF. This is sufficient for most cases, and good for at least getting started.
By default, without a `<plugin>` tag, `gz_ros2_control` will attempt to get all of the information it needs to interface with a ros2_control-based controller out of the URDF. This is sufficient for most cases, and good for at least getting started.

The default behavior provides the following ros2_control interfaces:

- hardware_interface::JointStateInterface
- hardware_interface::EffortJointInterface
- hardware_interface::VelocityJointInterface

#### Advanced: custom ign_ros2_control Simulation Plugins
#### Advanced: custom gz_ros2_control Simulation Plugins

The `ign_ros2_control` Gazebo plugin also provides a pluginlib-based interface to implement custom interfaces between Gazebo and `ros2_control` for simulating more complex mechanisms (nonlinear springs, linkages, etc).
The `gz_ros2_control` Gazebo plugin also provides a pluginlib-based interface to implement custom interfaces between Gazebo and `ros2_control` for simulating more complex mechanisms (nonlinear springs, linkages, etc).

These plugins must inherit the `ign_ros2_control::IgnitionSystemInterface`, which implements a simulated `ros2_control`
These plugins must inherit the `gz_ros2_control::GazeboSimSystemInterface`, which implements a simulated `ros2_control`
`hardware_interface::SystemInterface`. SystemInterface provides API-level access to read and command joint properties.

The respective IgnitionSystemInterface sub-class is specified in a URDF model and is loaded when the
The respective GazeboSimSystemInterface sub-class is specified in a URDF model and is loaded when the
robot model is loaded. For example, the following XML will load the default plugin:
```xml
<ros2_control name="IgnitionSystem" type="system">
<ros2_control name="GazeboSimSystem" type="system">
<hardware>
<plugin>ign_ros2_control/IgnitionSystem</plugin>
<plugin>gz_ros2_control/GazeboSimSystem</plugin>
</hardware>
...
<ros2_control>
<gazebo>
<<<<<<< HEAD
<plugin name="ign_ros2_control" filename="libign_ros2_control-system.so">
=======
<plugin name="gz_ros2_control::GazeboSimROS2ControlPlugin" filename="libgz_ros2_control-system">
>>>>>>> ab810e7 (Renamed ign to gz (#67))
...
</plugin>
</gazebo>
Expand All @@ -180,8 +230,13 @@ and use the tag `<controller_manager_prefix_node_name>` to set the controller ma

```xml
<gazebo>
<<<<<<< HEAD
<plugin name="ign_ros2_control" filename="libign_ros2_control-system.so">
<parameters>$(find ign_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
=======
<plugin name="gz_ros2_control::GazeboSimROS2ControlPlugin" filename="libgz_ros2_control-system">
<parameters>$(find gz_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
>>>>>>> ab810e7 (Renamed ign to gz (#67))
<controller_manager_prefix_node_name>controller_manager</controller_manager_prefix_node_name>
</plugin>
<gazebo>
Expand Down Expand Up @@ -210,26 +265,44 @@ cart_pole_controller:
```
#### Executing the examples

There are some examples in the `ign_ros2_control_demos` package. These examples allow to launch a cart in a 30 meter rail.
There are some examples in the `gz_ros2_control_demos` package. These examples allow to launch a cart in a 30 meter rail.

You can run some of the example configurations by running the following commands:

```bash
ros2 launch ign_ros2_control_demos cart_example_position.launch.py
ros2 launch ign_ros2_control_demos cart_example_velocity.launch.py
ros2 launch ign_ros2_control_demos cart_example_effort.launch.py
ros2 launch ign_ros2_control_demos diff_drive_example.launch.py
ros2 launch ign_ros2_control_demos tricycle_drive_example.launch.py
ros2 launch gz_ros2_control_demos cart_example_position.launch.py
ros2 launch gz_ros2_control_demos cart_example_velocity.launch.py
ros2 launch gz_ros2_control_demos cart_example_effort.launch.py
ros2 launch gz_ros2_control_demos diff_drive_example.launch.py
ros2 launch gz_ros2_control_demos tricycle_drive_example.launch.py
```

Send example commands:

When the Gazebo world is launched, you can run some of the following commands to move the cart.

```bash
ros2 run ign_ros2_control_demos example_position
ros2 run ign_ros2_control_demos example_velocity
ros2 run ign_ros2_control_demos example_effort
ros2 run ign_ros2_control_demos example_diff_drive
ros2 run ign_ros2_control_demos example_tricycle_drive
ros2 run gz_ros2_control_demos example_position
ros2 run gz_ros2_control_demos example_velocity
ros2 run gz_ros2_control_demos example_effort
ros2 run gz_ros2_control_demos example_diff_drive
ros2 run gz_ros2_control_demos example_tricycle_drive
```
<<<<<<< HEAD
=======

The following example shows parallel gripper with mimic joint:

![](img/gripper.gif)


```bash
ros2 launch gz_ros2_control_demos gripper_mimic_joint_example.launch.py
```

Send example commands:

```bash
ros2 run gz_ros2_control_demos example_gripper
```
>>>>>>> ab810e7 (Renamed ign to gz (#67))
File renamed without changes.
Loading