Skip to content

Repository files navigation

stack-chan_micro-ros_arduino

StackChan + micro-ROS + Arduino

stack-chan_micro-ros_arduino_servo-motor

Target StackChan

Development Environment

  • Ubuntu 24.04 LTS
  • ROS 2 Jazzy
  • Docker 29.5.0
  • Arduino IDE 2.3.8, 2.3.9
    • micro_ros_arduino 2.0.7-humble, 3.0.0-iron
    • M5StackChan 1.0.1
    • M5Stack_Avatar 0.10.0

Setup

Usage

  1. Clone this repository.
git clone https://github.com/YusukeKato/stack-chan_micro-ros_arduino.git
  1. Copy config.h.example to config.h and edit it to match your environment.
  2. Upload the program to your StackChan.
  3. Start micro-ROS Agent.
docker run -it --rm --net=host microros/micro-ros-agent:jazzy udp4 --port 8888 -v6
  1. Press the reset button on your StackChan to restart it.

Default

Displays the m5avatar::Expression:::Neutral face.

Neutral Face

Motor

Control the motor by specifying the angle.

ros2 topic pub --once /stackchan/joint_commands std_msgs/msg/Int32MultiArray "{data: [200, 500]}"
control stack-chan motor

Get the current motor angle.

ros2 topic echo /stackchan/joint_states
# output
layout:
  dim: []
  data_offset: 0
data:
- 331
- 300
get stack-chan motor angle

Camera

Get the publish rate of the camera image topic.

ros2 topic hz /stackchan/camera/image/compressed

View the camera image topic.

ros2 run rqt_image_view rqt_image_view

Note: If rqt_image_view doesn't work properly on Wayland, please switch to Xorg.

rqt_image_view stack-chan camera image topic

Battery

Get the battery voltage, remaining level (%), and charging status.

ros2 topic echo /stackchan/battery_state
# output
header:
  stamp:
    sec: 1778980809
    nanosec: 0
  frame_id: base_link
voltage: 4.205999851226807  # Voltage [V]
temperature: 0.0
current: 0.0
charge: 0.0
capacity: 0.0
design_capacity: 0.0
percentage: 0.9300000071525574  # remaining level [0.0-1.0]
power_supply_status: 1  # 1:charging, 2:discharging
power_supply_health: 0
power_supply_technology: 0
present: false
cell_voltage: []
cell_temperature: []
location: ''
serial_number: ''

Speech

Send text, and StackChan will speak.

ros2 topic pub --once /stackchan/speech_text std_msgs/msg/String "{data: 'ohayou gozaimasu'}"

YouTube↓

StackChan+micro-ROS+Arduino: Text To Speech

Touch

Get touch sensor values.

ros2 topic echo /stackchan/touch_intensities
# output
---
layout:
  dim: []
  data_offset: 0
data:
- 3  # Front
- 0  # Middle
- 1  # Back
---
stack-chan_micro-ros_arduino_touch

IMU

Get the IMU data.

Note1: M5StackChan(X-right, Y-down, Z-backward) -> ROS 2(X-forward, Y-left, Z-up)

Note2: Same axis mapping for linear and angular, but different sign inversions.

ros2 topic echo /stackchan/imu
# output
header:
  stamp:
    sec: 1780211663
    nanosec: 838000000
  frame_id: imu_link
orientation:
...
orientation_covariance:
...
angular_velocity:
  x: 0.059654808417774936
  y: 0.08096009713840883
  z: -0.0010652644360316954
angular_velocity_covariance:
...
linear_acceleration:
  x: -0.3208230137825012
  y: 0.1412578970193863
  z: -9.68694019317627
linear_acceleration_covariance:
...
stackchan_microros_imu

Note

  • You can check the debug logs in the Arduino IDE Serial Monitor.

Format

clang-format -i -style=file *.ino *.h

About

StackChan + micro-ROS + Arduino

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages