Skip to content
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

Ros2 add components #277

Merged
merged 9 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion panther_bringup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ The package contains the default configuration and launch files necessary to sta
- `use_sim` [*bool*, default: **false**]: whether simulation is used.
- `user_led_animations_file` [*string*, default: **None**]: path to a YAML file with a description of the user defined animations.
- `wheel_config_path` [*string*, default: **$(find panther_description)/config/<wheel_type arg>.yaml**]: path to YAML file with wheel specification. Arguments become required if `wheel_type` is set to **custom**.
- `wheel_type` [*string*, default: **WH01**]: type of wheel, possible are: **WH01** - offroad, **WH02** - mecanum, **WH04** - small pneumatic, and **custom** - custom wheel types (requires setting `wheel_config_path` argument accordingly).
- `wheel_type` [*string*, default: **WH01**]: type of wheel, possible are: **WH01** - off-road, **WH02** - mecanum, **WH04** - small pneumatic, and **custom** - custom wheel types (requires setting `wheel_config_path` argument accordingly).
- `components_config_path` [*string*, default: **None**]: Additional components configuration file. Components described in this file are dynamically included in Panther's urdf. Panther options are described in [the manual](https://husarion.com/manuals/panther/panther-options. Example of configuration you can find [config/components.yaml](config/components.yaml)

[//]: # (ROS_API_PACKAGE_START)
[//]: # (ROS_API_PACKAGE_NAME_START)
Expand Down
25 changes: 25 additions & 0 deletions panther_bringup/config/components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# By default panther is loaded without any components.

components: []

# If you want to add for example LDR01, LDR06 and CAM01 to your Panther look at this example below:

# components:
# - type: LDR01
# parent_link: cover_link
# xyz: 0.0 0.1 0.0
# rpy: 0.0 0.0 0.0
# device_namespace: main_lidar

# - type: LDR06
# parent_link: cover_link
# xyz: 0.0 -0.1 0.0
# rpy: 0.0 0.0 0.0
# device_namespace: second_lidar

# - type: CAM01
# name: camera
# parent_link: cover_link
# xyz: 0.1 0.0 0.0
# rpy: 0.0 0.0 0.0
# device_namespace: front_cam
16 changes: 16 additions & 0 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,26 @@ def generate_launch_description():
"When set to False, users should publish their own robot description."
),
)

namespace = LaunchConfiguration("namespace")
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value=EnvironmentVariable("ROBOT_NAMESPACE", default_value=""),
description="Add namespace to all launched nodes.",
)

components_config_path = LaunchConfiguration("components_config_path")
declare_components_config_path_arg = DeclareLaunchArgument(
"components_config_path",
default_value="None",
description=(
"Additional components configuration file. Components described in this file "
"are dynamically included in Panther's urdf."
"Panther options are described here "
"https://husarion.com/manuals/panther/panther-options/"
),
)

# Get URDF via xacro
robot_description_content = Command(
[
Expand Down Expand Up @@ -129,6 +142,8 @@ def generate_launch_description():
os.environ.get("PANTHER_IMU_ORIENTATION_Y", "0.0"),
" namespace:=",
namespace,
" components_config_path:=",
components_config_path,
]
)
robot_description = {"robot_description": robot_description_content}
Expand Down Expand Up @@ -240,6 +255,7 @@ def generate_launch_description():
declare_simulation_engine_arg,
declare_publish_robot_state_arg,
declare_namespace_arg,
declare_components_config_path_arg,
SetParameter(name="use_sim_time", value=use_sim),
control_node,
robot_state_pub_node,
Expand Down
1 change: 0 additions & 1 deletion panther_description/urdf/gazebo.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@

<gazebo reference="${reference_frame}">
<sensor name="${ns}imu" type="imu">
<plugin filename="ignition-gazebo-imu-system" name="ignition::gazebo::systems::Imu" />
<always_on>true</always_on>
<update_rate>50</update_rate>
<topic>${ns}imu/data_raw</topic>
Expand Down
15 changes: 14 additions & 1 deletion panther_description/urdf/panther.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

<xacro:arg name="panther_version" default="1.0" />
<xacro:arg name="use_sim" default="false" />
<xacro:arg name="use_gpu" default="false" />
<!-- if lidars have to work correctly, use_gpu has to be true. -->
<xacro:arg name="use_gpu" default="true" />
<xacro:arg name="imu_pos_x" default="0.169" />
<xacro:arg name="imu_pos_y" default="0.025" />
<xacro:arg name="imu_pos_z" default="0.092" />
Expand Down Expand Up @@ -36,4 +37,16 @@
battery_config_file="$(arg battery_config_file)"
namespace="$(arg namespace)" />

<xacro:arg name="components_config_path" default="$(find panther_bringup)/config/components.yaml" />
<xacro:property name="components_config_path_property" value="$(arg components_config_path)" />

<xacro:unless value="${components_config_path_property == 'None'}">
<xacro:include filename="$(find ros_components_description)/urdf/components.urdf.xacro"
ns="husarion_components" />

<xacro:husarion_components.create_components
components_config_path="${components_config_path_property}"
namespace="$(arg namespace)"
/>
</xacro:unless>
</robot>
22 changes: 20 additions & 2 deletions panther_gazebo/launch/spawn.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def launch_setup(context):
gz_bridge = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
name="gz_bridge",
name="panther_base_gz_bridge",
parameters=[{"config_file": gz_bridge_config_path}],
namespace=robot_name,
output="screen",
Expand Down Expand Up @@ -116,6 +116,21 @@ def launch_setup(context):
}.items(),
)

gz_components = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[
FindPackageShare("ros_components_description"),
"launch",
"gz_components.launch.py",
]
)
),
launch_arguments={
"namespace": namespace,
}.items(),
)

ns_prefix = robot_name + "/" if robot_name else robot_name

world_transform = Node(
Expand All @@ -128,7 +143,9 @@ def launch_setup(context):
condition=IfCondition(add_world_transform),
)

# bringup.launch.py has a timerAction in it. If the timerAction in simulation.launch.py ​​is smaller than bringup.launch.py, the namespace will be overwritten, resulting creating nodes with the same namespace.
# bringup.launch.py has a timerAction in it. If the timerAction in simulation.launch.py
# ​​is smaller than bringup.launch.py, the namespace will be overwritten,
# resulting creating nodes with the same namespace.
group = TimerAction(
period=10.0 * idx,
actions=[
Expand All @@ -137,6 +154,7 @@ def launch_setup(context):
gz_bridge,
bringup_launch,
world_transform,
gz_components,
],
)
spawn_group.append(group)
Expand Down