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 lynx sim #414

Merged
merged 19 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Launch arguments are largely common to both simulation and physical robot. Howev
| 🤖🖥️ | `use_sim` | Whether simulation is used. <br/> ***bool:*** `False` |
| 🤖🖥️ | `user_led_animations_file` | Path to a YAML file with a description of the user-defined animations. <br/> ***string:*** `''` |
| 🤖🖥️ | `wheel_config_path` | Path to wheel configuration file. <br/> ***string:*** [`{wheel_type}.yaml`](./panther_description/config) |
| 🤖🖥️ | `wheel_type` | Type of wheel. If you choose a value from the preset options ('WH01', 'WH02', 'WH04'), you can ignore the 'wheel_config_path' and 'controller_config_path' parameters. For custom wheels, please define these parameters to point to files that accurately describe the custom wheels. <br/> ***string:*** `WH01` (choices: `WH01`, `WH02`, `WH04`, `custom`) |
| 🤖🖥️ | `wheel_type` | Specify the wheel type. If the selected wheel type is not 'custom', the wheel_config_path and controller_config_path arguments will be automatically adjusted and can be omitted. <br/> ***string:*** `WH01` (choices: `WH01`, `WH02`, `WH04`, `custom`) |
| 🖥️ | `x` | Initial robot position in the global 'x' axis. <br/> ***float:*** `0.0` |
| 🖥️ | `y` | Initial robot position in the global 'y' axis. <br/> ***float:***` -2.0` |
| 🖥️ | `z` | Initial robot position in the global 'z' axis. <br/> ***float:*** `0.2` |
Expand Down
1 change: 1 addition & 0 deletions lynx_description/config/WH05.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ inertia: { ixx: 0.014738, iyy: 0.0261, izz: 0.014738 }
inertia_y_offset: 0.0
mesh_package: lynx_description
folder_path: meshes/WH05
mecanum: False
3 changes: 3 additions & 0 deletions lynx_description/urdf/gazebo.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<parameters>${config_file}</parameters>
<ros>
<namespace>${namespace}</namespace>
<remapping>gz_ros2_control/e_stop:=hardware/e_stop</remapping>
<remapping>gz_ros2_control/e_stop_reset:=hardware/e_stop_reset</remapping>
<remapping>gz_ros2_control/e_stop_trigger:=hardware/e_stop_trigger</remapping>
<remapping>imu_broadcaster/imu:=imu/data</remapping>
<remapping>drive_controller/cmd_vel_unstamped:=cmd_vel</remapping>
<remapping>drive_controller/odom:=odometry/wheels</remapping>
Expand Down
7 changes: 4 additions & 3 deletions lynx_description/urdf/lynx_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@
<ros2_control name="${ns}lynx_system" type="system">
<hardware>
<xacro:if value="${use_sim}">
<plugin>ign_ros2_control/IgnitionSystem</plugin>
<plugin>panther_gazebo/GzPantherSystem</plugin>
<param name="e_stop_initial_state">true</param>
</xacro:if>

<xacro:unless value="$(arg use_sim)">
<xacro:unless value="${use_sim}">
<plugin>panther_hardware_interfaces/PantherSystem</plugin>

<param name="encoder_resolution">1600</param>
Expand Down Expand Up @@ -140,7 +141,7 @@
</xacro:if>
</ros2_control>

<xacro:unless value="$(arg use_sim)">
<xacro:unless value="${use_sim}">
<ros2_control name="${ns}imu" type="sensor">
<hardware>
<plugin>panther_hardware_interfaces/PantherImuSensor</plugin>
Expand Down
7 changes: 4 additions & 3 deletions panther_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PathJoinSubstitution,
)
from launch_ros.substitutions import FindPackageShare
from panther_utils.welcomeMsg import welcomeMsg
from panther_utils.messages import welcome_msg


def generate_launch_description():
Expand All @@ -51,9 +51,10 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

robot_model = EnvironmentVariable("ROBOT_MODEL", default_value="panther")
KmakD marked this conversation as resolved.
Show resolved Hide resolved
serial_no = EnvironmentVariable(name="PANTHER_SERIAL_NO", default_value="----")
panther_version = EnvironmentVariable(name="PANTHER_ROBOT_VERSION", default_value="1.0")
KmakD marked this conversation as resolved.
Show resolved Hide resolved
welcome_msg = welcomeMsg(serial_no, panther_version)
welcome_info = welcome_msg(robot_model, serial_no, panther_version)

controller_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand Down Expand Up @@ -129,7 +130,7 @@ def generate_launch_description():
declare_disable_manager_arg,
declare_namespace_arg,
declare_use_ekf_arg,
welcome_msg,
welcome_info,
controller_launch,
system_monitor_launch,
delayed_action,
Expand Down
9 changes: 4 additions & 5 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ def generate_launch_description():
"wheel_type",
default_value="WH01",
description=(
"Type of wheel. If you choose a value from the preset options ('WH01', 'WH02',"
" 'WH04'), you can ignore the 'wheel_config_path' and 'controller_config_path'"
" parameters. For custom wheels, please define these parameters to point to files that"
" accurately describe the custom wheels."
"Specify the wheel type. If the selected wheel type is not 'custom', "
"the 'wheel_config_path' and 'controller_config_path' arguments will be "
"automatically adjusted and can be omitted."
),
choices=["WH01", "WH02", "WH04", "custom"],
choices=["WH01", "WH02", "WH04", "WH05", "custom"],
)

