A Metropolia Garage project made by students of Metropolia UAS.
It is highly recommender to run the image in a devcontainer for development.
To run the code from a terminal, use the following command:
docker run -it --rm -v ~/metrojoe/MetroJoe/ros2_ws:/ros2_ws -v /dev/input/:/dev/input/ --privileged metrojoe
docker run
- Run a command in a new container-it
- Keep STDIN open even if not attached, allocate a pseudo-TTY--rm
- Automatically remove the container when it exits- Optional, but recommended when running the container multiple times (ie. for development)
-v ~/metrojoe/MetroJoe/ros2_pkg:/ros2_pkg
- Mount theros2_pkg
directory from the host to the/ros2_pkg
directory in the container- The
ros2_pkg
directory should contain the ROS2 package(s) on the host machine
- The
-v /dev/input/:/dev/input/
- Mount the/dev/input/
directory from the host to the/dev/input/
directory in the container- Contains the input devices on the host machine
- Required for the joystick inputs to work
--device=/dev/ttyUSB0
- Give the container access to the/dev/ttyUSB0
device- Gives access to the USB serial device on the host machine
- Required for the serial communication to work (ie. with the ModBus motor controller)
--privileged
- Give the container full access to the host- Required for reading the joystick inputs from the
/dev/input/
directory
- Required for reading the joystick inputs from the
metrojoe
- The name of the image to run
ros2 run metrojoe <node_name>
All of the available nodes are listed below. (All of the nodes are still a work in progress.)
The main node that works as the brain of the robot.
Subscribes to the /gamepad_trigger
topic and publishes to the /drive_speed
topic.
In the future, more functions will be added to this node.
Reads the gamepad inputs and publishes them to a topic.
Publish topics:
/gamepad_trigger
- Type: GamepadInput
- string: name
- int16: value
- Test in terminal:
ros2 topic echo /gamepad_trigger
- Type: GamepadInput
Controls the ModBus motor controller.
Subscriber topics:
/drive_speed
- Type: DriveSpeed
- string: direction
- Values:
forward
,reverse
- Values:
- string: turn
- Values:
left
,right
,none
- Values:
- int16: speed
- Range:
0-255
- Range:
- string: direction
- Test in terminal:
ros2 topic pub --once /drive_speed metrojoe_interfaces/msg/DriveSpeed "{direction: '<value>', turn: '<none>', speed: <value>}"
- Type: DriveSpeed