使用ros_arduino_bridge控制机器人底盘

使用ros_arduino_bridge控制机器人底盘

搭建了ROS分布式环境后,将ros_arduino_bridge功能包上传至Jetson nano,就可以在PC端通过键盘控制小车的运动了。实现流程如下:

  1. 系统准备;
  2. 下载程序;
  3. 程序修改;
  4. 分别启动PC与Jetson nano端相关节点,并实现运动控制。

1 系统准备

ros_arduino_bridge是依赖于python-serial功能包的,需要在Jetson nano端安装该功能包,安装命令:

powershell 复制代码
sudo apt-get install python-serial

2 下载程序

使用git命令从仓库中下载程序。

powershell 复制代码
https://gitee.com/xu783462354/ros_arduino_bridge.git

3 程序修改

ros_arduino_bridge的ROS端功能包主要是使用 ros_arduino_python,程序入口是该包launch目录下的arduino.launch文件,内容如下:

shell 复制代码
<launch>
   <node name="arduino" pkg="ros_arduino_python" type="arduino_node.py" output="screen">
      <rosparam file="$(find ros_arduino_python)/config/my_arduino_params.yaml" command="load" />
   </node>
</launch>

需要载入yaml格式的配置文件,该文件在 config 目录下已经提供了模板,只需要复制文件并按需配置即可,复制文件并重命名,配置如下:

yaml 复制代码
# For a direct USB cable connection, the port name is typically
# /dev/ttyACM# where is # is a number such as 0, 1, 2, etc
# For a wireless connection like XBee, the port is typically
# /dev/ttyUSB# where # is a number such as 0, 1, 2, etc.

port: /dev/ttyUSB0
baud: 57600
timeout: 0.1

rate: 50
sensorstate_rate: 10

use_base_controller: True
base_controller_rate: 10

# For a robot that uses base_footprint, change base_frame to base_footprint
base_frame: base_footprint

# === Robot drivetrain parameters
wheel_diameter: 0.065
wheel_track: 0.155
encoder_resolution: 1560 # from Pololu for 131:1 motors
#gear_reduction: 1.0
#motors_reversed: True

# === PID parameters
Kp: 2
Kd: 15
Ki: 0
Ko: 50
accel_limit: 1.0

# === Sensor definitions.  Examples only - edit for your robot.
#     Sensor type can be one of the follow (case sensitive!):
#	  * Ping
#	  * GP2D12
#	  * Analog
#	  * Digital
#	  * PololuMotorCurrent
#	  * PhidgetsVoltage
#	  * PhidgetsCurrent (20 Amp, DC)



sensors: {
  #motor_current_left:   {pin: 0, type: PololuMotorCurrent, rate: 5},
  #motor_current_right:  {pin: 1, type: PololuMotorCurrent, rate: 5},
  #ir_front_center:      {pin: 2, type: GP2D12, rate: 10},
  #sonar_front_center:   {pin: 5, type: Ping, rate: 10},
  arduino_led:          {pin: 13, type: Digital, rate: 5, direction: output}
}

4 测试

  • 创建工作空间,并进入工作空间编译。
powershell 复制代码
mkdir -p catkin_ws/src
cd ./catkin_ws
catkin_make
  • 将ros_arduino_bridge程序放入src目录中。
  • 再次进行编译。
powershell 复制代码
catkin_make
  • 在Jetson nano端启动 ros_arduino_bridge 节点。
  1. 刷新环境变量,运行ros节点

  2. 发现错误,需要添加权限

进入catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes,为文件添加权限。

powershell 复制代码
chmod +x ./*
  1. 运行ros_arduino_bridge节点
  • 在PC端启动键盘控制节点。
powershell 复制代码
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
  • 启动rviz查看数据
相关推荐
Mr.Winter`8 小时前
轨迹优化 | 基于激光雷达的欧氏距离场ESDF地图构建(附ROS C++仿真)
c++·人工智能·机器人·自动驾驶·ros·ros2·具身智能
Blossom.1181 天前
机器学习在智能制造业中的应用:质量检测与设备故障预测
人工智能·深度学习·神经网络·机器学习·机器人·tensorflow·sklearn
MidJourney中文版1 天前
深度报告:中老年AI陪伴机器人需求分析
人工智能·机器人
沫儿笙2 天前
ABB焊接机器人智能节气仪
人工智能·机器人
微小冷2 天前
二关节机器人系统模型推导
线性代数·机器人·概率论·推导·拉格朗日函数·二关节机器人·机器人控制系统的设计
kyle~2 天前
计算机视觉---RealSense深度相机技术
人工智能·数码相机·计算机视觉·机器人·嵌入式·ros·传感器
龙猫略略略2 天前
ros+px4仿真中的二维激光雷达消息
ros·px4·激光雷达
视觉语言导航2 天前
RAL-2025 | 清华大学数字孪生驱动的机器人视觉导航!VR-Robo:面向视觉机器人导航与运动的现实-模拟-现实框架
人工智能·深度学习·机器人·具身智能
BFT白芙堂2 天前
睿尔曼系列机器人——以创新驱动未来,重塑智能协作新生态(上)
人工智能·机器学习·机器人·协作机器人·复合机器人·睿尔曼机器人
Eric.Lee20212 天前
ROS2的topic桥接ROS1
ros·ros2到ros1桥接·ros的topic