Add ros2 launch and make it the default
This commit is contained in:
@@ -165,7 +165,7 @@ Replace `matt` with the username configured in [ansible/inventory.ini](ansible/i
|
||||
|
||||
## Launching
|
||||
|
||||
The container needs access to the I²C bus that the motor controller is wired to. Pass only that device rather than running the container in privileged mode:
|
||||
The default `CMD` starts both nodes together via the launch file. The container needs access to the I²C bus — pass only that device rather than running privileged:
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
@@ -175,11 +175,11 @@ docker run --rm \
|
||||
my_robot:latest
|
||||
```
|
||||
|
||||
If your board exposes the motor controller on a different bus (check with `ls /dev/i2c-*` on the host), substitute the correct device node (e.g. `--device /dev/i2c-0`).
|
||||
If your board exposes the controller on a different bus (check with `ls /dev/i2c-*` on the host), substitute the correct device node (e.g. `--device /dev/i2c-0`).
|
||||
|
||||
### Camera orientation node
|
||||
### Overriding parameters at launch
|
||||
|
||||
Override the default `CMD` to run the camera orientation node instead:
|
||||
Launch arguments can be appended after the image name:
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
@@ -187,63 +187,22 @@ docker run --rm \
|
||||
--device /dev/i2c-1 \
|
||||
--env ROS_DOMAIN_ID=0 \
|
||||
my_robot:latest \
|
||||
ros2 run my_robot camera_orientation
|
||||
ros2 launch my_robot robot.launch.py \
|
||||
wheel_base:=0.25 max_speed:=0.8 tilt_center_deg:=45.0
|
||||
```
|
||||
|
||||
#### Overriding parameters at launch
|
||||
Available launch arguments:
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
--network=host \
|
||||
--device /dev/i2c-1 \
|
||||
--env ROS_DOMAIN_ID=0 \
|
||||
my_robot:latest \
|
||||
ros2 run my_robot camera_orientation \
|
||||
--ros-args -p pan_center_deg:=90.0 -p tilt_center_deg:=45.0
|
||||
```
|
||||
|
||||
#### Commanding the camera from the host
|
||||
|
||||
Pan to centre (90°) and tilt to 30°:
|
||||
|
||||
```bash
|
||||
ros2 topic pub --once /joint_command sensor_msgs/msg/JointState \
|
||||
"{name: ['pan', 'tilt'], position: [1.5708, 0.5236]}"
|
||||
```
|
||||
|
||||
You can command a single axis by omitting the other joint name:
|
||||
|
||||
```bash
|
||||
# Pan only
|
||||
ros2 topic pub --once /joint_command sensor_msgs/msg/JointState \
|
||||
"{name: ['pan'], position: [0.0]}"
|
||||
```
|
||||
|
||||
#### Verifying orientation state
|
||||
|
||||
```bash
|
||||
ros2 topic echo /joint_states
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Overriding parameters at launch (motor controller)
|
||||
|
||||
ROS 2 parameters can be passed through `--ros-args`:
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
--network=host \
|
||||
--device /dev/i2c-1 \
|
||||
--env ROS_DOMAIN_ID=0 \
|
||||
my_robot:latest \
|
||||
ros2 run my_robot motor_controller \
|
||||
--ros-args -p wheel_base:=0.25 -p max_speed:=0.8
|
||||
```
|
||||
| Argument | Default | Description |
|
||||
|---|---|---|
|
||||
| `wheel_base` | `0.3` | Distance between left and right wheels (m) |
|
||||
| `max_speed` | `1.0` | Maximum motor speed in library units |
|
||||
| `pan_center_deg` | `90.0` | Pan angle at startup and shutdown (degrees) |
|
||||
| `tilt_center_deg` | `60.0` | Tilt angle at startup and shutdown (degrees) |
|
||||
|
||||
### Sending velocity commands from the host
|
||||
|
||||
With the container running, publish a `cmd_vel` message from another terminal (requires ROS 2 installed on the host or a second container on the same network):
|
||||
With the container running, publish from another terminal (requires ROS 2 on the host or a second container on the same network):
|
||||
|
||||
```bash
|
||||
# Drive forward at 0.2 m/s
|
||||
@@ -259,10 +218,31 @@ ros2 topic pub --once /cmd_vel geometry_msgs/msg/Twist \
|
||||
"{linear: {x: 0.0}, angular: {z: 0.0}}"
|
||||
```
|
||||
|
||||
### Commanding the camera from the host
|
||||
|
||||
Pan to centre (90°) and tilt to 30°:
|
||||
|
||||
```bash
|
||||
ros2 topic pub --once /joint_command sensor_msgs/msg/JointState \
|
||||
"{name: ['pan', 'tilt'], position: [1.5708, 0.5236]}"
|
||||
```
|
||||
|
||||
A single axis can be commanded by omitting the other joint name:
|
||||
|
||||
```bash
|
||||
# Pan only
|
||||
ros2 topic pub --once /joint_command sensor_msgs/msg/JointState \
|
||||
"{name: ['pan'], position: [0.0]}"
|
||||
```
|
||||
|
||||
### Verifying telemetry
|
||||
|
||||
```bash
|
||||
# Wheel speeds
|
||||
ros2 topic echo /current_wheel_speeds
|
||||
|
||||
# Camera orientation
|
||||
ros2 topic echo /joint_states
|
||||
```
|
||||
|
||||
---
|
||||
@@ -277,6 +257,8 @@ ros2 topic echo /current_wheel_speeds
|
||||
│ └── my_robot/
|
||||
│ ├── package.xml # ROS package manifest
|
||||
│ ├── setup.py # ament_python build definition
|
||||
│ ├── launch/
|
||||
│ │ └── robot.launch.py # Starts both nodes together
|
||||
│ └── my_robot/
|
||||
│ ├── __init__.py
|
||||
│ ├── motor_controller_node.py # Differential-drive motor control
|
||||
|
||||
Reference in New Issue
Block a user