Home Unitree Unitree B2-W EDU doc--Sensor Communication and SLAM
Post
Cancel

Unitree Unitree B2-W EDU doc--Sensor Communication and SLAM

Sensor Communication

The data flow in B2W is built on CycloneDDS which is the basis for ROS2. As I am more familiar with ROS1, here I show how to subscribe sensor messages using unitree_sdk2_python message types

CycloneDDS

Install cyclonedds python package following this tutorial.

Some basic commands:

  • cyclonedds ps: show all messages
  • cyclonedds typeof <topic_name>: check topic types
  • `cyclonedds subscribe : susbcribe topic

subscribe LiDAR pointcloud

use built-in python message type PointCloud2_

subscribe IMU data

use built-in python message type IMUState

Cross-machine Communication

We need to setup cross-machine communication when we need other types of ports (e.g., I2C) since B2W only provides typeC ports.

Here we show how to setup a three machine (PC5, Jetson, and desktop) communication using ethernet and wireless connection. PC5 is connected with Jetson through ethernet, PC5 is connected with desktop through wireless network.

We have PC5 running SLAM with ethernet address 192.168.123.166 and wifi ip address 192.168.85.2, a jetson with ethernet address 192.168.123.222, and a desktop PC with wifi address 192.168.85.3.

PCFunctionInterfaceIP Address
PC5SLAM + ROS MasterEthernet192.168.123.166
  Wi‑Fi192.168.85.2
JetsonSensor DataEthernet192.168.123.222
DesktopMonitoringWi‑Fi192.168.85.3

enable PC5 IP forwarding

PC5 needs to route traffic between Jetson and desktop:

1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf

enable communication between Jetson and desktop

Desktop can’t reach Jetson directly, so route via PC5’s Wi-Fi IP:

1
sudo ip route add 192.168.123.0/24 via 192.168.85.2 dev wlan0 onlink

Replace wlan0 with the actual interface if different (ip a to check)

ROS Environment Variables

Assume PC5 is the ROS Master. You must set the same ROS_MASTER_URI and the correct ROS_IP on each machine.

On PC5,

1
2
3
export ROS_MASTER_URI=http://192.168.123.166:11311
export ROS_IP=192.168.123.166
roscore

On Jetson,

1
2
export ROS_MASTER_URI=http://192.168.123.166:11311
export ROS_IP=192.168.123.222

On desktop,

1
2
export ROS_MASTER_URI=http://192.168.123.166:11311
export ROS_IP=192.168.85.3

Add these lines to each ~/.bashrc for convenience.

test

ping each other in each machine.

This post is licensed under CC BY 4.0 by the author.
Trending Tags
Contents
Trending Tags