From ae7fdb7e753068ef737a326ecac9a7dbb0c8963a Mon Sep 17 00:00:00 2001 From: harleylara Date: Fri, 9 Feb 2024 01:52:11 +0100 Subject: [PATCH 1/6] add dependencies --- solo12_bringup/package.xml | 1 + solo12_description/package.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/solo12_bringup/package.xml b/solo12_bringup/package.xml index 3a64a90..bda1249 100644 --- a/solo12_bringup/package.xml +++ b/solo12_bringup/package.xml @@ -16,6 +16,7 @@ launch_ros gazebo_ros ros2_control + gazebo_ros2_control robot_state_publisher rviz diff --git a/solo12_description/package.xml b/solo12_description/package.xml index ad7c94f..74638ab 100644 --- a/solo12_description/package.xml +++ b/solo12_description/package.xml @@ -16,7 +16,9 @@ launch_ros joint_state_publisher_gui joint_state_publisher + joint_state_broadcaster robot_state_publisher + controller_manager ament_lint_auto ament_lint_common From 55a59a7548a57a7afbeb8431a1a56f5af16b77bb Mon Sep 17 00:00:00 2001 From: harleylara Date: Fri, 9 Feb 2024 01:52:31 +0100 Subject: [PATCH 2/6] minimal controller working --- solo12_bringup/launch/robot.launch.py | 20 ++++++++++++++++++- .../config/solo12_controllers.yaml | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/solo12_bringup/launch/robot.launch.py b/solo12_bringup/launch/robot.launch.py index 71f8100..912a4d9 100644 --- a/solo12_bringup/launch/robot.launch.py +++ b/solo12_bringup/launch/robot.launch.py @@ -40,6 +40,14 @@ def generate_launch_description(): ] ) + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare("solo12_description"), + "config", + "solo12_controllers.yaml" + ] + ) + # Get URDF path urdf_path = os.path.join( get_package_share_directory("solo12_description"), @@ -93,7 +101,7 @@ def generate_launch_description(): ] ), launch_arguments={ - "extra_gazebo_args": f"--ros-args --params-file {gazebo_configuration}" + # "extra_gazebo_args": f"--ros-args --params-file {gazebo_configuration.perform}" # Harley: fix path substitution }.items() ) @@ -115,6 +123,15 @@ def generate_launch_description(): parameters=[{"use_sim_time": True}] ) + ros2_control_node = Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[ + robot_controllers + ], + output="both" + ) + robot_state_pub_node = Node( package="robot_state_publisher", @@ -151,6 +168,7 @@ def generate_launch_description(): robot_state_pub_node, spawn_entity_node, spawn_stand, + ros2_control_node, joint_state_broadcaster_spawner, delay_rviz ] diff --git a/solo12_description/config/solo12_controllers.yaml b/solo12_description/config/solo12_controllers.yaml index 9b7733d..fc193cb 100644 --- a/solo12_description/config/solo12_controllers.yaml +++ b/solo12_description/config/solo12_controllers.yaml @@ -1,6 +1,6 @@ controller_manager: ros__parameters: - update_rate: 30 + update_rate: 500 use_sim_time: true joint_state_broadcaster: type: joint_state_broadcaster/JointStateBroadcaster From 0c65c931857d9f8eefb077b7a08305b5f6610c34 Mon Sep 17 00:00:00 2001 From: harleylara Date: Fri, 9 Feb 2024 16:03:34 +0100 Subject: [PATCH 3/6] add controller to launch --- solo12_bringup/launch/robot.launch.py | 3 ++- solo12_description/urdf/solo12.ros2_control.xacro | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/solo12_bringup/launch/robot.launch.py b/solo12_bringup/launch/robot.launch.py index 912a4d9..c08c179 100644 --- a/solo12_bringup/launch/robot.launch.py +++ b/solo12_bringup/launch/robot.launch.py @@ -129,7 +129,8 @@ def generate_launch_description(): parameters=[ robot_controllers ], - output="both" + output="both", + emulate_tty=True ) diff --git a/solo12_description/urdf/solo12.ros2_control.xacro b/solo12_description/urdf/solo12.ros2_control.xacro index ae2b7fe..98b966a 100644 --- a/solo12_description/urdf/solo12.ros2_control.xacro +++ b/solo12_description/urdf/solo12.ros2_control.xacro @@ -6,50 +6,62 @@ gazebo_ros2_control/GazeboSystem + + + + + + + + + + + + From c80ef1aefad1af5c3e5eaeabc2c354ae535c1da4 Mon Sep 17 00:00:00 2001 From: harleylara Date: Mon, 12 Feb 2024 03:15:04 +0100 Subject: [PATCH 4/6] add functions to use opaque functions --- .../launch/test_solo12_description.launch.py | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/solo12_description/launch/test_solo12_description.launch.py b/solo12_description/launch/test_solo12_description.launch.py index 603e11b..5a9c549 100644 --- a/solo12_description/launch/test_solo12_description.launch.py +++ b/solo12_description/launch/test_solo12_description.launch.py @@ -1,13 +1,30 @@ import os import xacro from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument +from launch.actions import DeclareLaunchArgument, OpaqueFunction from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare from ament_index_python.packages import get_package_share_directory +from launch.utilities import perform_substitutions -def generate_launch_description(): +def launch_args(context): + + declared_arguments = [] + + declared_arguments.append( + DeclareLaunchArgument( + "use_sim_time", + default_value="true", + ) + ) + + return declared_arguments + + +def launch_setup(context): + + use_sim_time = LaunchConfiguration("use_sim_time") package_name = "solo12_description" @@ -27,7 +44,7 @@ def generate_launch_description(): package="robot_state_publisher", executable="robot_state_publisher", output="both", - parameters=[robot_description, {"use_sim_time": True}], + parameters=[robot_description, {"use_sim_time": use_sim_time}], ) rviz_node = Node( @@ -38,10 +55,18 @@ def generate_launch_description(): arguments=["-d", rviz_config_file] ) - return LaunchDescription( - [ + return [ joint_state_publisher_node, robot_state_publisher_node, rviz_node, ] - ) + +def generate_launch_description(): + + ld = LaunchDescription() + + ld.add_action(OpaqueFunction(function=launch_args)) + + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld From 9915258bebbbf8abf99c88f9da64576857f0a774 Mon Sep 17 00:00:00 2001 From: harleylara Date: Mon, 12 Feb 2024 03:16:16 +0100 Subject: [PATCH 5/6] add `use_sim` arguments to allow dynamic interface usage --- .../urdf/solo12.ros2_control.xacro | 161 ++++++++++-------- solo12_description/urdf/solo12.urdf.xacro | 5 + 2 files changed, 96 insertions(+), 70 deletions(-) diff --git a/solo12_description/urdf/solo12.ros2_control.xacro b/solo12_description/urdf/solo12.ros2_control.xacro index 98b966a..6996ac8 100644 --- a/solo12_description/urdf/solo12.ros2_control.xacro +++ b/solo12_description/urdf/solo12.ros2_control.xacro @@ -1,76 +1,97 @@ - - - gazebo_ros2_control/GazeboSystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - $(find solo12_description)/config/solo12_controllers.yaml - - + + + + + + gazebo_ros2_control/GazeboSystem + + + + + placeholder_namespace/PlaceHolderClass + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(find solo12_description)/config/solo12_controllers.yaml + + + + + diff --git a/solo12_description/urdf/solo12.urdf.xacro b/solo12_description/urdf/solo12.urdf.xacro index e0ca44b..cdef181 100644 --- a/solo12_description/urdf/solo12.urdf.xacro +++ b/solo12_description/urdf/solo12.urdf.xacro @@ -5,6 +5,8 @@ xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:xacro="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"> + + @@ -12,6 +14,9 @@ + + From b727b535629b9373cde0875cc2245bfa03060d82 Mon Sep 17 00:00:00 2001 From: harleylara Date: Mon, 12 Feb 2024 03:16:54 +0100 Subject: [PATCH 6/6] refactor launch system --- README.md | 10 +- solo12_bringup/README.md | 53 +++++ solo12_bringup/launch/controllers.launch.py | 62 +++++ solo12_bringup/launch/robot.launch.py | 218 +++++++----------- solo12_bringup/launch/sim_gazebo.launch.py | 132 +++++++++++ solo12_bringup/launch/start_rviz.launch.py | 40 ++++ .../launch/state_publisher.launch.py | 58 +++++ solo12_examples/CMakeLists.txt | 33 +++ solo12_examples/package.xml | 18 ++ solo12_examples/src/minimal.cpp | 7 + 10 files changed, 490 insertions(+), 141 deletions(-) create mode 100644 solo12_bringup/README.md create mode 100644 solo12_bringup/launch/controllers.launch.py create mode 100644 solo12_bringup/launch/sim_gazebo.launch.py create mode 100644 solo12_bringup/launch/start_rviz.launch.py create mode 100644 solo12_bringup/launch/state_publisher.launch.py create mode 100644 solo12_examples/CMakeLists.txt create mode 100644 solo12_examples/package.xml create mode 100644 solo12_examples/src/minimal.cpp diff --git a/README.md b/README.md index 42944cb..83a7c8a 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,7 @@ To launch the system use: ros2 launch solo12_bringup robot.launch.py ``` -Launch arguments: -- `stand`: Spawn robot on stand (default true). -- `use_rviz`: Run rviz (default true). - -Example: - -``` -ros2 launch solo12_bringup robot.launch.py stand:=true use_rviz:=false -``` +to get more details of the availables launch arguments see [solo12_bringup](./solo12_bringup/README.md) package. ## Packages diff --git a/solo12_bringup/README.md b/solo12_bringup/README.md new file mode 100644 index 0000000..73d7156 --- /dev/null +++ b/solo12_bringup/README.md @@ -0,0 +1,53 @@ +# `solo12_bringup` + +This is the main package to launch all the components. + +## Usage: `robot.launch.py` + +To launch the full system is `robot.launch.py`, example: + +```bash +ros2 launch solo12_bringup robot.launch.py +``` + +Launch arguments: +- `use_sim`: Start Gazebo (default true), otherwise start hardware. +- `start_rviz`: Run rviz (default true). +- `rviz_config_file`: Custom rviz config file (default `solo12_description/rviz/solo12.rviz`) +- `robot_name`: Robot name (default "solo12"). For now just set the gazebo entity name, but this can be used later to spawn multiples robot. +- `stand`: Spawn robot on stand (default true). + +Example: + +``` +ros2 launch solo12_bringup robot.launch.py stand:=true use_rviz:=false +``` + +## `state_publisher.launch.py` + +This launch file is the **main and only** source for the robot_description. If you want to make use of the `robot_description`, please subscribe to the topic `/robot_description`. + +Launch arguments: +- `use_sim_time`: Sync ros and gazebo time (default true) + +## `controllers.launch.py` + +Launch all the components related with `ros2_control`. + +Launch arguments: +- `use_sim_time`: Sync ros and gazebo time (default true) + +## `sim_gazebo.launch.py` + +Start the gazebo simulation environment. Spawn the robot and the stand. + +Launch arguments: +- `stand`: spawn stand model into gazebo (default true). +- `robot_name`: robot entity name in gazebo (default "solo12") + +## `start_rviz.launch.py` + +Start rviz. + +Launch arguments: +- `rviz_config_file`: Custom cofiguration file to start rviz (no default value) diff --git a/solo12_bringup/launch/controllers.launch.py b/solo12_bringup/launch/controllers.launch.py new file mode 100644 index 0000000..29e9270 --- /dev/null +++ b/solo12_bringup/launch/controllers.launch.py @@ -0,0 +1,62 @@ +from launch import LaunchDescription +from launch.actions import OpaqueFunction, DeclareLaunchArgument +from launch.substitutions import PathJoinSubstitution, LaunchConfiguration +from launch_ros.substitutions import FindPackageShare +from launch_ros.actions import Node + +def launch_args(context): + + declared_args = [] + + declared_args.append( + DeclareLaunchArgument( + "use_sim_time", + default_value="true" + ) + ) + + return declared_args + + +def launch_setup(context): + + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare("solo12_description"), + "config", + "solo12_controllers.yaml" + ] + ) + + ros2_control_node = Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[ + robot_controllers + ], + output="both", + emulate_tty=True + ) + + joint_state_broadcaster_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], + parameters=[{"use_sim_time": LaunchConfiguration("use_sim_time")}] + ) + + return [ + ros2_control_node, + joint_state_broadcaster_spawner + ] + + +def generate_launch_description(): + + ld = LaunchDescription() + + ld.add_action(OpaqueFunction(function=launch_args)) + + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld diff --git a/solo12_bringup/launch/robot.launch.py b/solo12_bringup/launch/robot.launch.py index c08c179..0ec8fdf 100644 --- a/solo12_bringup/launch/robot.launch.py +++ b/solo12_bringup/launch/robot.launch.py @@ -1,176 +1,130 @@ -import os -import xacro -from launch.event_handlers import OnProcessExit -from launch.launch_context import LaunchContext from launch import LaunchDescription +from launch.actions import OpaqueFunction, DeclareLaunchArgument, IncludeLaunchDescription from launch.conditions import IfCondition -from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution -from launch_ros.actions import Node +from launch.substitutions import PathJoinSubstitution, LaunchConfiguration from launch_ros.substitutions import FindPackageShare -from ament_index_python.packages import get_package_share_directory -def generate_launch_description(): +def launch_args(context): - declared_arguments = [] + declared_args = [] - declared_arguments.append( + declared_args.append( DeclareLaunchArgument( - "use_rviz", + "use_sim", default_value="true", - description="Start RViz2 automatically with this launch file.") + description="Start robot in simulation, otherwise launch for physical hardware." + ) ) - declared_arguments.append( + declared_args.append( DeclareLaunchArgument( - "stand", + "start_rviz", default_value="true", - description="Spawn stand for the robot." + description="Start RViz2 automatically with this launch file." ) ) - use_rviz = LaunchConfiguration("use_rviz") - stand_arg = LaunchConfiguration("stand") - - rviz_config_file = PathJoinSubstitution( - [ - FindPackageShare("solo12_description"), - "rviz", - "solo12.rviz" - ] - ) - - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare("solo12_description"), - "config", - "solo12_controllers.yaml" - ] - ) - - # Get URDF path - urdf_path = os.path.join( - get_package_share_directory("solo12_description"), - 'urdf', - 'solo12.urdf.xacro' - ) - - # Spawn stand as a different entity. - # - # The first part of the command parse the urdf file - # using the `xacro` command, this is required to resolved - # the path of the meshes in the urdf file. - # The second part use the `spawn_entity.py` node with - # the option `-stdin` that get the urdf from the standard - # input. - spawn_stand = ExecuteProcess( - cmd=[ - "xacro", - PathJoinSubstitution( + declared_args.append( + DeclareLaunchArgument( + "rviz_config_file", + default_value=PathJoinSubstitution( [ FindPackageShare("solo12_description"), - "urdf", - "stand.urdf" + "rviz", + "solo12.rviz" ] ), - "|", - "ros2", "run", "gazebo_ros", "spawn_entity.py", "-stdin", "-entity", "stand" - ], - output="both", - shell=True, - condition=IfCondition(stand_arg) + description="Cofiguration file for rviz" + ) ) - # robot description parameter composition - robot_description = {"robot_description": xacro.process_file(urdf_path).toxml()} + declared_args.append( + DeclareLaunchArgument( + "robot_name", + default_value="solo12", + description="Robot name." + ) + ) - gazebo_configuration = PathJoinSubstitution( - [ - FindPackageShare("solo12_description"), - "config", - "gazebo.yaml" - ] + declared_args.append( + DeclareLaunchArgument( + "stand", + default_value="true", + description="Spawn the robot in a stand." + ) ) - gazebo = IncludeLaunchDescription( + return declared_args + +def launch_setup(context): + + state_publisher = IncludeLaunchDescription( PathJoinSubstitution( [ - FindPackageShare("gazebo_ros"), + FindPackageShare("solo12_bringup"), "launch", - "gazebo.launch.py" + "state_publisher.launch.py" ] ), launch_arguments={ - # "extra_gazebo_args": f"--ros-args --params-file {gazebo_configuration.perform}" # Harley: fix path substitution + "use_sim_time": LaunchConfiguration("use_sim") }.items() ) - spawn_entity_node = Node( - package="gazebo_ros", - executable="spawn_entity.py", - name="spawn_entity", - arguments=['-topic', "robot_description", - "-x", "0.0", - "-y", "0.0", - "-z", "0.54", - "-entity", "solo12"] + sim_gazebo = IncludeLaunchDescription( + PathJoinSubstitution( + [ + FindPackageShare("solo12_bringup"), + "launch", + "sim_gazebo.launch.py" + ] + ), + launch_arguments={ + "robot_name": LaunchConfiguration("robot_name"), + "stand": LaunchConfiguration("stand") + }.items(), + condition=IfCondition(LaunchConfiguration("use_sim")) ) - joint_state_broadcaster_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], - parameters=[{"use_sim_time": True}] + controllers = IncludeLaunchDescription( + PathJoinSubstitution( + [ + FindPackageShare("solo12_bringup"), + "launch", + "controllers.launch.py" + ] + ), + launch_arguments={ + "use_sim_time": LaunchConfiguration("use_sim") + }.items() ) - ros2_control_node = Node( - package="controller_manager", - executable="ros2_control_node", - parameters=[ - robot_controllers - ], - output="both", - emulate_tty=True + rviz = IncludeLaunchDescription( + PathJoinSubstitution( + [ + FindPackageShare("solo12_bringup"), + "launch", + "start_rviz.launch.py", + ] + ), + launch_arguments={ + "rviz_config_file": LaunchConfiguration("rviz_config_file") + }.items(), ) + return [ + state_publisher, + sim_gazebo, + controllers, + rviz + ] - robot_state_pub_node = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - output="both", - parameters=[ - robot_description, - {"use_sim_time": True} - ], - ) +def generate_launch_description(): - rviz_node = Node( - package="rviz2", - executable="rviz2", - name="rviz2", - output="log", - arguments=["-d", rviz_config_file], - condition=IfCondition(use_rviz) - ) + ld = LaunchDescription() - # Delay rviz start after `joint_state_broadcaster` - delay_rviz = RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[rviz_node], - ) - ) + ld.add_action(OpaqueFunction(function=launch_args)) + ld.add_action(OpaqueFunction(function=launch_setup)) - return LaunchDescription( - declared_arguments + - [ - gazebo, - robot_state_pub_node, - spawn_entity_node, - spawn_stand, - ros2_control_node, - joint_state_broadcaster_spawner, - delay_rviz - ] - ) + return ld diff --git a/solo12_bringup/launch/sim_gazebo.launch.py b/solo12_bringup/launch/sim_gazebo.launch.py new file mode 100644 index 0000000..f04408e --- /dev/null +++ b/solo12_bringup/launch/sim_gazebo.launch.py @@ -0,0 +1,132 @@ +from launch import LaunchDescription +from launch.event_handlers import OnProcessExit +from launch.conditions import IfCondition, UnlessCondition +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch.actions import OpaqueFunction, DeclareLaunchArgument, IncludeLaunchDescription, RegisterEventHandler, ExecuteProcess +from launch_ros.substitutions import FindPackageShare +from launch_ros.actions import Node + +def launch_args(context): + """ + Launch arguments definition using an "opaque function" + to be able to later evaluate the launch argument at runtime. + """ + + declared_args = [] + + declared_args.append( + DeclareLaunchArgument( + "stand", + default_value="true", + description="Spawn stand for the robot." + ) + ) + + declared_args.append( + DeclareLaunchArgument( + "robot_name", + default_value="solo12", + description="Robot name." + ) + ) + + return declared_args + +def launch_setup(context): + """ + Launch setup with access to `LaunchContext` to be able to read + launch arguments at runtime. + """ + + gazebo_configuration = PathJoinSubstitution( + [ + FindPackageShare("solo12_description"), + "config", + "gazebo.yaml" + ] + ) + + launch_gazebo = IncludeLaunchDescription( + PathJoinSubstitution( + [ + FindPackageShare("gazebo_ros"), + "launch", + "gazebo.launch.py" + ] + ), + launch_arguments={ + "extra_gazebo_args": f"--ros-args --params-file {gazebo_configuration.perform(context)}" + }.items(), + ) + + spawn_stand = ExecuteProcess( + cmd=[ + "xacro", + PathJoinSubstitution( + [ + FindPackageShare("solo12_description"), + "urdf", + "stand.urdf" + ] + ), + "|", + "ros2", "run", "gazebo_ros", "spawn_entity.py", "-stdin", "-entity", "stand" + ], + output="both", + shell=True, + condition=IfCondition(LaunchConfiguration("stand")) + ) + + # subscribe to the `/robot_description` topic to wait for the robot definition. + # this node spawn the robot wen + # this node is launched only when the argument `stand` is false (just the robot in gazebo). + only_spawn_solo_robot = Node( + package="gazebo_ros", + executable="spawn_entity.py", + name="spawn_entity", + arguments=['-topic', "robot_description", + "-x", "0.0", + "-y", "0.0", + "-z", "0.54", + "-entity", "solo12"], + condition=UnlessCondition(LaunchConfiguration("stand")) + ) + + + # If `stand`, launch this node. Used with `delay_spawn_solo_robot` + # Spawn the stand first and then the robot + spawn_solo_robot = Node( + package="gazebo_ros", + executable="spawn_entity.py", + name="spawn_entity", + arguments=['-topic', "robot_description", + "-x", "0.0", + "-y", "0.0", + "-z", "0.54", + "-entity", LaunchConfiguration("robot_name")], + ) + + delay_spawn_solo_robot = RegisterEventHandler( + event_handler=OnProcessExit( + target_action=spawn_stand, + on_exit=[spawn_solo_robot], + ) + ) + + return [ + launch_gazebo, + spawn_stand, + only_spawn_solo_robot, + delay_spawn_solo_robot + ] + + +def generate_launch_description(): + + ld = LaunchDescription() + + ld.add_action(OpaqueFunction(function=launch_args)) + + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld diff --git a/solo12_bringup/launch/start_rviz.launch.py b/solo12_bringup/launch/start_rviz.launch.py new file mode 100644 index 0000000..7960d4e --- /dev/null +++ b/solo12_bringup/launch/start_rviz.launch.py @@ -0,0 +1,40 @@ +from launch import LaunchDescription +from launch.actions import OpaqueFunction, DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + +def launch_args(context): + + declared_args = [] + + declared_args.append( + DeclareLaunchArgument( + "rviz_config_file" + ) + ) + + return + +def launch_setup(context): + + rviz_node = Node( + package="rviz2", + executable="rviz2", + name="rviz2", + output="both", + arguments=["-d", LaunchConfiguration("rviz_config_file")], + ) + + return [ + rviz_node + ] + +def generate_launch_description(): + + ld = LaunchDescription() + + ld.add_action(OpaqueFunction(function=launch_args)) + + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld diff --git a/solo12_bringup/launch/state_publisher.launch.py b/solo12_bringup/launch/state_publisher.launch.py new file mode 100644 index 0000000..72dce44 --- /dev/null +++ b/solo12_bringup/launch/state_publisher.launch.py @@ -0,0 +1,58 @@ +import xacro +from launch import LaunchDescription +from launch.actions import OpaqueFunction, DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + +def launch_args(context): + + declared_args = [] + + declared_args.append( + DeclareLaunchArgument( + "use_sim_time", + default_value="true" + ) + ) + + return declared_args + +def launch_setup(context): + + robot_description_content = xacro.process_file( + PathJoinSubstitution( + [ + FindPackageShare("solo12_description"), + "urdf", + "solo12.urdf.xacro" + ] + ).perform(context), + mappings={ + "use_sim_time": LaunchConfiguration("use_sim_time").perform(context) + } + ).toxml() + + robot_state_publiser_node = Node( + package="robot_state_publisher", + executable="robot_state_publisher", + output="both", + parameters=[ + {"robot_description": robot_description_content}, + {"use_sim_time": LaunchConfiguration("use_sim_time")} + ] + ) + + return [ + robot_state_publiser_node + ] + +def generate_launch_description(): + + ld = LaunchDescription() + + ld.add_action(OpaqueFunction(function=launch_args)) + + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld diff --git a/solo12_examples/CMakeLists.txt b/solo12_examples/CMakeLists.txt new file mode 100644 index 0000000..3555166 --- /dev/null +++ b/solo12_examples/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.8) +project(solo12_examples) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_executable(minimal src/minimal.cpp) +# ament_target_dependencies(talker rclcpp std_msgs) + +install(TARGETS + minimal + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/solo12_examples/package.xml b/solo12_examples/package.xml new file mode 100644 index 0000000..3006493 --- /dev/null +++ b/solo12_examples/package.xml @@ -0,0 +1,18 @@ + + + + solo12_examples + 0.0.0 + TODO: Package description + harley + TODO: License declaration + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/solo12_examples/src/minimal.cpp b/solo12_examples/src/minimal.cpp new file mode 100644 index 0000000..42a522f --- /dev/null +++ b/solo12_examples/src/minimal.cpp @@ -0,0 +1,7 @@ +#include + +int main(int argc, char * argv[]) +{ + std::cout << "test"; + return 0; +}