Skip to content

Commit

Permalink
Add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Sep 19, 2024
1 parent fbc8d4c commit c36470c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
14 changes: 13 additions & 1 deletion panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

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",
Expand All @@ -119,9 +129,10 @@ def generate_launch_description():
),
)

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=(
"Specify the wheel type. If the selected wheel type is not 'custom', "
"the 'wheel_config_path' and 'controller_config_path' arguments will be "
Expand Down Expand Up @@ -268,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
17 changes: 3 additions & 14 deletions panther_gazebo/launch/simulate_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ def generate_launch_description():
description="Add namespace to all launched nodes.",
)

robot_model_dict = {"LNX": "lynx", "PTH": "panther"}
robot_model_env = os.environ.get("ROBOT_MODEL", default="PTH")
robot_model_env = "lynx" if robot_model_env == "LNX" else "panther"
robot_model_default = robot_model_dict[robot_model_env]
declare_robot_model_arg = DeclareLaunchArgument(
"robot_model",
default_value=robot_model_env,
default_value=robot_model_default,
description="Specify robot model",
choices=["lynx", "panther"],
)
Expand All @@ -104,17 +105,6 @@ def generate_launch_description():
choices=["True", "true", "False", "false"],
)

declare_wheel_type_arg = DeclareLaunchArgument(
"wheel_type",
default_value=PythonExpression(["'WH01' if '", robot_model, "' == 'panther' else 'WH05'"]),
description=(
"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", "WH05", "custom"],
)

spawn_robot_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
Expand Down Expand Up @@ -246,7 +236,6 @@ def generate_launch_description():
declare_gz_bridge_config_path_arg,
declare_namespace_arg,
declare_use_ekf_arg,
declare_wheel_type_arg,
SetUseSimTime(True),
spawn_robot_launch,
lights_launch,
Expand Down
7 changes: 4 additions & 3 deletions panther_gazebo/launch/spawn_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def generate_launch_description():
)

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

0 comments on commit c36470c

Please sign in to comment.