Skip to content

Commit 9f09c40

Browse files
destoglbmagyar
andauthored
Add test node package (#72)
* Added test-node package Co-authored-by: Bence Magyar <[email protected]>
1 parent fe5a8f0 commit 9f09c40

File tree

14 files changed

+381
-0
lines changed

14 files changed

+381
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
ros2_control_demo_hardware
4242
ros2_control_demo_robot
4343
ros2_control_demos
44+
ros2_control_test_nodes
4445
vcs-repo-file-url: |
4546
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control_demos/ros2_control_demos.repos
4647
colcon-mixin-name: coverage-gcc

.github/workflows/linters.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ jobs:
2121
ros2_control_demo_hardware
2222
ros2_control_demo_robot
2323
ros2_control_demos
24+
ros2_control_test_nodes

.pre-commit-config.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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: v3.4.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+
- id: check-byte-order-marker # Forbid UTF-8 byte-order markers
33+
34+
# Python hooks
35+
- repo: https://github.com/asottile/pyupgrade
36+
rev: v2.12.0
37+
hooks:
38+
- id: pyupgrade
39+
args: [--py36-plus]
40+
41+
- repo: https://github.com/psf/black
42+
rev: 20.8b1
43+
hooks:
44+
- id: black
45+
args: ["--line-length=100"]
46+
47+
# PEP 257
48+
- repo: https://github.com/FalconSocial/pre-commit-mirrors-pep257
49+
rev: v0.3.3
50+
hooks:
51+
- id: pep257
52+
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]
53+
54+
- repo: https://github.com/pycqa/flake8
55+
rev: 3.9.0
56+
hooks:
57+
- id: flake8
58+
args: ["--ignore=E501"]
59+
60+
# CPP hooks
61+
# The same options as in ament_cppcheck are used, but its not working...
62+
#- repo: https://github.com/pocc/pre-commit-hooks
63+
#rev: v1.1.1
64+
#hooks:
65+
#- id: cppcheck
66+
#args: ['--error-exitcode=1', '-f', '--inline-suppr', '-q', '-rp', '--suppress=internalAstError', '--suppress=unknownMacro', '--verbose']
67+
68+
- repo: local
69+
hooks:
70+
- id: ament_cppcheck
71+
name: ament_cppcheck
72+
description: Static code analysis of C/C++ files.
73+
stages: [commit]
74+
entry: ament_cppcheck
75+
language: system
76+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
77+
78+
# Maybe use https://github.com/cpplint/cpplint instead
79+
- repo: local
80+
hooks:
81+
- id: ament_cpplint
82+
name: ament_cpplint
83+
description: Static code analysis of C/C++ files.
84+
stages: [commit]
85+
entry: ament_cpplint
86+
language: system
87+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
88+
args: ["--linelength=120"]
89+
90+
- repo: local
91+
hooks:
92+
- id: clang-format
93+
name: clang-format
94+
description: Format files with ClangFormat.
95+
entry: clang-format-10
96+
language: system
97+
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
98+
args: ['-fallback-style=none', '-i']
99+
100+
# Cmake hooks
101+
- repo: local
102+
hooks:
103+
- id: ament_lint_cmake
104+
name: ament_lint_cmake
105+
description: Check format of CMakeLists.txt files.
106+
stages: [commit]
107+
entry: ament_lint_cmake
108+
language: system
109+
files: CMakeLists.txt$
110+
111+
# Copyright
112+
- repo: local
113+
hooks:
114+
- id: ament_copyright
115+
name: ament_copyright
116+
description: Check if copyright notice is available in all files.
117+
stages: [commit]
118+
entry: ament_copyright
119+
language: system
120+
121+
# Docs - RestructuredText hooks
122+
- repo: https://github.com/PyCQA/doc8
123+
rev: 0.9.0a1
124+
hooks:
125+
- id: doc8
126+
args: ['--max-line-length=100', '--ignore=D001']
127+
128+
- repo: https://github.com/pre-commit/pygrep-hooks
129+
rev: v1.8.0
130+
hooks:
131+
- id: rst-backticks
132+
- id: rst-directive-colons
133+
- id: rst-inline-touching-normal
134+
135+
# Spellcheck in comments and docs
136+
# skipping of *.svg files is not working...
137+
- repo: https://github.com/codespell-project/codespell
138+
rev: v2.0.0
139+
hooks:
140+
- id: codespell
141+
args: ['--write-changes']
142+
exclude: \.(svg|pyc)$

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Direct joint commands are sent to this robot via the `ForwardCommandController`.
116116
The sections below describe their usage.
117117
Check the [Results](##result) section on how to ensure that things went well.
118118

119+
119120
### JointStateController
120121

121122
Open another terminal and load, configure and start `joint_state_controller`:
@@ -174,6 +175,10 @@ Now you should also see the *RRbot* represented correctly in `rviz2`.
174175
- 0.5
175176
- 0.5"
176177
```
178+
b. Or you can start demo node which sends two goals every 5 seconds in a loop:
179+
```
180+
ros2 launch ros2_control_test_nodes rrbot_test_forward_position_controller.launch.py
181+
```
177182

178183
## Result
179184

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
publisher_forward_position_controller:
2+
ros__parameters:
3+
4+
controller_name: "forward_position_controller"
5+
wait_sec_between_publish: 5
6+
7+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
8+
pos1: [0.785, 0.785]
9+
pos2: [0, 0]
10+
pos3: [-0.785, -0.785]
11+
pos4: [0, 0]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2021 Stogl Robotics Consulting UG (haftungsbeschränkt)
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from ament_index_python.packages import get_package_share_directory
18+
19+
from launch import LaunchDescription
20+
from launch_ros.actions import Node
21+
22+
23+
def generate_launch_description():
24+
25+
position_goals = os.path.join(
26+
get_package_share_directory('ros2_control_test_nodes'),
27+
'configs',
28+
'rrbot_forward_position_publisher.yaml'
29+
)
30+
31+
return LaunchDescription([
32+
Node(
33+
package='ros2_control_test_nodes',
34+
executable='publisher_forward_position_controller',
35+
parameters=[position_goals],
36+
output={
37+
'stdout': 'screen',
38+
'stderr': 'screen',
39+
},
40+
)
41+
42+
])

ros2_control_demo_robot/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<exec_depend>joint_state_publisher_gui</exec_depend>
1515
<exec_depend>robot_state_publisher</exec_depend>
1616
<exec_depend>ros2_control_demo_hardware</exec_depend>
17+
<exec_depend>ros2_control_test_nodes</exec_depend>
1718
<exec_depend>rviz2</exec_depend>
1819

1920
<test_depend>ament_cmake_gtest</test_depend>

ros2_control_demos/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<buildtool_depend>ament_cmake</buildtool_depend>
1414

1515
<exec_depend>ros2_control_demo_hardware</exec_depend>
16+
<exec_depend>ros2_control_test_nodes</exec_depend>
1617
<exec_depend>ros2_control_demo_robot</exec_depend>
1718

1819
<export>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>ros2_control_test_nodes</name>
5+
<version>0.0.0</version>
6+
<description>Demo nodes for showing and testing functionalities of the ros2_control framework.</description>
7+
8+
<maintainer email="[email protected]">Denis Štogl</maintainer>
9+
10+
<license>Apache License 2.0</license>
11+
12+
<depend>rclpy</depend>
13+
<depend>std_msgs</depend>
14+
<depend>trajectory_msgs</depend>
15+
16+
<test_depend>ament_copyright</test_depend>
17+
<test_depend>ament_flake8</test_depend>
18+
<test_depend>ament_pep257</test_depend>
19+
<test_depend>python3-pytest</test_depend>
20+
21+
<export>
22+
<build_type>ament_python</build_type>
23+
</export>
24+
</package>
25+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)