diff --git a/README.md b/README.md index 506be12..01d3985 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Connect joy via nano USB receiver and make sure it is in **DirectInput Mode** (s To test if joy works, use `jstest /dev/input/js0`. If the output is: -``` +```bash jstest: No such file or directory ``` @@ -38,27 +38,28 @@ By default, linear `X` and `Y` are held by the left stick. Angular `Z` is contro | `B` | Trigger E-stop | | `LT` | Enable E-stop reset | -> [!NOTE] +> [!NOTE] > Handle of robot's emergency stop is available only when `~e_stop/present` parameter is set true. This functionality will work with any robot configured as follows: +> > - publishes robot's E-stop state uisng ROS topic of type `std_msgs/Bool`. > - allows resetting robot's E-stop using ROS service of type `std_srvs/Trigger`. > - allows triggering robot's E-stop using ROS service of type `std_srvs/Trigger`. -> +> > Topic and services names can be configured using ROS parameters, see [Parameters](#parameters) for more info. --- -## ROS node API -ROS node is translating `/joy` topic to `/cmd_vel` topic. +## ROS node API +ROS node is translating `joy` topic to `cmd_vel` topic. ### Publish -- `/cmd_vel` *(geometry_msgs/Twist)* +- `cmd_vel` *(geometry_msgs/Twist)* ### Subscribe -- `/joy` *(sensor_msgs/Joy)* +- `joy` *(sensor_msgs/Joy)* ### Parameters @@ -98,38 +99,38 @@ Available on [Docker Hub](https://hub.docker.com/r/husarion/joy2twist/tags) 1. Flash the right firmware: -```bash -docker stop rosbot-xl microros || true && \ -docker run --rm -it --privileged \ ---mount type=bind,source=/dev/ttyUSBDB,target=/dev/ttyUSBDB \ -husarion/rosbot-xl:humble-0.8.2-20230913 \ -flash-firmware.py -p /dev/ttyUSBDB -``` + ```bash + docker stop rosbot-xl microros || true && \ + docker run --rm -it --privileged \ + --mount type=bind,source=/dev/ttyUSBDB,target=/dev/ttyUSBDB \ + husarion/rosbot-xl:humble-0.8.2-20230913 \ + flash-firmware.py -p /dev/ttyUSBDB + ``` -2. Connect Logitech F710 dongle to the ROSbot XL and run (on ROSbot): +1. Connect Logitech F710 dongle to the ROSbot XL and run (on ROSbot): -```bash -cd joy2twist/demo/single_robot -docker compose -f compose.rosbotxl.yaml up -``` + ```bash + cd joy2twist/demo/single_robot + docker compose -f compose.rosbotxl.yaml up + ``` ### Controlling ROSbot 2R with a Logitech F710 Gamepad 1. Flash the right firmware: -```bash -docker stop rosbot microros || true && docker run \ ---rm -it --privileged \ -husarion/rosbot:humble-0.6.1-20230712 \ -flash-firmware.py /root/firmware.bin -``` + ```bash + docker stop rosbot microros || true && docker run \ + --rm -it --privileged \ + husarion/rosbot:humble-0.6.1-20230712 \ + flash-firmware.py /root/firmware.bin + ``` -2. Connect Logitech F710 dongle to the ROSbot 2R and run (on ROSbot): +1. Connect Logitech F710 dongle to the ROSbot 2R and run (on ROSbot): -```bash -cd joy2twist/demo/single_robot -docker compose -f compose.rosbot2r.yaml up -``` + ```bash + cd joy2twist/demo/single_robot + docker compose -f compose.rosbot2r.yaml up + ``` ### Different namespace demo with a Logitech F710 gamepad @@ -160,20 +161,20 @@ docker compose -f compose.rosbot2r.yaml up > **Topic filtering** > > If you will then check on the PC the available ROS 2 nodes you will get: -> +> > ```bash > $ ros2 topic list > /parameter_events > /robot1/cmd_vel > /rosout > ``` -> +> > Note that nly the single `/robot1/cmd_vel` topic is available outside the robot thanks to the configuration from the `ros2router_config.yaml` file. > > To control the robot by using the teleop, just run: `ros2 run teleop_twist_keyboard teleop_twist_keyboard __ns:=/robot1` To run the `joy2twist` container execute the following command on your PC in the `joy2twist/demo/multiple_robots` directory: -``` +```bash docker compose -f compose.pc.yaml up ``` diff --git a/joy2twist/launch/gamepad_controller.launch.py b/joy2twist/launch/gamepad_controller.launch.py index 520d8bb..559fe13 100644 --- a/joy2twist/launch/gamepad_controller.launch.py +++ b/joy2twist/launch/gamepad_controller.launch.py @@ -27,7 +27,11 @@ def generate_launch_description(): joy2twist_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare("joy2twist"), "launch", "joy2twist.launch.py"])] + [ + PathJoinSubstitution( + [FindPackageShare("joy2twist"), "launch", "joy2twist.launch.py"] + ) + ] ), launch_arguments={ "joy2twist_params_file": LaunchConfiguration("joy2twist_params_file"), @@ -40,9 +44,15 @@ def generate_launch_description(): executable="joy_linux_node", # output={"stdout": "screen", "stderr": "screen"}, emulate_tty="true", - namespace=namespace + namespace=namespace, + remappings=[("/diagnostics", "diagnostics")], ) - actions = [declare_namespace_arg, joy2twist_params_file_argument, joy2twist_launch, joy_linux_node] + actions = [ + declare_namespace_arg, + joy2twist_params_file_argument, + joy2twist_launch, + joy_linux_node, + ] return LaunchDescription(actions) diff --git a/joy2twist/launch/joy2twist.launch.py b/joy2twist/launch/joy2twist.launch.py index fea2f0b..c278988 100644 --- a/joy2twist/launch/joy2twist.launch.py +++ b/joy2twist/launch/joy2twist.launch.py @@ -30,7 +30,7 @@ def generate_launch_description(): parameters=[LaunchConfiguration("joy2twist_params_file")], # output={"stdout": "screen", "stderr": "screen"}, emulate_tty="true", - namespace=namespace + namespace=namespace, ) actions = [declare_namespace_arg, joy2twist_params_file_argument, joy2twist_node]