Skip to content

Commit cbd4a8e

Browse files
authored
Merge pull request #121 from livanov93/port-master-to-humble
Port master to humble
2 parents 6c4244d + 2568e8c commit cbd4a8e

19 files changed

+806
-61
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
# Workflow files stored in the
10+
# default location of `.github/workflows`
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"

.github/workflows/ci-format.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is a format job. Pre-commit has a first-party GitHub action, so we use
2+
# that: https://github.com/pre-commit/action
3+
4+
name: Format
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
10+
jobs:
11+
pre-commit:
12+
name: Format
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version: 3.10.6
19+
- name: Install system hooks
20+
run: sudo apt install -qq cppcheck ament-cmake-uncrustify ament-cmake-pep257
21+
- uses: pre-commit/[email protected]
22+
with:
23+
extra_args: --all-files --hook-stage manual

.github/workflows/triage.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ jobs:
1616
COLUMN: Inbox
1717
GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }}
1818
CHECK_ORG_PROJECT: true
19-

.pre-commit-config.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
repos:
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v4.1.0
19+
hooks:
20+
- id: check-added-large-files
21+
- id: check-ast
22+
- id: check-case-conflict
23+
- id: check-docstring-first
24+
- id: check-merge-conflict
25+
- id: check-symlinks
26+
- id: check-xml
27+
- id: check-yaml
28+
- id: debug-statements
29+
- id: end-of-file-fixer
30+
- id: mixed-line-ending
31+
- id: trailing-whitespace
32+
exclude_types: [rst]
33+
- id: fix-byte-order-marker
34+
35+
36+
# Python hooks
37+
- repo: https://github.com/asottile/pyupgrade
38+
rev: v2.31.1
39+
hooks:
40+
- id: pyupgrade
41+
args: [--py36-plus]
42+
43+
# # PEP 257
44+
- repo: local
45+
hooks:
46+
- id: ament_pep257
47+
name: ament_pep257
48+
description: Format files with pep257.
49+
entry: ament_pep257
50+
language: system
51+
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]
52+
53+
- repo: https://github.com/pycqa/flake8
54+
rev: 4.0.1
55+
hooks:
56+
- id: flake8
57+
args: ["--extend-ignore=E501"]
58+
59+
# CPP hooks
60+
- repo: local
61+
hooks:
62+
- id: ament_uncrustify
63+
name: ament_uncrustify
64+
description: Format files with uncrustify.
65+
entry: ament_uncrustify
66+
language: system
67+
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
68+
args: ["--reformat"]
69+
70+
- repo: local
71+
hooks:
72+
- id: ament_cppcheck
73+
name: ament_cppcheck
74+
description: Static code analysis of C/C++ files.
75+
stages: [commit]
76+
entry: ament_cppcheck
77+
language: system
78+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
79+
80+
# Maybe use https://github.com/cpplint/cpplint instead
81+
- repo: local
82+
hooks:
83+
- id: ament_cpplint
84+
name: ament_cpplint
85+
description: Static code analysis of C/C++ files.
86+
stages: [commit]
87+
entry: ament_cpplint
88+
language: system
89+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
90+
args: ["--linelength=100", "--filter=-whitespace/newline"]
91+
92+
# Cmake hooks
93+
- repo: local
94+
hooks:
95+
- id: ament_lint_cmake
96+
name: ament_lint_cmake
97+
description: Check format of CMakeLists.txt files.
98+
stages: [commit]
99+
entry: ament_lint_cmake
100+
language: system
101+
files: CMakeLists\.txt$
102+
103+
# Copyright
104+
- repo: local
105+
hooks:
106+
- id: ament_copyright
107+
name: ament_copyright
108+
description: Check if copyright notice is available in all files.
109+
stages: [commit]
110+
entry: ament_copyright
111+
language: system
112+
113+
# Docs - RestructuredText hooks
114+
- repo: https://github.com/PyCQA/doc8
115+
rev: 0.10.1
116+
hooks:
117+
- id: doc8
118+
args: ['--max-line-length=100', '--ignore=D001']
119+
exclude: CHANGELOG\.rst$
120+
121+
- repo: https://github.com/pre-commit/pygrep-hooks
122+
rev: v1.9.0
123+
hooks:
124+
- id: rst-backticks
125+
exclude: CHANGELOG\.rst$
126+
- id: rst-directive-colons
127+
- id: rst-inline-touching-normal
128+
129+
# Spellcheck in comments and docs
130+
# skipping of *.svg files is not working...
131+
- repo: https://github.com/codespell-project/codespell
132+
rev: v2.1.0
133+
hooks:
134+
- id: codespell
135+
args: ['--write-changes']
136+
exclude: CHANGELOG\.rst|\.(svg|pyc)$

