Cube Rover Demonstration

Hi. I’m just here to share some tips on building a rover with Cube and other common peripherals. Most of the instructions are written in Ardupilot wiki.

Rover with Here2

Screenshot 2022-01-07 153241

Cube: Black

GPS: Here3

Lidar: Rplidar A2

This build is quite straight forward. Setting up everything and it should work. The couplers on my rover were 3D printed and they loosen over time. Therefore it is not moving quite perfectly straight in the video.

Setup are exactly same as instruction in Ardupilot wiki

https://ardupilot.org/copter/docs/common-simple-object-avoidance.html

https://ardupilot.org/copter/docs/common-oa-bendyruler.html

Rover with Realsense T265

Cube: Black

Companion computer: Raspberry Pi (w. APSync) /Intel UP2 (w. Ubuntu 18)

Motion camera: Intel Realsense T265

Another build a rover with companion computer and vision positioning sensor

Companion computer Setup

Raspberry Pi connection

Flash APSync into the SD card. The T265 scripts should be already installed.

If you want to use raspbian, setup as mentioned here

If you use Ubuntu, follow the steps here

UP2 connection

Connect the UP2 with telem port, according to its pinout.

Setup the UP2 system as mentioned in their wiki (eg: Ubuntu). You will need to install their kernal to enable the HAT.

I’m using ubuntu 18.

If you connect them as shown in the figure above, the Cube should appear in ttyS5.

Software Installation and Parameter Setup

Setup the companion computer if you are not using APSync. If you use APSync, start from Configure ArduPilot.

I’m using EK3 with compass disabled.

Prerequisite

Install mavproxy for ease on verifying connection to autopilot

Remove modemmanager so that it won’t conflict with serial communication

Install mavlink router to route more ports for potential usages

Follow the instructions in wiki to complete the remaining steps:

https://ardupilot.org/copter/docs/common-vio-tracking-camera.html

Mavlink Router Setting

Create the config file in /etc/mavlink-router/main.conf

[General]
ReportStats=false
MavlinkDialect=auto
​
[UartEndpoint alfa]
Device = /dev/ttyS5
Baud = 921600
​
[UdpEndpoint bravo]
Mode = Normal
Address = 127.0.0.1
Port = 14460
​
[UdpEndpoint Charlie]
Mode = Normal
Address = 127.0.0.1
Port = 14470
Make autorun at boot

Create the bash script mavlink_router.sh

#!/bin/bash
mavlink-routerd

Create the service in /etc/systemd/system/mavlink_router.service

[Unit]
Description=Mavlink Router Service
After=multi-user.target
StartLimitIntervalSec=0
Conflicts=
​
[Service]
User={your username}
EnvironmentFile=
ExecStartPre=
ExecStart={path to mavlink_rounter.sh}
​
Restart=on-failure
RestartSec=1
​
[Install]
WantedBy=multi-user.target

Enable and start the service

systemctl start mavlink_router
systemctl enable mavlink_router

T265 with UDP port

We have routed port 14460 and 14470 from serial port. Now we can use them to connect to autopilot.

Base on the T265 script (serial) in wiki, further modify it:

connection_string_default = 'udpin:127.0.0.1:14460'
conn = mavutil.mavlink_connection(
connection_string,
autoreconnect = True,
source_system = 255,
source_component = 93,
target_system = 1
)
Make autorun at boot

Same as wiki but since we use udp routed my mavlink router, we want it to start after mavlink router service. In the first part of t265.service:

[Unit]
Description=Realsense T265 Service
After=multi-user.target mavlink_outer.service
StartLimitIntervalSec=0
Conflicts=

Don’t forget to start and enable the service.

In some system (or hardware, I don’t actually know which one to blame), the service don’t start until its desktop initialized. If you don’t have any monitor/HDMI output connected, the service will stay inactive forever. In that case, you will need a HDMI dummy plug.

Connection Test

Now if you have gone through the steps, it should work. Verify this in Mission Planner as mentioned in wiki.

The port 14470 is a spare, you can connect it from companion computer via mavproxy to confirm the connection.

mavproxy.py --master=udp:localhost:14470 --console --map --target-system=1 --target-component=0

You can also use it for various applications such as ROS.

