-
Notifications
You must be signed in to change notification settings - Fork 2
Implement ros2_control #58
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
97418e9
fix: typo, wrong type, outdated comments and other small fixes
mbloechli 7f07d6c
feat(control): added control package
mbloechli 78fd7f1
refactor: allowing access to docker.sock without sudo, removes the ne…
mbloechli 7b51b91
feat(cli): added test for that checks if robot responds to cmd_vel input
mbloechli 285d94a
doc: Added a README explaining the general use of this repo
mbloechli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| # Custom Alias | ||
| alias src='source /opt/ros/jazzy/setup.bash && source /home/ws/install/setup.bash' | ||
| alias build='/home/ws/docker/build.sh' | ||
| alias test='build && sudo /home/act -j test-locally' | ||
| alias test='sudo /home/act -j test-locally' | ||
| alias clc_test='build && colcon build --symlink-install && colcon test --executor sequential' | ||
|
|
||
| # Integrate entrypoint.sh | ||
| source /home/ws/docker/entrypoint.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,85 @@ | ||
| # HelMoRo-software-ROS2 | ||
| Welcome to our HelMoRo repository! | ||
| We moved all our documentation to our [website](https://helbling-technik.github.io/HelMoRo/), to remove redundant and/ or conflicting information. | ||
|
|
||
| Welcome to the microservices branch! This branch provides a modular and extensible software stack for robotics applications using ROS 2. The repository includes tools for simulation, control, visualization, and command-line interaction with robots. | ||
|
|
||
| ## Roadmap | ||
| ### Current Features | ||
| * **Simulation**: Manage simulation environments with Gazebo and ROS 2 integration. | ||
| * **Control**: Implement robot joint control using ros2_control and Gazebo plugins. | ||
| * **Visualization**: Visualize robot states and environments using RViz2. | ||
| * **Command-Line Interface**: Interact with the system via a user-friendly CLI. | ||
| * **Multi-Robot Support**: Built for managing multiple robots in simulation. | ||
|
|
||
| ### Planned Features | ||
| * **State Estimation**: Sensor fusion for accurate odometry. | ||
| * **SLAM**: Self-localization and mapping in a dynamic environment. | ||
| * **Teleopration**: Steer your robots with joysticks. | ||
| * **Navigation**: Autonomous navigation through unknown environments. | ||
|
|
||
|
|
||
| ## Repository Overview | ||
| * **`.devcontainer`**: Development container configuration for VS Code. | ||
| * **`.github`**: Configurations for CI pipeline using GitHub Actions. | ||
| * **`docker`**: Docker setup for development and deployment. | ||
| * **`config`**: Configuration files for middleware and other tools. | ||
| * **`src/ helmoro_cli`**: Command-line interface for managing simulations and robots. | ||
| * **`src/ helmoro_control`**: ROS 2 package for controlling robot joints and states. | ||
| * **`src/ helmoro_description`**: Robot description files (URDF/Xacro) | ||
| * **`src/ helmoro_simulation`**: Tools and configurations for simulation environments. | ||
| * **`src/ helmoro_utils`**: Utility scripts and tools for the project | ||
| * **`src/ helmoro_visualization`**: Visualization tools and RViz configurations. | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Prerequisites | ||
| - Linux OS | ||
| - Docker | ||
| - VSCode with Devcontainer Extension | ||
|
|
||
| ### Setup | ||
| 1. Clone the repository and check out the microservices branch: | ||
| ```bash | ||
| git clone https://github.com/helbling-technik/HelMoRo-software-ROS2.git | ||
| git checkout microservices | ||
| ``` | ||
|
|
||
| 2. Open the repo with VSCode: | ||
| ```bash | ||
| code HelMoRo-software-ROS2 | ||
| ``` | ||
|
|
||
| 3. Start the Devcontainer through VSCode's command palette: | ||
| ``` | ||
| Dev Containers: Reopen in Container | ||
| ``` | ||
|
|
||
| ### Running the Simulation | ||
| For running the simulation it's recommended to use the [CLI](/src/helmoro_cli/README.md). Start the CLI with: | ||
| ```bash | ||
| ros2 run helmoro_cli open_cli | ||
| ``` | ||
|
|
||
| The simulation can be started with: | ||
| ```bash | ||
| start_simulation depot | ||
| ``` | ||
|
|
||
| Robots can be spawned with: | ||
| ```bash | ||
| multi_robot_spawn | ||
| ``` | ||
|
|
||
| ## Contributing | ||
| Contributions are welcome! Create an issue or resolve an existing one. For new contributors, we recommend tackling one of the issues labeled with "good first issue", as they do not require a complete understanding of the repo. | ||
|
|
||
| ### Testing | ||
| For local testing type `test` in your terminal. This will start up the act container. On the first startup, you'll be asked to choose a default image to use with Act, and choose the medium one. Until now that one had all the utilities we needed. During development, the alias `clc_test` is also useful. Instead of creating a containerized environment similar to the tests running in GitHub runners, it runs the tests directly in the Devcontainer. This leads to quicker testing, but may not catch all bugs. | ||
|
|
||
| ### Pull Request | ||
| When starting out create a draft pull request, so others know that you're working on the issue. On completion of a successful local test push to your dev branch and change your draft pull request to a normal one. | ||
|
|
||
| ### Commit Messages | ||
| By following a unified commit message standard, we are able to trace bugs quickly. Please adhere to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. | ||
|
|
||
| ## License | ||
| This project is licensed under the BSD 3-Clause License. See the [LICENSE](./LICENSE) file for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import time | ||
| import pytest | ||
| import rclpy | ||
|
|
||
| from helmoro_cli.robot_manager import RobotManager | ||
| from helmoro_cli.simulation_manager import SimulationManager | ||
| from helmoro_utils.test_helpers import wait_for_topic, wait_for_node_with_namespace, wait_for_goal_reached | ||
| from helmoro_utils.publishers import publish_twist_stamped | ||
|
|
||
| @pytest.fixture(scope="module") | ||
| def robot_manager(): | ||
| """Fixture to initialize and return a RobotManager instance.""" | ||
| print("[Fixture] Creating RobotManager instance") | ||
| return RobotManager() | ||
|
|
||
| @pytest.fixture(scope="module") | ||
| def simulation_manager(): | ||
| """Fixture to initialize and return a SimulationManager instance.""" | ||
| print("[Fixture] Creating SimulationManager instance") | ||
| return SimulationManager() | ||
|
|
||
| def test_simple_scenario(robot_manager, simulation_manager): | ||
| """Integration test for spawning, controlling, and deleting a robot.""" | ||
| rclpy.init() | ||
| node = rclpy.create_node("test_node") | ||
|
|
||
| world = "empty" | ||
| robot_name = "testbot" | ||
|
|
||
| print("[Action] Starting simulation...") | ||
| simulation_manager.start_simulation(world) | ||
|
|
||
| print(f"[Action] Spawning robot: {robot_name}") | ||
| robot_manager.add_robot(robot_name, 0, 0, 0, 0) | ||
| simulation_manager.spawn_robot(robot_name, 0, 0, 0, 0) | ||
|
|
||
| print("[Test] Checking for robot_description topic...") | ||
| wait_for_topic(node, f"/{robot_name}/robot_description", timeout=10.0) | ||
| print("[Result] Robot description topic is active") | ||
|
|
||
| print("[Test] Checking for control nodes...") | ||
| wait_for_node_with_namespace(node, "joint_state_broadcaster", f"/{robot_name}", timeout=10.0) | ||
| wait_for_node_with_namespace(node, "diff_drive_controller", f"/{robot_name}", timeout=10.0) | ||
| print("[Results] Control nodes are active") | ||
|
|
||
| print("[Action] Sending move command to the robot...") | ||
| publish_twist_stamped( | ||
| node, f"/{robot_name}/cmd_vel", x_vel=1.0, rot_vel=0.0) | ||
|
|
||
| print("[Test] Waiting for robot to reach the goal position...") | ||
| wait_for_goal_reached(node, robot_name, x=1.0, y=0.0, timeout=10.0) | ||
|
|
||
| print("[Action] Sending stop command to the robot...") | ||
| publish_twist_stamped( | ||
| node, f"/{robot_name}/cmd_vel", x_vel=0.0, rot_vel=0.0) | ||
|
|
||
| print("[Test] Verifying robot stopped...") | ||
| print("[Result] Robot control commands were successfully sent and executed") | ||
|
|
||
| print(f"[Action] Deleting robot: {robot_name}") | ||
| robot_manager.delete_robot(robot_name) | ||
|
|
||
| print("[Test] Verifying robot deletion...") | ||
| timeout = 2.0 | ||
| start_time = time.time() | ||
| while time.time() - start_time < timeout: | ||
| if robot_name not in robot_manager.get_robot_names(): | ||
| break | ||
| time.sleep(0.1) | ||
|
|
||
| remaining_robots = robot_manager.get_robot_names() | ||
| assert robot_name not in remaining_robots, ( | ||
| f"Robot '{robot_name}' was not properly deleted. Remaining robots: {remaining_robots}" | ||
| ) | ||
| print(f"[Result] Robot '{robot_name}' deleted successfully") | ||
|
|
||
| print("[Action] Stopping simulation...") | ||
| simulation_manager.stop_simulation() | ||
|
|
||
| rclpy.shutdown() | ||
|
|
||
| def test_cleanup(robot_manager, simulation_manager): | ||
| """Test to ensure RobotManager cleans up properly.""" | ||
| print("[Action] Cleaning up test...") | ||
| robot_manager.delete_robot("all") | ||
|
|
||
| remaining_robots = robot_manager.get_robot_names() | ||
| assert not remaining_robots, ( | ||
| f"RobotManager cleanup failed. Remaining robots: {remaining_robots}" | ||
| ) | ||
|
|
||
| simulation_manager.stop_simulation() | ||
| print("[Result] RobotManager cleaned up successfully") | ||
|
|
||
|
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.