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

Add robot specific velocity presets #3

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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
3 changes: 2 additions & 1 deletion husarion_ugv_crsf_teleop/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
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"), ["config/crsf_teleop_panther.yaml"]),
(os.path.join("share", package_name, "config"), ["config/crsf_teleop_lynx.yaml"]),
miloszlagan marked this conversation as resolved.
Show resolved Hide resolved
(os.path.join("share", package_name), ["package.xml"]),
(
os.path.join("share", package_name, "launch"),
Expand Down
Loading