This projects implements autonomous racing car, in scale 1/10 of Formula 1. The car is equipped with Lidar and encoders for localization and supports various path planning and tracking algorithms.
- Traxxes Slash 2WD (chassis)
- Pololu magnetic encoder
- Slamtec S2 Lidar
- Pololu 5V regulator
- Raspberry Pi 4 Model B 8GB (on-board computer)
- Arduino Unu (low level controller)
- Lipo battery
The Raspberry Pi runs Ubuntu 22.04 Mate, with ROS2
download imager to burn OS to PI download ubuntu mate for PI 64 from https://ubuntu-mate.org/download/ install ros:https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
skip: set locale
setup sources
install ros2 packages , desktop version
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
After installtion update TIME and DATE before sudo apt update and upgrade
Burn the low-level code to the Arduino. the code implements PID controller for drive motor, steering commands, and reading of the encoder for odometry.
sudo apt install ros-humble-xacro ros-humble-joint-state-publisher-gui ros-humble-joint-state-publisher ros-humble-rplidar-ros ros-humble-ros2-control ros-humble-ros2-controllers ros-humble-gazebo-ros2-control joystick jstest-gtk evtest ros-humble-slam-toolbox ros-humble-navigation2 ros-humble-nav2-bringup ros-humble-turtlebot3* ros-humble-twist-mux ros-humble-twist-stamper
sudo apt-get install python3-pip
pip install setuptools==58.2.0
sudo apt install python3-serial
sudo apt install libserial-dev
sudo apt install net-tools
sudo apt install openssh-server
sudo adduser $USER dialout
Find robot IP:
connect robot to wifi
on robot computer - ifconfig -a -> wlan -> inet
or
hostname -I
or
how to find robot ip - on robot computer ->wifi -> connection information
setting up ssh:
- sudo apt install openssh-server
- service ssh status
- sudo ufw allow ssh
- ssh 127.0.0.1
- ip addr
- ssh robot1@172.20.10.5
pyserial-miniterm -e /dev/ttyACM0 57600 with o - open loop, e- encoders, m-closed loop run in terminal pyserial-miniterm -e /dev/ttyACM0 57600
find path to some serial device: ls /dev/serial/by-path/
Original low level controller(for differential drive): https://github.com/joshnewans/diffdrive_arduino/tree/humble
Serial communication: https://github.com/joshnewans/serial
Ros arduino bridge: https://github.com/joshnewans/ros_arduino_bridge.git
sudo chmod 666 /dev/ttyACM0
- drive the car stright, adjust the offset of the steering
- measure the turning radius and adjust the maximal steering angle
- steering angle = atan(wheelbase/turning radius)
source /opt/ros/humble/setup.bash
colcon build
source install/setup.bash
Access the robot via SSH, make sure to source:
ssh robot1@192.168.77.6
ssh robot1@192.168.0.102
cd car_hardware
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch rc_car launch_robot.launch.py
ros2 launch rc_car rplidar_s2.launch.py
ros2 run rviz2 rviz2 -d src/rc_car/rviz_config/localization.rviz --ros-args -p use_sim_time:=false
ros2 launch rc_car online_async_launch.py use_sim_time:=false
- panels -> add new panel -> slam tool box plugin
- in rviz add map and set /map to topic, change durability policy TransientLocal
- save the map with rviz, serialize the map
- To store map as numpy array:
restart
run with localization and to save the map:
ros2 run rc_car ros_Get_map_client.py --ros-args -p map_name:=lab_demo
After Mapping restart the the robot
ros2 launch rc_car localization.launch.py map:=demoe.yaml use_sim_time:=false
- in rviz, manually write "map" in fixed frame
- change set initial position
- add map
- topic->durability policy->transient local
ros2 run rc_car PathPlanning_service_prm.py --ros-args -p map_name:=map_world -p use_sime_time:=false
ros2 run rc_car PathPlanning_client.py 0 0 6.22 -4.5 path1 --ros-args -p use_sime_time:=false
Use the script py_path_loops_generator.py
NOTE - the path_name without the '_meter'
ros2 run rc_car ros_Path_Tracking.py --ros-args -p use_sime_time:=false -p show_path:=true -p show_marker:=true -p path_name:=demoe_path
ros2 ros2_control list_hardware_interfaces
How to stop the lidar?
ros2 launch rc_car rplidar.launch.py
ros2 service call /stop_motor std_srvs/srv/Empty "{}"
ros2 service call /start_motor std_srvs/srv/Empty "{}"
How to remap ros2 run teleop_twist_keyboard --ros-args -r /cmd_vel:=/diff_cont/cmd_vel_unstampted

