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 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ Launch arguments are largely common to both simulation and physical robot. Howev
| 🤖🖥️ | `localization_mode` | Specifies the localization mode: <br/>- 'relative' `odometry/filtered` data is relative to the initial position and orientation. <br/>- 'enu' `odometry/filtered` data is relative to initial position and ENU (East North Up) orientation. <br/> ***string:*** `relative` (choices: `relative`, `enu`) |
| 🤖🖥️ | `namespace` | Add namespace to all launched nodes. <br/> ***string:*** `env(ROBOT_NAMESPACE)` |
| 🤖🖥️ | `publish_robot_state` | Whether to publish the default Panther robot description. <br/> ***bool:*** `True` |
| 🖥️ | `robots` | The list of the robots spawned in the simulation e.g. `robots:='robot1={x: 1.0, y: -2.0}; robot2={x: 1.0, y: -4.0}'` <br/> ***string:*** `''` |
| 🖥️ | `robot_model` | Specify robot model type. <br/> ***string:*** `env(ROBOT_MODEL)` if not specified `panther` (choices: `lynx`, `panther`) |
| 🤖🖥️ | `safety_bt_project_path` | Path to BehaviorTree project file, responsible for safety and shutdown management. <br/> ***string:*** [`PantherSafetyBT.btproj`](./panther_manager/behavior_trees/PantherSafetyBT.btproj) |
| 🤖🖥️ | `shutdown_hosts_config_path` | Path to file with list of hosts to request shutdown. <br/> ***string:*** [`shutdown_hosts_config.yaml`](./panther_manager/config/shutdown_hosts_config.yaml) |
| 🤖🖥️ | `use_ekf` | Enable or disable EKF. <br/> ***bool:*** `True` |
| 🤖🖥️ | `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` (for Panther), `WH05` (for Lynx) (choices: `WH01`, `WH02`, `WH04`, `WH05`, `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` |
| 🖥️ | `z` | Initial robot position in the global 'z' axis. <br/> ***float:*** `0.0` |
| 🖥️ | `roll` | Initial robot 'roll' orientation. <br/> ***float:*** `0.0` |
| 🖥️ | `pitch` | Initial robot 'pitch' orientation. <br/> ***float:*** `0.0` |
| 🖥️ | `yaw` | Initial robot 'yaw' orientation. <br/> ***float:*** `0.0` |
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
11 changes: 5 additions & 6 deletions lynx_description/launch/load_urdf.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def generate_launch_description():
),
)

wheel_type = LaunchConfiguration("wheel_type") # wheel_type is used by controller_config_path
wheel_type = LaunchConfiguration("wheel_type")
controller_config_path = LaunchConfiguration("controller_config_path")
declare_controller_config_path_arg = DeclareLaunchArgument(
"controller_config_path",
Expand Down Expand Up @@ -99,6 +99,7 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
declare_wheel_config_path_arg = DeclareLaunchArgument(
"wheel_config_path",
default_value=PathJoinSubstitution(
Expand All @@ -115,15 +116,13 @@ def generate_launch_description():
),
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
declare_wheel_type_arg = DeclareLaunchArgument(
"wheel_type",
default_value="WH05",
description=(
"Type of wheel. If you choose a value from the preset options ('WH05'), 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=["WH05", "custom"],
)
Expand Down
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
5 changes: 3 additions & 2 deletions lynx_description/urdf/lynx_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
<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)">
Expand Down Expand Up @@ -139,7 +140,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
14 changes: 9 additions & 5 deletions panther_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, TimerAction
from launch.conditions import IfCondition, UnlessCondition
Expand All @@ -24,7 +26,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 +53,11 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

serial_no = EnvironmentVariable(name="PANTHER_SERIAL_NO", default_value="----")
panther_version = EnvironmentVariable(name="PANTHER_ROBOT_VERSION", default_value="1.0")
welcome_msg = welcomeMsg(serial_no, panther_version)
robot_model = os.environ.get("ROBOT_MODEL", default="PTH")
robot_model = "lynx" if robot_model == "LNX" else "panther"
robot_serial_no = EnvironmentVariable(name="ROBOT_SERIAL_NO", default_value="----")
robot_version = EnvironmentVariable(name="ROBOT_VERSION", default_value="1.0")
welcome_info = welcome_msg(robot_model, robot_serial_no, robot_version)

controller_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand Down Expand Up @@ -129,7 +133,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
31 changes: 20 additions & 11 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def generate_launch_description():
),
)

wheel_type = LaunchConfiguration(
"wheel_type"
) # wheel_type must be before controller_config_path
wheel_type = LaunchConfiguration("wheel_type")
controller_config_path = LaunchConfiguration("controller_config_path")
declare_controller_config_path_arg = DeclareLaunchArgument(
"controller_config_path",
Expand Down Expand Up @@ -96,14 +94,25 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
robot_model = LaunchConfiguration("robot_model")
robot_model_dict = {"LNX": "lynx", "PTH": "panther"}
robot_model_env = os.environ.get("ROBOT_MODEL", default="PTH")
declare_robot_model_arg = DeclareLaunchArgument(
"robot_model",
default_value=robot_model_dict[robot_model_env],
description="Specify robot model",
choices=["lynx", "panther"],
)

use_sim = LaunchConfiguration("use_sim")
declare_use_sim_arg = DeclareLaunchArgument(
"use_sim",
default_value="False",
description="Whether simulation is used",
choices=["True", "true", "False", "false"],
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
declare_wheel_config_path_arg = DeclareLaunchArgument(
"wheel_config_path",
default_value=PathJoinSubstitution(
Expand All @@ -120,17 +129,16 @@ def generate_launch_description():
),
)

use_sim = LaunchConfiguration("use_sim")
default_wheel_type = {"lynx": "WH05", "panther": "WH01"}
declare_wheel_type_arg = DeclareLaunchArgument(
"wheel_type",
default_value="WH01",
default_value=PythonExpression([f"{default_wheel_type}['", robot_model, "']"]),
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 Expand Up @@ -271,6 +279,7 @@ def generate_launch_description():

actions = [
declare_battery_config_path_arg,
declare_robot_model_arg, # robot_model must be before wheel_type
declare_wheel_type_arg, # wheel_type must be before controller_config_path
declare_components_config_path_arg,
declare_controller_config_path_arg,
Expand Down
11 changes: 5 additions & 6 deletions panther_description/launch/load_urdf.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def generate_launch_description():
),
)

wheel_type = LaunchConfiguration("wheel_type") # wheel_type is used by controller_config_path
wheel_type = LaunchConfiguration("wheel_type")
controller_config_path = LaunchConfiguration("controller_config_path")
declare_controller_config_path_arg = DeclareLaunchArgument(
"controller_config_path",
Expand Down Expand Up @@ -98,6 +98,7 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
declare_wheel_config_path_arg = DeclareLaunchArgument(
"wheel_config_path",
default_value=PathJoinSubstitution(
Expand All @@ -114,15 +115,13 @@ def generate_launch_description():
),
)

wheel_config_path = LaunchConfiguration("wheel_config_path")
declare_wheel_type_arg = DeclareLaunchArgument(
"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
Loading