# Get URDF via xacro
Expand Down
7 changes: 3 additions & 4 deletions panther_description/launch/load_urdf.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ def generate_launch_description():
"wheel_type",
default_value="WH01",
description=(
"Type of wheel. If you choose a value from the preset options ('WH01', 'WH02',"
" 'WH04'), you can ignore the 'wheel_config_path' and 'controller_config_path'"
" parameters. For custom wheels, please define these parameters to point to files that"
" accurately describe the custom wheels."
"Specify the wheel type. If the selected wheel type is not 'custom', "
"the 'wheel_config_path' and 'controller_config_path' arguments will be "
"automatically adjusted and can be omitted."
KmakD marked this conversation as resolved.
Show resolved Hide resolved
),
choices=["WH01", "WH02", "WH04", "custom"],
)
Expand Down
4 changes: 2 additions & 2 deletions panther_description/urdf/panther_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<param name="e_stop_initial_state">true</param>
</xacro:if>

<xacro:unless value="$(arg use_sim)">
<xacro:unless value="${use_sim}">
<plugin>panther_hardware_interfaces/PantherSystem</plugin>

<param name="panther_version">${panther_version}</param>
Expand Down Expand Up @@ -143,7 +143,7 @@
</xacro:if>
</ros2_control>

<xacro:unless value="$(arg use_sim)">
<xacro:unless value="${use_sim}">
<ros2_control name="${ns}imu" type="sensor">
<hardware>
<plugin>panther_hardware_interfaces/PantherImuSensor</plugin>
Expand Down
16 changes: 16 additions & 0 deletions panther_gazebo/config/configuration.yaml
KmakD marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The minimal configuration file with the default values.
# namespace is optional - without this element namespace will not be provided.

# namespace:
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved
# robot_model: panther
# init_pose: [0.0, 0.0, 0.0]
# init_rotation: [0.0, 0.0, 0.0]
# configuration:
# wheel_type: WH01

panther:
robot_model: panther
init_pose: [0.0, -2.0, 0.0]
init_rotation: [0.0, 0.0, 0.0]
configuration:
wheel_type: WH01
122 changes: 0 additions & 122 deletions panther_gazebo/launch/simulate_multiple_robots.launch.py

This file was deleted.

27 changes: 17 additions & 10 deletions panther_gazebo/launch/simulate_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@
from launch.conditions import IfCondition, UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
EnvironmentVariable,
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node, SetUseSimTime
from launch_ros.substitutions import FindPackageShare
from nav2_common.launch import ReplaceString
from panther_utils.arguments import DeclareRobotArgs


def generate_launch_description():

components_config_path = LaunchConfiguration("components_config_path")
gz_bridge_config_path = LaunchConfiguration("gz_bridge_config_path")
namespace = LaunchConfiguration("namespace")
KmakD marked this conversation as resolved.
Show resolved Hide resolved
robot_configuration = LaunchConfiguration("robot_configuration")
robot_model = LaunchConfiguration("robot_model")
use_ekf = LaunchConfiguration("use_ekf")

declare_battery_config_path_arg = DeclareLaunchArgument(
"battery_config_path",
description=(
Expand All @@ -42,7 +49,6 @@ def generate_launch_description():
),
)

components_config_path = LaunchConfiguration("components_config_path")
declare_components_config_path_arg = DeclareLaunchArgument(
"components_config_path",
default_value=PathJoinSubstitution(
Expand All @@ -56,7 +62,6 @@ def generate_launch_description():
),
)

gz_bridge_config_path = LaunchConfiguration("gz_bridge_config_path")
declare_gz_bridge_config_path_arg = DeclareLaunchArgument(
"gz_bridge_config_path",
default_value=PathJoinSubstitution(
Expand All @@ -65,14 +70,14 @@ def generate_launch_description():
description="Path to the parameter_bridge configuration file.",
)

namespace = LaunchConfiguration("namespace")
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value=EnvironmentVariable("ROBOT_NAMESPACE", default_value=""),
description="Add namespace to all launched nodes.",
declare_robot_configuration_arg = DeclareLaunchArgument(
"robot_configuration",
default_value=PathJoinSubstitution(
[FindPackageShare("panther_gazebo"), "config", "configuration.yaml"]
),
description="Path to robot configuration YAML file.",
)
KmakD marked this conversation as resolved.
Show resolved Hide resolved

use_ekf = LaunchConfiguration("use_ekf")
declare_use_ekf_arg = DeclareLaunchArgument(
"use_ekf",
default_value="True",
Expand All @@ -89,6 +94,7 @@ def generate_launch_description():
launch_arguments={
"add_wheel_joints": "False",
"namespace": namespace,
"robot_model": robot_model,
"use_sim": "True",
}.items(),
)
Expand Down Expand Up @@ -187,10 +193,11 @@ def generate_launch_description():

return LaunchDescription(
[
declare_robot_configuration_arg,
DeclareRobotArgs(robot_configuration),
declare_battery_config_path_arg,
declare_components_config_path_arg,
declare_gz_bridge_config_path_arg,
declare_namespace_arg,
declare_use_ekf_arg,
SetUseSimTime(True),
spawn_robot_launch,
Expand Down
Loading