Skip to content

Commit

Permalink
Merge pull request #11 from husarion/readme_update
Browse files Browse the repository at this point in the history
api update
  • Loading branch information
delihus authored Mar 8, 2023
2 parents 2c98c2d + faaced9 commit d61e0c4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ______ _____ _____ _ _ __
| |\ \ \ \_/ //\__/ /| |_) || (_) || |_ | | \ V V /
\_| \_| \___/ \____/ |_.__/ \___/ \__| |_| \_/\_/
```
**Firmware version:** `0.3.1`
**Firmware version:** `0.3.2`

## Prerequisites
You need to install following tools:
Expand Down
107 changes: 55 additions & 52 deletions ROS_API.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,65 @@
## ROS2 API
### Subscribes
- `/cmd_ser` (*std_msgs/msg/UInt32MultiArray[6]*, **/rosbot_stm32_firmware**)
- `/led/left` (*std_msgs/msg/Bool*, **/rosbot_stm32_firmware**)
- `/led/right` (*std_msgs/msg/Bool*, **/rosbot_stm32_firmware**)
- `/_motors_cmd` (*std_msgs/msg/Float32MultiArray[4]*, **/rosbot_stm32_firmware**)

### Publishes
- `/_motors_response` (*sensor_msgs/msg/JointState*, **/rosbot_stm32_firmware**)
- `/_imu/data_raw` (*sensor_msgs/msg/Imu*, **/rosbot_stm32_firmware**)
- `/battery` (*sensor_msgs/BatteryState*, **/rosbot_stm32_firmware**)
- `/range/right_front` (*sensor_msgs/msg/Range*, **/rosbot_stm32_firmware**)
- `/range/left_front` (*sensor_msgs/msg/Range*, **/rosbot_stm32_firmware**)
- `/range/right_rear` (*sensor_msgs/msg/Range*, **/rosbot_stm32_firmware**)
- `/range/left_rear` (*sensor_msgs/msg/Range*, **/rosbot_stm32_firmware**)
- `/button/left` (*std_msgs/msg/Bool*, **/rosbot_stm32_firmware**)
- `/button/right` (*std_msgs/msg/Bool*, **/rosbot_stm32_firmware**)

### Parameters
- `servo_enable_power` (*Bool*, **/rosbot_stm32_firmware**)
- `servo_voltage` (*Double*, **/rosbot_stm32_firmware**):
- `5.0`V
- `6.0`V
- `7.4`V
- `8.6`V
- `servo[0...5]_enable` (*Bool*, **/rosbot_stm32_firmware**) e.g. `servo2_enable`
- `servo[0...5]_period` (*UInt32*, **/rosbot_stm32_firmware**) e.g. `servo2_period`

## Command line examples
### Motors driving
Use `micro_ros_agent` to communicate with all firmware functionalities.
```bash
# Go forward
ros2 topic pub /_motors_cmd std_msgs/msg/Float32MultiArray "data: [1.0, 1.0, 1.0, 1.0]"
ros2 run micro_ros_agent micro_ros_agent serial -D $SERIAL_PORT serial -b 576000
```
- `rosbot_ros2_firmware` it is a micro-ROS node on CORE2 inside ROSbot 2R, 2 PRO, 2. It is used to publish all the sensor data such as wheels positions, IMU measurements, battery level and buttons states from firmware to ROS2 and also to subscribe command values such as motors speeds, servos periods, servos parameters and LEDs states.
**Subscribes**
- `/cmd_ser` (_std_msgs/msg/UInt32MultiArray[6]_)
- `/led/left` (_std_msgs/msg/Bool_)
- `/led/right` (_std_msgs/msg/Bool_)
- `/_motors_cmd` (_std_msgs/msg/Float32MultiArray[4]_)

### Servos steering
```bash
# Choose power supply voltage for the servos e.g. 5.0V
ros2 param set /rosbot_stm32_firmware servo_voltage 5.0
**Publishes**
- `/_motors_response` (_*sensor_msgs/msg/JointState_)
- `/_imu/data_raw` (_sensor_msgs/msg/Imu_)
- `/battery` (_sensor_msgs/BatteryState_)
- `/range/right_front` (_sensor_msgs/msg/Range_)
- `/range/left_front` (_sensor_msgs/msg/Range_)
- `/range/right_rear` (_sensor_msgs/msg/Range_)
- `/range/left_rear` (_sensor_msgs/msg/Range_)
- `/button/left` (_std_msgs/msg/Bool_)
- `/button/right` (_std_msgs/msg/Bool_)

# Enable power for the servos
ros2 param set /rosbot_stm32_firmware servo_enable_power true
**Parameters**
- `servo_enable_power` (_Bool_)
- `servo_voltage` (_Double_):
- `5.0`V
- `6.0`V
- `7.4`V
- `8.6`V
- `servo[0...5]_enable` (*Bool_) e.g. `servo2_enable`
- `servo[0...5]_period` (*UInt32_) e.g. `servo2_period`

# Set the control period in microseconds e.g. 20 000us for the servo5
ros2 param set /rosbot_stm32_firmware servo5_period 20000
#### Command line examples
- **Motors driving (e.g. go forward)**
```bash
ros2 topic pub /_motors_cmd std_msgs/msg/Float32MultiArray "data: [1.0, 1.0, 1.0, 1.0]"
```

# Enable PWM output for the servo e.g. for the servo5
ros2 param set /rosbot_stm32_firmware servo5_enable true
- **Servos steering**
```bash
# Choose power supply voltage for the servos e.g. 5.0V
ros2 param set /rosbot_stm32_firmware servo_voltage 5.0
# Send duty cycle to the servos
ros2 topic pub /cmd_ser std_msgs/msg/UInt32MultiArray "data: [0, 0, 0, 0, 0, 2000]"
# Enable power for the servos
ros2 param set /rosbot_stm32_firmware servo_enable_power true
```
# Set the control period in microseconds e.g. 20 000us for the servo5
ros2 param set /rosbot_stm32_firmware servo5_period 20000
### LED blinking
```bash
# Turn on the left LED
ros2 topic pub /led/left std_msgs/msg/Bool "data: true"
# Enable PWM output for the servo e.g. for the servo5
ros2 param set /rosbot_stm32_firmware servo5_enable true
# Send duty cycle to the servos
ros2 topic pub /cmd_ser std_msgs/msg/UInt32MultiArray "data: [0, 0, 0, 0, 0, 2000]"
```

- **LED blinking**
```bash
# Turn on the left LED
ros2 topic pub /led/left std_msgs/msg/Bool "data: true"
# Turn off the left LED
ros2 topic pub /led/left std_msgs/msg/Bool "data: false"
```
# Turn off the left LED
ros2 topic pub /led/left std_msgs/msg/Bool "data: false"
```
2 changes: 1 addition & 1 deletion include/microros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <microros_transport/mbed_serial_transport.hpp>
#include <rclc_parameter/rclc_parameter.h>

constexpr const char *NODE_NAME = "rosbot_stm32_firmware";
constexpr const char *NODE_NAME = "rosbot_ros2_firmware";
constexpr const char *IMU_TOPIC_NAME = "_imu/data_raw";
constexpr const char *WHEELS_STATE_TOPIC_NAME = "_motors_response";
constexpr const char *BATTERY_TOPIC_NAME = "battery";
Expand Down

0 comments on commit d61e0c4

Please sign in to comment.