For general settings: https://ubuntu-mate.org/raspberry-pi/
- raspberry pi 3 - Ubuntu Mate
- RPLIDAR https://www.slamtec.com/en/Lidar/A1
- IMU + magnetometer (GY-85) combines: ADXL345 Three axis acceleration, ITG3205 Three axis gyroscope, HMC5883L Three axis magnetic field.
- 2 Stepper motors with rotary encoder
- 3S LiPo Battery
user: rikirobot
pw: 123456
you might need an ip scanner to find the ip.
If you never connected to your local wifi, use hdmi, mouse and keyboard.
sudo ./auto_start.sh
(sudo to set time).
Content:
#!/bin/bash
#start all stuff for slammy
#user slammy
#pw: 123456
#usual ip 141.58.125.212
sleep 10
# source bash
source ~/catkin_ws/devel/setup.bash
# start roscore
roscore &
sleep 2
# start lidar
roslaunch --wait rplidar_ros rplidar.launch &
sleep 10
# start motorboard
rosrun rosserial_python serial_node.py /dev/ttyUSB1 &
sleep 10
#start controler
roslaunch ds4_driver ds4_twist.launch dof:=2 &
Only do once: Pair PS4 Controller by pressing share and PS button until backlight flashes.
Use bluetoothctl
to pair to controller.
If connected solid purple backllight.
After first pairing the controller will pair automaticly after powerup.
Install http://wiki.ros.org/ds4_driver launch the twist node with 2 degree of freedom:
roslaunch ds4_driver ds4_twist.launch dof:=2
If connected solid purple light and:
[INFO] [1634658515.208866]: Connected to Bluetooth Controller (98:B6:E9:FE:7A:30 hidraw0)
Axis and sensitivity can be changed in:
/catkin_ws/src/ds4_driver/config/twist_2dof.yaml
Follow this: https://tutorials-raspberrypi.de/hd44780-lcd-display-per-i2c-mit-dem-raspberry-pi-ansteuern/
enable i2c in /boot/config.txt
## i2c_arm
## Enable the ARM's i2c interface
##
## Default off.
##
dtparam=i2c_arm=off
this python script to show status, time and ip
its entered in crontab -e
@reboot python /home/slammy/hd44780/display_slammy.py
to start at reboot
import lcddriver
from time import *
import socket
from datetime import datetime
import os
import time
# set up display
lcd = lcddriver.lcd()
lcd.lcd_clear()
# init status
ROS_stat = "OFF"
LDR_stat = "OFF"
ARD_stat = "OFF"
PS4_stat = "OFF"
def extract_ip():
'''gets the ip adresse and retursn as string'''
st = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
st.connect(('10.255.255.255', 1))
IP = st.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
st.close()
return IP
while True:
# get ip
hostname=socket.gethostname()
IPAddr=socket.gethostbyname(hostname)
#get time
now=datetime.now()
# list ros topics
rtopics = os.popen('rostopic list').readlines()
# print(rtopics)
# check if topics exist
if '/scan\n' in rtopics :
LDR_stat=" ON"
else:
LDR_stat="OFF"
if '/cmd_vel\n' in rtopics:
ARD_stat = " ON"
else:
ARD_stat="OFF"
if '/rosout\n' in rtopics:
ROS_stat= " ON"
else:
ROS_stat="OFF"
if '/status\n' in rtopics:
PS4_stat = " ON"
else:
PS4_stat = "OFF"
# display all
lcd.lcd_display_string(now.strftime("%d.%m.%Y, %H:%M:%S"), 1)
lcd.lcd_display_string("IP:"+extract_ip(), 2)
lcd.lcd_display_string("ROS:"+ROS_stat+" LIDAR:"+LDR_stat, 3)
lcd.lcd_display_string("Ardu:"+ARD_stat+" PS4:"+PS4_stat, 4)
time.sleep(0.5)
Set ip to master
export ROS_MASTER_URI=http://141.58.125.213:11311
Set my IP:
export ROS_IP=
hostname -I`
Show all topics:
rostopic list
Show contend of a message:
rostopic echo /scan
Output:
/cmd_vel
/diagnostics
/imu/data
/imu/data_raw
/imu/mag
/imu_filter_madgwick/parameter_descriptions
/imu_filter_madgwick/parameter_updates
/odom
/pid
/raw_imu
/raw_vel
/rosout
/rosout_agg
/scan
/statistics
/tf
Show rqt_graph:
rosrun rqt_graph rqt_graph
Output:
./records/rosbag_record.sh
that runs following commands:
rosbag record /imu/data /imu/data_raw /imu/mag /imu_filter_madgwick/parameter_descriptions /imu_filter_madgwick/parameter_updates /odom /pid /scan /tf
Rikirobot\rosbag\two_loops_robot\2021-07-16-15-31-07_two_loops_robot.bag Contains the robots sensor data from the "two_loops" run.
English https://www.programmersought.com/article/70391490094/
Chinese https://github.com/ykevin/rikirobot_docs/tree/master/UserManual
Some exemples of how to use the recorded rosbag in Matlab.
Rikirobot\Matlab\example_teleop
Remote control via numpad for slammy. Control the robot by publishing ROS messages with the desired linear and angular velocity.
You need the current ip address.
Use the numpad to navigate:
8: Forward
7: Forward and turn left
9: Forward and turn right
4: Sharp left
2: Backwards
6: Sharp right
1: Backwards and turn left
3: Backwards and turn right
Rikirobot\Matlab\example_lidar_slam
Use the MATLAB's lidarSLAM
to evaluate the recorded ROSbag.
The lidarSLAM class performs simultaneous localization and mapping (SLAM) for lidar scan sensor inputs. The SLAM algorithm takes in lidar scans and attaches them to a node in an underlying pose graph. The algorithm then correlates the scans using scan matching. It also searches for loop closures, where scans overlap previously mapped regions, and optimizes the node poses in the pose graph.
Rikirobot\Matlab\example_odometry
Visualize the topic \odom
, which, contains the accumulated odometry data.
madgwick filtered https://nitinjsanket.github.io/tutorials/attitudeest/madgwick imu data is available under the topic \imu\data
.
The timestamp is expressed as:
- stamp.sec: seconds (stamp_secs) since 01-Jan-1970.
- stamp.nsec: nanoseconds since stamp_secs.