Dockerfile/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:22.04
22

33
ENV DEBIAN_FRONTEND noninteractive
44
ENV IGNITION_VERSION fortress
5+
ENV ROS_DISTRO humble
56

67
# Make sure everything is up to date before building from source
78
RUN apt-get update \
@@ -30,10 +31,10 @@ RUN mkdir -p /home/ros2_ws/src \
3031
&& cd /home/ros2_ws/src \
3132
&& git clone https://github.com/ros-controls/gz_ros2_control/ \
3233
&& rosdep init && rosdep update \
33-
&& rosdep install --from-paths ./ -i -y --rosdistro rolling
34+
&& rosdep install --from-paths ./ -i -y --rosdistro ${ROS_DISTRO}
3435

3536
RUN cd /home/ros2_ws/ \
36-
&& . /opt/ros/rolling/setup.sh \
37+
&& . /opt/ros/"${ROS_DISTRO}"/setup.sh \
3738
&& colcon build --merge-install
3839

3940
COPY entrypoint.sh /entrypoint.sh

README.md

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
# ign_ros2_control
22

3+
ROS2 Distro | Build Status | Package build |
4+
:---------: | :----: | :----------: |
5+
[![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__gz_ros2_control__ubuntu_focal_amd64)](http://build.ros2.org/job/Hdev__gz_ros2_control__ubuntu_focal_amd64) | [![Build Status](http://build.ros2.org/buildStatus/icon?job=Hbin_uF64__gz_ros2_control__ubuntu_focal_amd64__binary)](http://build.ros2.org/job/Hbin_uF64__gz_ros2_control__ubuntu_focal_amd64__binary) |
6+
37
This is a ROS 2 package for integrating the `ros2_control` controller architecture with the [Ignition Gazebo](http://ignitionrobotics.org/) simulator.
48
More information about `ros2_control` can be found here: https://control.ros.org/
59

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

8-
Tested on:
12+
[![Build Status](https://github.com/ros-controls/gz_ros2_control/actions/workflows/ci.yaml/badge.svg?branch=galactic)](https://github.com/ros-controls/gz_ros2_control/actions/workflows/ci.yaml)
913

10-
- Debs:
11-
- [Ignition Edifice](https://ignitionrobotics.org/docs/edifice) + [ROS 2 Galactic](https://docs.ros.org/en/galactic/Installation.html)
12-
- From source:
13-
- [Ignition Citadel](https://ignitionrobotics.org/docs/citadel) + [ROS 2 Galactic](https://docs.ros.org/en/galactic/Installation.html)
14-
- [Ignition Fortress](https://ignitionrobotics.org/docs/fortress) + [ROS 2 Galactic](https://docs.ros.org/en/galactic/Installation.html)
14+
ROS version | Gazebo version | Branch | Binaries hosted at
15+
-- | -- | -- | --
16+
Foxy | Citadel | [foxy](https://github.com/ros-controls/gz_ros2_control/tree/foxy) | https://packages.ros.org
17+
Foxy | Edifice | [foxy](https://github.com/ros-controls/gz_ros2_control/tree/foxy) | only from source
18+
Galactic | Edifice | [galactic](https://github.com/ros-controls/gz_ros2_control/tree/galactic) | https://packages.ros.org
19+
Galactic | Fortress | [galactic](https://github.com/ros-controls/gz_ros2_control/tree/galactic) | only from source
20+
Humble | Fortress | [ros2](https://github.com/ros-controls/gz_ros2_control/tree/master) | https://packages.ros.org
21+
Rolling | Edifice | [ros2](https://github.com/ros-controls/gz_ros2_control/tree/master) | only from source
22+
Rolling | Fortress | [ros2](https://github.com/ros-controls/gz_ros2_control/tree/master) | https://packages.ros.org
23+
Rolling | Garden (not released) | [ros2](https://github.com/ros-controls/gz_ros2_control/tree/master) | only from source
1524

16-
If you want to run this with `ROS 2 Foxy` please check the branch `foxy`.
1725

1826
# Compile from source
1927

@@ -118,6 +126,38 @@ include:
118126
</ros2_control>
119127
```
120128

129+
130+
### Using mimic joints in simulation
131+
132+
To use `mimic` joints in `ign_ros2_control` you should define its parameters to your URDF.
133+
We should include:
134+
135+
- `<mimic>` tag to the mimicked joint ([detailed manual(https://wiki.ros.org/urdf/XML/joint))
136+
- `mimic` and `multiplier` parameters to joint definition in `<ros2_control>` tag
137+
138+
```xml
139+
<joint name="left_finger_joint" type="prismatic">
140+
<mimic joint="right_finger_joint"/>
141+
<axis xyz="0 1 0"/>
142+
<origin xyz="0.0 0.48 1" rpy="0.0 0.0 3.1415926535"/>
143+
<parent link="base"/>
144+
<child link="finger_left"/>
145+
<limit effort="1000.0" lower="0" upper="0.38" velocity="10"/>
146+
</joint>
147+
```
148+
149+
```xml
150+
<joint name="left_finger_joint">
151+
<param name="mimic">right_finger_joint</param>
152+
<param name="multiplier">1</param>
153+
<command_interface name="position"/>
154+
<state_interface name="position"/>
155+
<state_interface name="velocity"/>
156+
<state_interface name="effort"/>
157+
</joint>
158+
```
159+
160+
121161
## Add the ign_ros2_control plugin
122162

123163
In addition to the `ros2_control` tags, a Gazebo plugin needs to be added to your URDF that
@@ -128,7 +168,7 @@ robot hardware interfaces between `ros2_control` and Gazebo.
128168

129169
```xml
130170
<gazebo>
131-
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control">
171+
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control::IgnitionROS2ControlPlugin">
132172
<robot_param>robot_description</robot_param>
133173
<robot_param_node>robot_state_publisher</robot_param_node>
134174
<parameters>$(find ign_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
@@ -167,7 +207,7 @@ robot model is loaded. For example, the following XML will load the default plug
167207
...
168208
<ros2_control>
169209
<gazebo>
170-
<plugin name="ign_ros2_control" filename="libign_ros2_control-system.so">
210+
<plugin name="ign_ros2_control::IgnitionROS2ControlPlugin" filename="libign_ros2_control-system.so">
171211
...
172212
</plugin>
173213
</gazebo>
@@ -180,7 +220,7 @@ and use the tag `<controller_manager_prefix_node_name>` to set the controller ma
180220

181221
```xml
182222
<gazebo>
183-
<plugin name="ign_ros2_control" filename="libign_ros2_control-system.so">
223+
<plugin name="ign_ros2_control::IgnitionROS2ControlPlugin" filename="libign_ros2_control-system.so">
184224
<parameters>$(find ign_ros2_control_demos)/config/cartpole_controller.yaml</parameters>
185225
<controller_manager_prefix_node_name>controller_manager</controller_manager_prefix_node_name>
186226
</plugin>
@@ -233,3 +273,18 @@ ros2 run ign_ros2_control_demos example_effort
233273
ros2 run ign_ros2_control_demos example_diff_drive
234274
ros2 run ign_ros2_control_demos example_tricycle_drive
235275
```
276+
277+
The following example shows parallel gripper with mimic joint:
278+
279+
![](img/gripper.gif)
280+
281+
282+
```bash
283+
ros2 launch ign_ros2_control_demos gripper_mimic_joint_example.launch.py
284+
```
285+
286+
Send example commands:
287+
288+
```bash
289+
ros2 run ign_ros2_control_demos example_gripper
290+
```

ign_ros2_control/CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Changelog for package ign_ros2_control
1313
* Fix ignition version in package.xml - Rolling (`#41 <https://github.com/ros-controls/gz_ros2_control/issues/41>`_)
1414
* Fixed position control (`#29 <https://github.com/ros-controls/gz_ros2_control/issues/29>`_)
1515
* Add support for initial_values for hardware interfaces when starting simulation. (`#27 <https://github.com/ros-controls/gz_ros2_control/issues/27>`_)
16-
* Contributors: Alejandro Hernández Cordero, Bence Magyar, Denis Štogl, Guillaume Beuzeboc
16+
* Contributors: Alejandro Hernández Cordero, Denis Štogl, Guillaume Beuzeboc, Tianyu Li
1717

1818
0.4.0 (2022-03-18)
1919
------------------

ign_ros2_control/include/ign_ros2_control/ign_system.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class IgnitionSystem : public IgnitionSystemInterface
5656
// Documentation Inherited
5757
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
5858

59+
// Documentation Inherited
60+
hardware_interface::return_type perform_command_mode_switch(
61+
const std::vector<std::string> & start_interfaces,
62+
const std::vector<std::string> & stop_interfaces) override;
63+
5964
// Documentation Inherited
6065
hardware_interface::return_type read(
6166
const rclcpp::Time & time,

ign_ros2_control/src/ign_ros2_control_plugin.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,18 @@ void IgnitionROS2ControlPlugin::Configure(
270270
return;
271271
}
272272

273+
std::vector<std::string> arguments = {"--ros-args"};
274+
275+
auto sdfPtr = const_cast<sdf::Element *>(_sdf.get());
276+
277+
sdf::ElementPtr argument_sdf = sdfPtr->GetElement("parameters");
278+
while (argument_sdf) {
279+
std::string argument = argument_sdf->Get<std::string>();
280+
arguments.push_back(RCL_PARAM_FILE_FLAG);
281+
arguments.push_back(argument);
282+
argument_sdf = argument_sdf->GetNextElement("parameters");
283+
}
284+
273285
// Get controller manager node name
274286
std::string controllerManagerNodeName{"controller_manager"};
275287

@@ -279,9 +291,6 @@ void IgnitionROS2ControlPlugin::Configure(
279291
controllerManagerNodeName = controllerManagerPrefixNodeName + "_" + controllerManagerNodeName;
280292
}
281293

282-
std::vector<std::string> arguments = {"--ros-args", "--params-file", paramFileName};
283-
auto sdfPtr = const_cast<sdf::Element *>(_sdf.get());
284-
285294
if (sdfPtr->HasElement("ros")) {
286295
sdf::ElementPtr sdfRos = sdfPtr->GetElement("ros");
287296

@@ -428,6 +437,10 @@ void IgnitionROS2ControlPlugin::Configure(
428437
std::chrono::duration_cast<std::chrono::nanoseconds>(
429438
std::chrono::duration<double>(1.0 / static_cast<double>(this->dataPtr->update_rate))));
430439

440+
// Force setting of use_sime_time parameter
441+
this->dataPtr->controller_manager_->set_parameter(
442+
rclcpp::Parameter("use_sim_time", rclcpp::ParameterValue(true)));
443+
431444
this->dataPtr->entity_ = _entity;
432445
}
433446

0 commit comments

Comments
 (0)