-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROS2 example implementation Author: benvonh <[email protected]>
- Loading branch information
Showing
15 changed files
with
510 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,67 @@ | ||
# ROS2 Application - Instructions | ||
|
||
Minimal instructions to compile and run a CORC application as a ROS2 node able to publish the robot state. | ||
|
||
This page assumes you have an Ubuntu system with ROS2 Humble installed (may work with other ROS2 versions but not tested). See [here](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html) for ROS2 installation instructions. | ||
Testing the application also assumes you have an ExoMotus X2 Exoskeleton. | ||
|
||
|
||
> Note : these instructions are for ROS2. See [here](AdvancedSimulationAndHardwareTesting.md) for a ROS1 example. | ||
## Compilation | ||
|
||
|
||
```bash | ||
$ source /opt/ros/humble/setup.bash | ||
``` | ||
|
||
In CORC root directory, rename ros2 package configuration file | ||
```bash | ||
$ mv package.ros2.xml package.xml | ||
``` | ||
|
||
|
||
Edit the CMAKEFileList.txt to set ROS2 option and to select a ROS2 state machine: | ||
|
||
``` | ||
... | ||
... | ||
#set (STATE_MACHINE_NAME "ExoTestMachine") | ||
#set (STATE_MACHINE_NAME "M1DemoMachine") | ||
#set (STATE_MACHINE_NAME "M1DemoMachineROS") | ||
#set (STATE_MACHINE_NAME "M2DemoMachine") | ||
#set (STATE_MACHINE_NAME "M3DemoMachine") | ||
#set (STATE_MACHINE_NAME "X2DemoMachine") | ||
set (STATE_MACHINE_NAME "X2ROS2DemoMachine") | ||
#set (STATE_MACHINE_NAME "LoggingDevice") | ||
# Use this if your state machine code folder is not in CORC 'src/apps/' folder. | ||
# Can be a relative or absolute path. | ||
#set (STATE_MACHINE_PATH "../") | ||
# Comment to use actual hardware, uncomment for a nor robot (virtual) app | ||
set(NO_ROBOT OFF) | ||
# ROS Flag: set to 0 for a no ROS stateMachine, 1 for ROS 1 (use catkin build) and 2 for ROS2 (use colcon build) | ||
# Remember to rename select appropriate package.xml too | ||
set(ROS 2) | ||
... | ||
... | ||
``` | ||
|
||
|
||
From the **CANOpenController parent folder**, compile the package: | ||
```bash | ||
$ colcon build | ||
$ source install/setup.bash | ||
``` | ||
|
||
|
||
## Run the node | ||
```bash | ||
$ ros2 run CORC X2ROS2DemoMachine_APP | ||
``` | ||
|
||
Here CORC is the package name and the CORC app name is the executable name. | ||
|
||
See the content of the `src/apps/X2ROS2DemoMachine` folder to see how to interact with ROS2 from within CORC. |
This file contains 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,56 @@ | ||
import os | ||
|
||
from xacro import process_file | ||
from ament_index_python import get_package_share_directory | ||
|
||
from launch import LaunchDescription | ||
from launch_ros.actions import Node | ||
|
||
def generate_launch_description(): | ||
# Launch description | ||
ld = LaunchDescription() | ||
|
||
# Package share path | ||
corc_path = get_package_share_directory("CORC") | ||
x2_description_path = get_package_share_directory("x2_description") | ||
|
||
# Package share paths | ||
exo_path = os.path.join(corc_path, "config", "x2_params.yaml") | ||
rviz_path = os.path.join(x2_description_path, "rviz", "x2.rviz") | ||
|
||
# Process XACRO | ||
urdf_xacro = process_file( | ||
os.path.join(x2_description_path, "urdf", "x2_fixed_base.urdf.xacro") | ||
) | ||
|
||
# Nodes | ||
exo_node = Node( | ||
package="CORC", | ||
executable="X2ROS2DemoMachine_APP", | ||
arguments=["-can", "can0"], | ||
name="x2", | ||
output="screen", | ||
parameters=[ | ||
{ "exo_path": exo_path } | ||
] | ||
) | ||
robot_state_node = Node( | ||
package="robot_state_publisher", | ||
executable="robot_state_publisher", | ||
name="robot_state_publisher", | ||
parameters=[ | ||
{ "robot_description": urdf_xacro.toprettyxml(indent=' ') } | ||
] | ||
) | ||
rviz_node = Node( | ||
package="rviz2", | ||
executable="rviz2", | ||
arguments=["-d", rviz_path], | ||
name="rviz2" | ||
) | ||
|
||
# Launch description actions | ||
ld.add_action(exo_node) | ||
ld.add_action(robot_state_node) | ||
ld.add_action(rviz_node) | ||
return ld |
File renamed without changes.
This file contains 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,65 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<name>CORC</name> | ||
<version>1.0.0</version> | ||
<description>The CORC package</description> | ||
|
||
<!-- One maintainer tag required, multiple allowed, one person per tag --> | ||
<!-- Example: --> | ||
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> --> | ||
<maintainer email="[email protected]">Benjamin von Snarski</maintainer> | ||
|
||
|
||
<!-- One license tag required, multiple allowed, one license per tag --> | ||
<!-- Commonly used license strings: --> | ||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> | ||
<license>Apache 2</license> | ||
|
||
|
||
<!-- Url tags are optional, but multiple are allowed, one per tag --> | ||
<!-- Optional attribute type can be: website, bugtracker, or repository --> | ||
<!-- Example: --> | ||
<!-- <url type="website">http://wiki.ros.org/x2</url> --> | ||
|
||
|
||
<!-- Author tags are optional, multiple are allowed, one per tag --> | ||
<!-- Authors do not have to be maintainers, but could be --> | ||
<!-- Example: --> | ||
<!-- <author email="[email protected]">Jane Doe</author> --> | ||
|
||
|
||
<!-- The *depend tags are used to specify dependencies --> | ||
<!-- Dependencies can be catkin packages or system dependencies --> | ||
<!-- Examples: --> | ||
<!-- Use depend as a shortcut for packages that are both build and exec dependencies --> | ||
<!-- <depend>roscpp</depend> --> | ||
<!-- Note that this is equivalent to the following: --> | ||
<!-- <build_depend>roscpp</build_depend> --> | ||
<!-- <exec_depend>roscpp</exec_depend> --> | ||
<!-- Use build_depend for packages you need at compile time: --> | ||
<!-- <build_depend>message_generation</build_depend> --> | ||
<!-- Use build_export_depend for packages you need in order to build against this package: --> | ||
<!-- <build_export_depend>message_generation</build_export_depend> --> | ||
<!-- Use buildtool_depend for build tool packages: --> | ||
<!-- <buildtool_depend>catkin</buildtool_depend> --> | ||
<!-- Use exec_depend for packages you need at runtime: --> | ||
<!-- <exec_depend>message_runtime</exec_depend> --> | ||
<!-- Use test_depend for packages you need only for testing: --> | ||
<!-- <test_depend>gtest</test_depend> --> | ||
<!-- Use doc_depend for packages you need only for building documentation: --> | ||
<!-- <doc_depend>doxygen</doc_depend> --> | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<depend>rclcpp</depend> | ||
<depend>std_msgs</depend> | ||
<depend>sensor_msgs</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<!-- The export tag contains other, unspecified, tags --> | ||
<export> | ||
<!-- Other tools can request additional information be placed here --> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
Oops, something went wrong.