Skip to content

Rework python launch test #2767

@christophfroehlich

Description

@christophfroehlich

Background

Motivated by the great talk of @emersonknapp at ROSCon, we should cleanup our launchfiles.
Until the videos are online, you can have a look at the livestream at 6:10 and https://github.com/emersonknapp/roscon2025_launch_snippets

In this repo, we only have this one:

# Executes the given launch file and checks if all nodes can be started
@pytest.mark.launch_test
def generate_test_description():
robot_controllers = os.path.join(
get_package_prefix("controller_manager"), "test", "test_ros2_control_node.yaml"
)
control_node = launch_ros.actions.Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_controllers],
output="both",
)
# Get URDF, without involving xacro
urdf = os.path.join(
get_package_share_directory("ros2_control_test_assets"),
"urdf",
"test_hardware_components.urdf",
)
with open(urdf) as infp:
robot_description_content = infp.read()
robot_description = {"robot_description": robot_description_content}
robot_state_pub_node = launch_ros.actions.Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
ctrl_spawner = generate_controllers_spawner_launch_description(
[
"ctrl_with_parameters_and_type",
],
controller_params_files=[robot_controllers],
)
return LaunchDescription([robot_state_pub_node, control_node, ctrl_spawner, ReadyToTest()])

As a first step, remove the unnecessary local variables and remove the usage of os by using correct launch substitutions (~6:20 in the stream)

Instructions

Hi, this is a good-first-issue issue. This means we've worked to make it more legible to people who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

We're interested in helping you take the first step, and can answer questions and help you out along the way. Note that we're especially interested in contributions from underrepresented groups!

We know that creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this PR for someone new, and looking through our general bug issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!

  • 🗄️ Create a local workspace for making your changes and testing following these instructions, for Step 3 use "Download Source Code" section with these instructions.

  • 🍴 Fork the repository using the handy button at the top of the repository page and clone it into ~/ws_ros2_control/src/ros-controls/ros2_control, here is a guide that you can follow (You will have to remove or empty the existing ros2_control folder before cloning your own fork)

  • Checkout a new branch using git checkout -b <branch_name>

  • 🤖 Apply pre-commit auto formatting, by running pip3 install pre-commit and running pre-commit install in the ros2_control repo.

  • 💾 Commit and Push your changes

  • 🔀 Start a Pull Request to request to merge your code into master. There are two ways that you can start a pull request:

  1. If you are not familiar with GitHub or how to create a pull request, here is a guide you can follow on how GitHub works.
  • 🏁 Done Ask in comments for a review :)

Is someone else already working on this?

🔗- We encourage contributors to link to the original issue in their pull request so all users can easily see if someone's already started on it.

👥- If someone seems stuck, offer them some help!

🤔❓ Questions?

Don’t hesitate to ask questions or to get help if you feel like you are getting stuck. For example leave a comment below!
Furthermore, you find helpful resources here:

Good luck with your first issue!

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions