Simon Shi的小站

人工智能,机器学习, 强化学习,大模型,自动驾驶

0%

ROS2 Ackerman Car (小白学移动机器人)

car code

1
2
3
4
└──src
    ├── mbot_bringup
    ├── mbot_description
    └──sllidar_ros2-humble

编译

1
2
3
4
5
cd ~/ros2_ws
colcon build # 一起编译,若出现编译错误,可以单个单个编译功能包
colcon build --packages-select mbot_description
colcon build --packages-select mbot_bringup
colcon build --packages-select sllidar_ros2

刷新

1
2
3
source ~/ros2_ws/install/setup.bash
or
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc

端口配置

1
2
cd /etc/udev/rules.d/
sudo vi 99-robot-usb.rules
1
2
3
4
5
6
KERNELS=="1-1", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523",
SYMLINK+="mbot",MODE:="0777"
KERNELS=="6-1", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",
SYMLINK+="lidar",MODE:="0777"
KERNELS=="5-1", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",
SYMLINK+="camera",MODE:="0777"

查看串口设备

1
2
3
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)

ls /dev | grep ttyUSB

Serial

/dev/serial

1
2
3
4
5
6
7
8
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2':
KERNELS=="1-1.2"
ATTRS{idVendor}=="1a86"
ATTRS{devspec}=="(null)"
ATTRS{devpath}=="1.2"
ATTRS{idProduct}=="7523"

KERNELS=="1-1.2",ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523",SYMLINK+="mbot", MODE:="0777"
Lidar
1
2
3
KERNELS=="1-1.1", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="lidar", MODE:="0777"

KERNELS=="1-1", ATTRS{idVendor}=="2109", ATTRS{idProduct}=="3431", SYMLINK+="lidar", MODE:="0777"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{speed}=="480"
ATTRS{authorized}=="1"
ATTRS{bMaxPower}=="100mA"
ATTRS{devspec}=="(null)"
ATTRS{product}=="USB2.0 Hub"
ATTRS{busnum}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bDeviceSubClass}=="00"
ATTRS{idVendor}=="2109"
ATTRS{bConfigurationValue}=="1"
ATTRS{rx_lanes}=="1"
ATTRS{tx_lanes}=="1"
ATTRS{quirks}=="0x0"
ATTRS{bcdDevice}=="0421"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bmAttributes}=="e0"
ATTRS{configuration}==""
ATTRS{devnum}=="2"
ATTRS{devpath}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{urbnum}=="38"
ATTRS{version}==" 2.10"
ATTRS{maxchild}=="4"
ATTRS{idProduct}=="3431"
ATTRS{removable}=="unknown"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bNumInterfaces}==" 1"

运行

1.线路都链接正确且正常(单片机->香橙派)(激光雷达->香橙派)
2.单片机正常且烧录好程序

mbot_with_lidar_launch.py

1
ros2 launch mbot_bringup mbot_with_lidar_launch.py

[mbot_bringup-1] [INFO] [1666446425.232926736] [mbot_bringup]: y_:-0.006942
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1666446425.233090570] [mbot_bringup]: th_:338.204911
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1666446425.253658500] [mbot_bringup]: dt:0.021006
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1666446425.253865001] [mbot_bringup]: x_:-0.004255
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1666446425.253914877] [mbot_bringup]: y_:-0.006942

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ubuntu@ubuntu:~/ros2_ws$ ros2 launch mbot_bringup mbot_with_lidar_launch.py
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2024-08-26-14-58-42-813855-ubuntu-2195
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mbot_bringup-1]: process started with pid [2197]
[INFO] [robot_state_publisher-2]: process started with pid [2199]
[INFO] [joint_state_publisher-3]: process started with pid [2201]
[INFO] [sllidar_node-4]: process started with pid [2203]
[robot_state_publisher-2] Parsing robot urdf xml string.
[robot_state_publisher-2] The root link base_link has an inertia specified in the URDF, but KDL does not support a root link with an inertia. As a w you can add an extra dummy link to your URDF.
[robot_state_publisher-2] Link lidar_link had 0 children
[robot_state_publisher-2] Link right_back_wheel had 0 children
[robot_state_publisher-2] Link left_back_wheel had 0 children
[robot_state_publisher-2] [INFO] [1724684323.340970547] [robot_state_publisher]: got segment base_link
[robot_state_publisher-2] [INFO] [1724684323.341309405] [robot_state_publisher]: got segment left_back_wheel
[robot_state_publisher-2] [INFO] [1724684323.341378643] [robot_state_publisher]: got segment lidar_link
[robot_state_publisher-2] [INFO] [1724684323.341410586] [robot_state_publisher]: got segment right_back_wheel
[sllidar_node-4] [INFO] [1724684323.348386895] [sllidar_node]: SLLidar running on ROS2 package SLLidar.ROS2 SDK Version:1.0.1, SLLIDAR SDK Version:2.
[sllidar_node-4] [INFO] [1724684323.402525357] [sllidar_node]: SLLidar S/N: DCA19DF1C3E39AC4C3E698F92C76340D
[sllidar_node-4] [INFO] [1724684323.402664611] [sllidar_node]: Firmware Ver: 1.27
[sllidar_node-4] [INFO] [1724684323.402700369] [sllidar_node]: Hardware Rev: 5
[sllidar_node-4] [INFO] [1724684323.454031586] [sllidar_node]: SLLidar health status : 0
[sllidar_node-4] [INFO] [1724684323.454176081] [sllidar_node]: SLLidar health status : OK.
[joint_state_publisher-3] [INFO] [1724684324.977991460] [joint_state_publisher]: Waiting for robot_description to be published on the robot_descripti.
[sllidar_node-4] [ERROR] [1724684327.485681561] [sllidar_node]: Can not start scan: 80008000!
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[mbot_bringup-1] [INFO] [1724684379.574944583] [rclcpp]: signal_handler(signal_value=2)
[mbot_bringup-1] [INFO] [1724684379.575556968] [mbot_bringup]: dt:56.246054
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1724684379.575648558] [mbot_bringup]: x_:0.000000
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1724684379.575687038] [mbot_bringup]: y_:0.000000
[mbot_bringup-1]
[mbot_bringup-1] [INFO] [1724684379.575721333] [mbot_bringup]: th_:0.000000
[mbot_bringup-1]
[robot_state_publisher-2] [INFO] [1724684379.576430992] [rclcpp]: signal_handler(signal_value=2)
[INFO] [robot_state_publisher-2]: process has finished cleanly [pid 2199]
[INFO] [mbot_bringup-1]: process has finished cleanly [pid 2197]
[INFO] [joint_state_publisher-3]: process has finished cleanly [pid 2201]
[sllidar_node-4] [INFO] [1724684381.596310322] [sllidar_node]: Stop motor
[INFO] [sllidar_node-4]: process has finished cleanly [pid 2203]

mob_launch.py

1
$ros2 launch mbot_bringup mbot_launch.py

log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2024-08-26-14-59-50-148695-ubuntu-2270
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mbot_bringup-1]: process started with pid [2272]
[INFO] [robot_state_publisher-2]: process started with pid [2274]
[INFO] [joint_state_publisher-3]: process started with pid [2276]
[robot_state_publisher-2] Parsing robot urdf xml string.
[robot_state_publisher-2] The root link base_link has an inertia specified in the URDF, but KDL does not support a root link with an inertia. As a w you can add an extra dummy link to your URDF.
[robot_state_publisher-2] Link lidar_link had 0 children
[robot_state_publisher-2] Link right_back_wheel had 0 children
[robot_state_publisher-2] Link left_back_wheel had 0 children
[robot_state_publisher-2] [INFO] [1724684390.636906578] [robot_state_publisher]: got segment base_link
[robot_state_publisher-2] [INFO] [1724684390.637204512] [robot_state_publisher]: got segment left_back_wheel
[robot_state_publisher-2] [INFO] [1724684390.637258713] [robot_state_publisher]: got segment lidar_link
[robot_state_publisher-2] [INFO] [1724684390.637289175] [robot_state_publisher]: got segment right_back_wheel
[joint_state_publisher-3] [INFO] [1724684392.267731058] [joint_state_publisher]: Waiting for robot_description to be published on the robot_descripti.

Ref

Wexin 搭建ROS小车文章汇总 白茶 l 清欢 小白学移动机器人

# ros2-control系列教程(4) 控制管理器-运行整个框架

# 搭建ROS小车文章汇总

# ROS机器人启动功能包

# ROS机器人建图导航测试

# ROS机器人建图导航测试

ros app 下载、ros android app下载、ROS机器人控制app下载-CSDN博客

开源:

Releases · ROS-Mobile/ROS-Mobile-Android · GitHub

Other People:

android app控制ros机器人一_ros 机器人手机app-CSDN博客

linux系统下串口设备和串口号绑定_linux串口号重启后就会变-CSDN博客