-
Notifications
You must be signed in to change notification settings - Fork 209
Add --message field to the creation of ROS2 packages.
#1202
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
base: rolling
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2026 Leander Stephen Desouza | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # TODO: Define the message fields here. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. License text is missing. However, the other template files also don't have it, so maybe let's leave it to another PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sure. |
||
| # For example: | ||
| # bool my_flag | ||
| # string my_string | ||
| # int32 my_number | ||
leander-dsouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # if you use a non-trivial message type, do not forget to add its package to package.xml and CMakeLists.txt | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,8 @@ def test_create_package(self): | |
| '--maintainer-email', '[email protected]', | ||
| '--maintainer-name', 'Nobody', | ||
| '--node-name', 'test_node', | ||
| '--library-name', 'test_library' | ||
| '--library-name', 'test_library', | ||
| '--message', 'MyMsg', 'OtherMsg', | ||
| ], cwd=tmpdir | ||
| ) as pkg_command: | ||
| assert pkg_command.wait_for_shutdown(timeout=5) | ||
|
|
@@ -151,6 +152,7 @@ def test_create_package(self): | |
| "dependencies: ['ros2pkg']", | ||
| 'node_name: test_node', | ||
| 'library_name: test_library', | ||
| "messages: ['MyMsg', 'OtherMsg']", | ||
| 'creating folder ' + os.path.join('.', 'a_test_package'), | ||
| 'creating ' + os.path.join('.', 'a_test_package', 'package.xml'), | ||
| 'creating source and include folder', | ||
|
|
@@ -171,29 +173,31 @@ def test_create_package(self): | |
| 'creating ' + os.path.join( | ||
| '.', 'a_test_package', 'include', 'a_test_package', 'visibility_control.h' | ||
| ), | ||
| 'creating folder ' + os.path.join('.', 'a_test_package', 'msg'), | ||
| 'creating ' + os.path.join('.', 'a_test_package', 'msg', 'MyMsg.msg'), | ||
| 'creating ' + os.path.join('.', 'a_test_package', 'msg', 'OtherMsg.msg'), | ||
| ], | ||
| text=pkg_command.output, | ||
| strict=True | ||
| ) | ||
| # Check layout | ||
| assert os.path.isdir(os.path.join(tmpdir, 'a_test_package')) | ||
| assert os.path.isfile(os.path.join(tmpdir, 'a_test_package', 'package.xml')) | ||
| assert os.path.isfile(os.path.join(tmpdir, 'a_test_package', 'CMakeLists.txt')) | ||
| assert os.path.isfile(os.path.join(tmpdir, 'a_test_package', 'LICENSE')) | ||
| assert os.path.isfile( | ||
| os.path.join(tmpdir, 'a_test_package', 'src', 'test_node.cpp') | ||
| ) | ||
| assert os.path.isfile( | ||
| os.path.join(tmpdir, 'a_test_package', 'src', 'test_library.cpp') | ||
| ) | ||
| pkg_dir = os.path.join(tmpdir, 'a_test_package') | ||
| assert os.path.isdir(pkg_dir) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'package.xml')) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'CMakeLists.txt')) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'LICENSE')) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'src', 'test_node.cpp')) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'src', 'test_library.cpp')) | ||
| assert os.path.isfile(os.path.join( | ||
| tmpdir, 'a_test_package', 'include', 'a_test_package', 'test_library.hpp' | ||
| pkg_dir, 'include', 'a_test_package', 'test_library.hpp' | ||
| )) | ||
| assert os.path.isfile(os.path.join( | ||
| tmpdir, 'a_test_package', 'include', 'a_test_package', 'visibility_control.h' | ||
| pkg_dir, 'include', 'a_test_package', 'visibility_control.h' | ||
| )) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'msg', 'MyMsg.msg')) | ||
| assert os.path.isfile(os.path.join(pkg_dir, 'msg', 'OtherMsg.msg')) | ||
| # Check package.xml | ||
| tree = ET.parse(os.path.join(tmpdir, 'a_test_package', 'package.xml')) | ||
| tree = ET.parse(os.path.join(pkg_dir, 'package.xml')) | ||
| root = tree.getroot() | ||
| assert root.tag == 'package' | ||
| assert root.attrib['format'] == '3' | ||
|
|
@@ -204,3 +208,18 @@ def test_create_package(self): | |
| assert root.find('license').text == 'Apache-2.0' | ||
| assert root.find('depend').text == 'ros2pkg' | ||
| assert root.find('.//build_type').text == 'ament_cmake' | ||
|
|
||
| # Check rosidl message dependencies | ||
| buildtool_deps = [e.text for e in root.findall('buildtool_depend')] | ||
| assert 'rosidl_default_generators' in buildtool_deps | ||
| exec_deps = [e.text for e in root.findall('exec_depend')] | ||
| assert 'rosidl_default_runtime' in exec_deps | ||
| assert root.find('member_of_group').text == 'rosidl_interface_packages' | ||
|
|
||
| # Check CMakeLists.txt | ||
| with open(os.path.join(pkg_dir, 'CMakeLists.txt'), 'r', encoding='utf-8') as f: | ||
| cmake_content = f.read() | ||
| assert 'find_package(rosidl_default_generators REQUIRED)' in cmake_content | ||
| assert 'rosidl_generate_interfaces(${PROJECT_NAME}' in cmake_content | ||
| assert '"msg/MyMsg.msg"' in cmake_content | ||
| assert '"msg/OtherMsg.msg"' in cmake_content | ||
Uh oh!
There was an error while loading. Please reload this page.