Skip to content

Commit

Permalink
Add robot specific velocity presets (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszlagan authored Dec 19, 2024
1 parent 1e784ba commit b6d1727
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ This ROS 2 package allows you to control robots using a CRSF compatible remote c

## Launch Files

- `teleop.launch.py`: Launches crsf_teleop_node node. Automatically respawns node if it exits. Node's namespace can be set using the `namespace` launch argument.
- `teleop.launch.py`: Launches crsf_teleop_node node. Automatically respawns node if it exits. Node's namespace can be set using the `namespace` launch argument. Custom parameters file can be provided by setting the `params_file` launch argument.

## Configuration Files

- [`crsf_teleop.yaml`](./config/crsf_teleop.yaml): Sets default parameter values for the crsf_teleop_node when `teleop.launch.py` is launched.
- [`crsf_teleop_panther.yaml`](./husarion_ugv_crsf_teleop/config/crsf_teleop_panther.yaml): Sets default Panther robot parameter values for the crsf_teleop_node when `teleop.launch.py` is launched.
- [`crsf_teleop_lynx.yaml`](./husarion_ugv_crsf_teleop/config/crsf_teleop_lynx.yaml): Sets default Lynx robot parameter values for the crsf_teleop_node when `teleop.launch.py` is launched.

## ROS Nodes

Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ services:
environment:
- RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION:-rmw_cyclonedds_cpp}
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0}
- ROBOT_MODEL_NAME=${ROBOT_MODEL_NAME:-panther}
volumes:
- /dev:/dev
- ./config/crsf_teleop.yaml:/ros2_ws/install/husarion_ugv_crsf_teleop/share/husarion_ugv_crsf_teleop/config/crsf_teleop.yaml
command: >
ros2 launch husarion_ugv_crsf_teleop teleop.launch.py namespace:=panther
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
baud: 576000
e_stop_republish: false
enable_cmd_vel_silence_switch: false
linear_speed_presets: [0.5, 1.0, 2.0]
angular_speed_presets: [0.5, 1.0, 2.0]
linear_speed_presets: [0.5, 0.9, 1.5]
angular_speed_presets: [0.45, 0.9, 2.0]
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
baud: 576000
e_stop_republish: false
enable_cmd_vel_silence_switch: false
linear_speed_presets: [0.5, 1.0, 2.0]
angular_speed_presets: [0.5, 1.0, 2.0]
linear_speed_presets: [0.4, 1.2, 2.0]
angular_speed_presets: [0.39, 0.78, 1.88]
28 changes: 25 additions & 3 deletions husarion_ugv_crsf_teleop/launch/teleop.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
EnvironmentVariable,
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
Expand All @@ -28,6 +29,27 @@
def generate_launch_description():
husarion_ugv_crsf_teleop_dir = FindPackageShare("husarion_ugv_crsf_teleop")

robot_model = LaunchConfiguration("robot_model")
declare_robot_model_arg = DeclareLaunchArgument(
"robot_model",
default_value=EnvironmentVariable(name="ROBOT_MODEL_NAME", default_value="panther"),
description="Specify robot model.",
choices=["lynx", "panther"],
)

params_file = LaunchConfiguration("params_file")
declare_params_file_arg = DeclareLaunchArgument(
"params_file",
default_value=PathJoinSubstitution(
[
husarion_ugv_crsf_teleop_dir,
"config",
PythonExpression(["'crsf_teleop_", robot_model, ".yaml'"]),
]
),
description="Path to the ROS2 parameters file to use for the launched node.",
)

namespace = LaunchConfiguration("namespace")
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
Expand All @@ -39,16 +61,16 @@ def generate_launch_description():
package="husarion_ugv_crsf_teleop",
executable="crsf_teleop_node",
name="crsf_teleop",
parameters=[
PathJoinSubstitution([husarion_ugv_crsf_teleop_dir, "config", "crsf_teleop.yaml"]),
],
parameters=[params_file],
namespace=namespace,
emulate_tty=True,
respawn=True,
respawn_delay=2,
)

actions = [
declare_robot_model_arg,
declare_params_file_arg,
declare_namespace_arg,
husarion_ugv_crsf_teleop_node,
]
Expand Down
2 changes: 1 addition & 1 deletion husarion_ugv_crsf_teleop/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
packages=find_packages(exclude=["test"]),
data_files=[
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
(os.path.join("share", package_name, "config"), ["config/crsf_teleop.yaml"]),
(os.path.join("share", package_name, "config"), glob(os.path.join("config", "*.yaml"))),
(os.path.join("share", package_name), ["package.xml"]),
(
os.path.join("share", package_name, "launch"),
Expand Down

0 comments on commit b6d1727

Please sign in to comment.