Auto Mission Test

5 Likes

SLAM Mapping with Cartographer

Following the build with T265 non GPS navigation rover, I added the 2D lidar on top of it.

Additional Hardware

Camera: Pi camera with Raspberry pi
Lidar: RPLidar A2
Internet connection for companion computer: 2.4GHz Wifi dongle

You may wonder why not put all wireless connection connecting under Herelink controller’s hotspot. The answer is simply because I don’t have the hardware to connect UP2 to 5GHz wifi.
It is also possible to setup the ethernet so that the companion computer doesn’t need additional wireless connection.

Setup

On companion computer (UP2 in my case), build the cartographer, ROS, and other necessary packages following the instruction in Ardupilot wiki

If the error show up when trying to build it, try to build the packages with cartographer wiki’s instruction

You may also need to install abseil if any related error come out

$ sudo apt-get install stow
$ sudo chmod +x ~/carto_ws/src/cartographer/scripts/install_abseil.sh
$ cd ~/carto_ws/src/cartographer/scripts
$ ./install_abseil.sh

To make a remote spectator or control on laptop, use ROS’s master/remote setup:
In master’s ~/.bashrc, put

export ROS_IP={self ip}
export ROS_MASTER_URI=http://localhost:11311

In remote’s ~/.bashrc, put

export ROS_IP={self ip}
export ROS_MASTER_URI=http://{master’s ip}:11311

Run the SLAM

SSH into master machine

ssh {username}@{master ip}

Then run the ros components in different terminals

roscore

roslaunch rplidar_ros rplidar.launch

roslaunch cartographer_ros cartographer.launch

In remote/client machine

roscore

rviz -d ~/catkin_ws/src/cartographer_ros/cartographer_ros/configuration_files/demo_2d.rviz

Generate mapping file

Finally, when mapping is done, run the following lines to generate .pgm and .yaml files

rosrun map_server map_saver [-f mapname]

You will get something like this:

Video Demo

It was a little laggy at the corner, because there is surrounded by couple of big and tall metal shelves. The wifi hotspot signal from Herelink was not reaching, but the Herelink transmission itself are working fine.

I’m not able to test the build elsewhere. That’s because I need to stick to a network with 2.4GHz hotspot(for UP2), 5GHz hotspot(for Herelink controller), and under my control.

Errors

If the follow error shows up:

[ERROR] [1651567143.011534119]: Client [/rviz_1651567140920139372] wants topic /submap_list to have datatype/md5sum [cartographer_ros_msgs/SubmapList/6efe809c4a0e69266aa99b3bea531f2a], but our version has [cartographer_ros_msgs/SubmapList/73b1e412208f0787050395996f6143db]. Dropping connection.

in master’s rosrun cartographer’s terminal when client’s rviz launch. (the md5sum string maybe different, but the idea is them being mismatched over master and client)

You may try to:

  1. check whether you have sourced devel/setup.bash in ~/bashrc.sh or not. If you used catkin_make_isolated --install --use-ninja, the directory becomes devel_isolated/setup.bash

  2. reinstall ros-{distro}-cartographer-rviz

  3. rebuild cartographer_ros

  4. reset rviz to default

  5. reinstall ROS

If the follow error shows up:

[ERROR] [1651655459.598098736]: PluginlibFactory: The plugin for class ‘Submaps’ failed to load. Error: According to the loaded plugin descriptions the class Submaps with base class type rviz::Display does not exist. Declared types are rviz/Axes rviz/Camera rviz/DepthCloud rviz/Effort rviz/FluidPressure rviz/Grid rviz/GridCells rviz/Illuminance rviz/Image rviz/InteractiveMarkers rviz/LaserScan rviz/Map rviz/Marker rviz/MarkerArray rviz/Odometry rviz/Path rviz/PointCloud rviz/PointCloud2 rviz/PointStamped rviz/Polygon rviz/Pose rviz/PoseArray rviz/PoseWithCovariance rviz/Range rviz/RelativeHumidity rviz/RobotModel rviz/TF rviz/Temperature rviz/WrenchStamped

Source devel/setup.bash or devel_isolated/setup.bash like the 1st solution in last error.

Hope you enjoy my sharing.