- Notifications
You must be signed in to change notification settings - Fork7
waveshareteam/ugv_ws
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
1.Environment
- pc software:VMware Workstation 17Pro、mobarxterm
- ugv Version:UGV ROVER、UGV BEAST
2.Architecture
project:https://github.com/DUDULRX/ugv_ws/tree/ros2-humble
gitclone-bros2-humble-develophttps://github.com/DUDULRX/ugv_ws.git
First compilation on the virtual machine (compiling one by one on the pi or jetson)
cd/home/ws/ugv_ws.build_first.sh
build_first.sh content
cd/home/ws/ugv_wscolconbuild--packages-selectapriltagapriltag_msgsapriltag_roscartographercostmap_converter_msgscostmap_converteremcl2explore_liteopenslam_gmappingslam_gmappingldlidarrf2o_laser_odometryrobot_pose_publisherteb_msgsteb_local_plannervizantivizanti_cppvizanti_demosvizanti_msgsvizanti_serverugv_base_nodeugv_interfacecolconbuild--packages-selectugv_bringupugv_chat_aiugv_descriptionugv_gazebougv_navugv_slamugv_toolsugv_visionugv_web_app--symlink-installecho"source /opt/ros/humble/setup.bash">>~/.bashrcecho "eval"$(register-python-argcomplete ros2)"" >> ~/.bashrcecho "eval"$(register-python-argcomplete colcon)"" >> ~/.bashrcecho "source/home/ws/ugv_ws/install/setup.bash">>~/.bashrcsource~/.bashrc
Daily compilation of virtual machines (one by one on the car)
cd/home/ws/ugv_ws.build_common.sh
build_common.sh content
cd/home/ws/ugv_wscolconbuild--packages-selectapriltagapriltag_msgsapriltag_roscartographercostmap_converter_msgscostmap_converteremcl2explore_liteopenslam_gmappingslam_gmappingldlidarrf2o_laser_odometryrobot_pose_publisherteb_msgsteb_local_plannervizantivizanti_cppvizanti_demosvizanti_msgsvizanti_serverugv_base_nodeugv_interfacecolconbuild--packages-selectugv_bringupugv_chat_aiugv_descriptionugv_gazebougv_navugv_slamugv_toolsugv_visionugv_web_app--symlink-installsourceinstall/setup.bash
Compile apriltag
cd/home/ws/ugv_ws.build_apriltag.sh
build_apriltag.sh content
cd/home/ws/ugv_ws/src/ugv_else/apriltag_ros/apriltagcmake-Bbuild-DCMAKE_BUILD_TYPE=Releasecmake--buildbuild--targetinstallcd/home/ws/ugv_ws
Ubuntu software:
Install according to wiki install ros2 humble
apt-getupdateapt-getupgradeaptinstallpython3-pipapt-getinstallalsa-utilsaptinstallpython3-colcon-argcompleteaptinstallros-humble-cartographer-*aptinstallros-humble-desktop-*aptinstallros-humble-joint-state-publisher-*aptinstallros-humble-nav2-*aptinstallros-humble-rosbridge-*aptinstallros-humble-rqt-*aptinstallros-humble-rtabmap-*aptinstallros-humble-usb-camaptinstallros-humble-depthai-*#Simulationvirtualmachineinstallationaptinstallgazeboaptinstallros-humble-gazebo-*
Python3 Library:
domestic
cd~/ugv_wspython3-mpipinstall-rrequirements.txt-i https://pypi.tuna.tsinghua.edu.cn/simple
foreign
cd~/ugv_wspython3-mpipinstall-rrequirements.txt
requirements.txt content
pyserialflaskmediapiperequests
Feature pack ugv_ws
ugv_main Main functions
ugv_base_node Two-wheel differential kinematics
ugv_bringup drive, control
ugv_chat_ai web ai interaction
ugv_description Model
ugv_gazebo simulation
ugv_interface Information interface
ugv_nav navigation
ugv_slam Mapping
ugv_tools tool
ugv_vision visual interaction
ugv_web_app web
ugv_else ( ugv_main dependence)
apriltag_ros
cartographer
costmap_converter
emcl_ros2
explore_lite
gmapping
ldlidar
rf2o_laser_odometry
robot_pose_publisher
teb_local_planner
vizanti
3.Use (ros packages on the car are all executed in docker)
use_rviz optional true, false (default)
car model optional rasp_rover, ugv_rover, ugv_beast
lidar model optional ld06, ld19 (default), stl27l
Start the car and turn off the auto-start script.
sudokillall-9python
Enter docker and start ssh to remotely access docker and the visual interface
Car settings docker
Remote to docker
#usernameroot#Passwordneedstobesetinadvancews
Enter workspace
cd/home/ws/ugv_ws
View model joints
rasp_rover
exportUGV_MODEL=rasp_rover
start up
ros2launchugv_descriptiondisplay.launch.pyuse_rviz:=true
ugv_rover
exportUGV_MODEL=ugv_rover
start up
ros2launchugv_descriptiondisplay.launch.pyuse_rviz:=true
ugv_beast
exportUGV_MODEL=ugv_beast
start up
ros2launchugv_descriptiondisplay.launch.pyuse_rviz:=true
Drive the car (can control the pan/tilt and LED lights)
ros2runugv_bringupugv_driver
Drag the slider related to the joint angle publisher to control the gimbal
Control the light data 0-255 data[0] control the light IO4 near the oak camera data[1] control the light IO5 near the usb camera
ros2topicpub/ugv/led_ctrlstd_msgs/msg/Float32MultiArray"{data: [0, 0]}"-1
Chassis driver (executed within docker)
If you switch to another radar, modify
exportLDLIDAR_MODEL=
Use radar as imu sensor data (more stable)
ros2launchugv_bringupbringup_lidar.launch.pyuse_rviz:=true
Rotate the car in place to check the posture
Joystick, keyboard control
Start the car
ros2launchugv_bringupbringup_lidar.launch.pyuse_rviz:=true
Visual interaction
Start the car
ros2launchugv_bringupbringup_lidar.launch.pyuse_rviz:=true
Start related interfaces
control car
ros2runugv_toolsbehavior_ctrl
Turn on the camera, easy
ros2runusb_camusb_cam_node_exe
Turn on the camera and remove distortion
ros2launchugv_visioncamera.launch.py
Monocular
Apriltag control
apriltag only sets tag36h11, which can be modified by yourself
Apriltag control
1 2 3 4 Right, left, front and rear, other stops
ros2runugv_visionapriltag_ctrl
Apriltag Simple tracking
Select the left and right according to the x coordinate of the center point of the ar tag. After centering, select the front and rear according to the y coordinate. If the y is upward, the front is forward, and if the y is downward, the rear is
ros2runugv_visionapriltag_track_0
Apriltag Target tracking (AR code needs to specify size 0.08)
pose recognition
Here, the previous command to turn on the camera is turned off and replaced with the following
ros2launchugv_visionapriltag_track.launch.py
Simply drive to the target point (rotate, go straight)
Turn on tracking
ros2runugv_visionapriltag_track_1
command line
ros2topicpub/apriltag/trackstd_msgs/msg/Int8-1
Combine nav2 to drive to the target point (you need to close the previous startup file and change to open nav)
Turn on navigation
ros2launchugv_navnav.launch.pyuse_rviz:=true
Turn on tracking
ros2runugv_visionapriltag_track_2
Mapping
2D (LiDAR)
Gmapping
ros2launchugv_slamgmapping.launch.pyuse_rviz:=true
control car
ros2runugv_toolskeyboard_ctrl
save map
./save_2d_gmapping_map.sh
save_2d_gmapping_map.sh内容
cd/home/ws/ugv_ws/src/ugv_main/ugv_nav/mapsros2runnav2_map_servermap_saver_cli-f./map
Cartographer
ros2launchugv_slamcartographer.launch.pyuse_rviz:=true
control car
ros2runugv_toolskeyboard_ctrl
save map
./save_2d_cartographer_map.sh
save_2d_cartographer_map.sh内容
cd/home/ws/ugv_ws/src/ugv_main/ugv_nav/mapsros2runnav2_map_servermap_saver_cli-f./map&&ros2servicecall/write_statecartographer_ros_msgs/srv/WriteState"{filename: '/home/ws/ugv_ws/src/ugv_main/ugv_nav/maps/map.pbstream'}"
3D (lidar + depth camera)
Rtabmap
Rtabmap_viz Visualization
ros2launchugv_slamrtabmap_rgbd.launch.pyuse_rviz:=false
control car
ros2runugv_toolskeyboard_ctrl
Rviz Visualization
ros2launchugv_slamrtabmap_rgbd.launch.pyuse_rviz:=true
control car
ros2runugv_toolskeyboard_ctrl
After the mapping is completed, directly press ctrl+c to exit the mapping node, and the system will automatically save the map. Map default save path ~/.ros/rtabmap.db
Navigation
2D
Local localization
use_localization amcl(default),emcl,cartographer
amcl
Start first, you need to manually specify the approximate initial position
ros2launchugv_navnav.launch.pyuse_localization:=amcluse_rviz:=true
Then by controlling the car, simply move and rotate to assist in initial positioning.
ros2runugv_toolskeyboard_ctrl
emcl
After startup, you need to manually specify the approximate initial position
ros2launchugv_navnav.launch.pyuse_localization:=emcluse_rviz:=true
cartographer
Note that you need to use Cartographer to build the map before you can proceed.
ros2launchugv_navnav.launch.pyuse_localization:=cartographeruse_rviz:=true
After startup, if the accurate position has not been located, you can control the car and simply move it to assist in the initial positioning.
ros2runugv_toolskeyboard_ctrl
Local navigation
use_localplan dwa,teb(default)
dwa
ros2launchugv_navnav.launch.pyuse_localplan:=dwause_rviz:=true
teb
ros2launchugv_navnav.launch.pyuse_localplan:=tebuse_rviz:=true
3D
- Rtabmap
Local navigation
Turn on positioning
ros2launchugv_navrtabmap_localization_launch.py
Turn on nav (you can wait slowly until the 3D data is loaded before navigating, it will take a while)
use_localplan dwa,teb(default)
dwa
ros2launchugv_navnav_rtabmap.launch.pyuse_localplan:=dwause_rviz:=true
teb
ros2launchugv_navnav_rtabmap.launch.pyuse_localplan:=tebuse_rviz:=true
- Rtabmap
Mapping and navigation are enabled at the same time (two-dimensional)
ros2launchugv_navslam_nav.launch.pyuse_rviz:=true
Web ai interaction
Start the car
ros2launchugv_bringupbringup_lidar.launch.pyuse_rviz:=true
Start related interfaces
ros2runugv_toolsbehavior_ctrl
Web ai Interaction (requires relevant ai interface, currently ollama local deployment)
ros2runugv_chat_aiapp
Web side control
Drive the car first, refer to the above chassis drive, map construction and navigation, and start mapping and navigation at the same time.
ugv web
ros2launchugv_web_appbringup.launch.pyhost:=ip
Command interaction
ros2runugv_toolsbehavior_ctrl
Basic control (you need to put the car down and run, and judge whether the goal has been completed based on the odometer)
ros2launchugv_bringupbringup_lidar.launch.pyuse_rviz:=true
Forward data unit meters
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"drive_on_heading\", \"data\": 0.1}]'}"
Back data unit meters
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"back_up\", \"data\": 0.1}]'}"
Rotation data unit degree ,positive number left rotation, negative number right rotation
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"spin\", \"data\": -1}]'}"
Stop
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"stop\", \"data\": 0}]'}"
Navigation needs to be enabled below
ros2launchugv_navnav.launch.pyuse_rviz:=true
Get current point position
ros2topic echo/robot_pose--once
Save as navigation point
data Navigation point name, optional a-g
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"save_map_point\", \"data\": \"a\"}]'}"
Move to navigation point
data Navigation point name, optional a-g
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"pub_nav_point\", \"data\": \"a\"}]'}"
The saved points will also be stored in the file.
Gazebo comprehensive simulation (executed on virtual machine)
cd~/.gazebo/gitclone https://github.com/osrf/gazebo_models.git modelscp-r/home/ws/ugv_ws/src/ugv_main/ugv_gazebo/models/worldmodelscp/home/ws/ugv_ws/ugv_description.zipmodelscd~/.gazebo/models/unzipugv_description.ziprm-rfugv_description.zip
View model
rasp_rover
exportUGV_MODEL=rasp_rover
start up
ros2launchugv_gazebodisplay.launch.py
ugv_rover
exportUGV_MODEL=ugv_rover
start up
ros2launchugv_gazebodisplay.launch.py
ugv_beast
exportUGV_MODEL=ugv_beast
start up
ros2launchugv_gazebodisplay.launch.py
Load model
The following takes ugv_rover as an example
Specify model
exportUGV_MODEL=ugv_rover
start up
ros2launchugv_gazebobringup.launch.py
Joystick, keyboard control
Mapping
2D (LiDAR)
Gmapping
ros2launch ugv_gazebo gmapping.launch.py
control car
ros2runugv_toolskeyboard_ctrl
save map
./save_2d_gmapping_map_gazebo.sh
save_2d_gmapping_map_gazebo.sh content
cd/home/ws/ugv_ws/src/ugv_main/ugv_gazebo/mapsros2runnav2_map_servermap_saver_cli-f./map
Cartographer
ros2launch ugv_gazebo cartographer.launch.py
control car
ros2runugv_toolskeyboard_ctrl
save map
./save_2d_cartographer_map_gazebo.sh
save_2d_cartographer_map_gazebo.sh content
cd/home/ws/ugv_ws/src/ugv_main/ugv_gazebo/mapsros2runnav2_map_servermap_saver_cli-f./map&&ros2servicecall/write_statecartographer_ros_msgs/srv/WriteState"{filename: '/home/ws/ugv_ws/src/ugv_main/ugv_gazebo/maps/map.pbstream'}"
3D (lidar + depth camera)
Rtabmap
Rtabmap_viz Visualization
ros2launchugv_gazebortabmap_rgbd.launch.py
control car
ros2runugv_toolskeyboard_ctrl
Rviz Visualization
ros2launchugv_gazebortabmap_rgbd.launch.pyuse_rviz:=true
control car
ros2runugv_toolskeyboard_ctrl
After the mapping is completed, directly press ctrl+c to exit the mapping node, and the system will automatically save the map. Map default save path ~/.ros/rtabmap.db
Navigation
2D
Local positioning
use_localization amcl(default),emcl,cartographer
amcl
Start first, you need to manually specify the approximate initial position
ros2launchugv_gazebonav.launch.pyuse_localization:=amcl
Then by controlling the car, simply move and rotate to assist in initial positioning.
ros2runugv_toolskeyboard_ctrl
emcl
After startup, you need to manually specify the approximate initial position
ros2launchugv_gazebonav.launch.pyuse_localization:=emcl
cartographer
Note that you need to use Cartographer to build the map before you can proceed.
ros2launchugv_gazebonav.launch.pyuse_localization:=cartographer
After startup, if the accurate position has not been located, you can control the car and simply move it to assist in the initial positioning.
ros2runugv_toolskeyboard_ctrl
Local navigation
use_localplan dwa,teb(默认)
dwa
ros2launchugv_gazebonav.launch.pyuse_localplan:=dwa
teb
ros2launchugv_gazebonav.launch.pyuse_localplan:=teb
3D
- Rtabmap
Local navigation
Turn on positioning
ros2launchugv_gazebortabmap_localization_launch.py
Turn on nav (you can wait slowly until the 3D data is loaded before navigating, it will take a while)
use_localplan dwa,teb(默认)
dwa
ros2launchugv_gazebonav_rtabmap.launch.pyuse_localplan:=dwa
teb
ros2launchugv_ngazebonav_rtabmap.launch.pyuse_localplan:=teb
- Rtabmap
Mapping and navigation are enabled at the same time (two-dimensional)
ros2launchugv_gazeboslam_nav.launch.py
Automatic exploration (to be in a closed rule area)
ros2launchexplore_liteexplore.launch.py
Web ai interaction
Start related interfaces
ros2runugv_toolsbehavior_ctrl
web ai Interaction (requires relevant ai interface, currently ollama local deployment)
ros2runugv_chat_aiapp
Web control
ugv web
ros2launchugv_web_appbringup.launch.pyhost:=ip
Command interaction
ros2runugv_toolsbehavior_ctrl
Basic control (you need to put the car down and run, and judge whether the goal has been completed based on the odometer)
Forward data unit meters
ros2actionsend_goal/behaviorugv_interface/action/Behavior "{command: '[{\"T\": 1, \"type\": \"drive_on_heading\", \"data\": 0.5}]'}”
Back data unit meters
ros2actionsend_goal/behaviorugv_interface/action/Behavior "{command: '[{\"T\": 1, \"type\": \"back_up\", \"data\": 0.5}]'}”
Rotation data unit degree positive number rotate right, negative number rotate left
ros2actionsend_goal/behaviorugv_interface/action/Behavior "{command: '[{\"T\": 1, \"type\": \"spin\", \"data\": -1}]'}”
Stop
ros2actionsend_goal/behaviorugv_interface/action/Behavior "{command: '[{\"T\": 1, \"type\": \"spin\", \"data\": 0}]'}”
Navigation needs to be enabled below
ros2launchugv_gazebonav.launch.pyuse_rviz:=true
Get current point position
ros2topic echo/robot_pose--once
Save as navigation point
data navigation point name, optional a-g
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"save_map_point\", \"data\": \"a\"}]'}"
Move to navigation point
data navigation point name, optional a-g
ros2actionsend_goal/behaviorugv_interface/action/Behavior"{command: '[{\"T\": 1, \"type\": \"pub_nav_point\", \"data\": \"a\"}]'}"
The saved points will also be stored in the file.