Skip to content

The control of four wheel car, mechanical arm and camera in rviz and gazebo

Notifications You must be signed in to change notification settings

CrescentVelvet/dancer_car

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dancer_car

The control of four wheel car, mechanical arm and camera in rviz and gazebo

使用指南

2018年初次接触ROS,做小车路径规划,使用Ubuntu16.04和ROS kinetic
2020年创建此仓库,做机器人爬起行走,使用Ubuntu18.04和ROS melodic
2023年改进此仓库,寻找Robotics实习,使用Ubuntu20.04和ROS noetic

系统配置

实验室大电脑

用虚拟机安装Ubuntu
在清华源下载Ubuntu20.04的iso文件
https://blog.csdn.net/weixin_45912291/article/details/108900602
安装虚拟机VMware Workstation 17 Pro
https://blog.csdn.net/weixin_45912291/article/details/108894737
VMware许可证密钥MC60H-DWHD5-H80U9-6V85M-8280D
在虚拟机中安装Ubuntu20.04
https://blog.csdn.net/weixin_45912291/article/details/108901106
全名crescent_velvet
用户名velvet
密码123
虚拟机名称Ubuntu20.04
安装在C盘,硬盘50G,内存8G,处理器2*2

笔记本小电脑

直接安装双系统Ubuntu
使用U盘制作Ubuntu20.04启动盘

Ubuntu系统

进入Ubuntu,更新software,安装code
配置软件源

sudo apt update
cp /etc/apt/sources.list ~/Desktop
sudo gedit /etc/apt/sources.list

将全部内容替换为

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

用sudo权限保存

报错The repository 'http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal Release' is not signed
是因为没有数字签名,无法安全地用清华源更新,所以默认禁用该源
https://blog.csdn.net/Netceor/article/details/118655603
打开网址http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
将安装证书内容复制保存为ros.asc文件,解决

sudo apt-key add ros.asc
sudo apt update

报错Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal/universe/binary-i386/Packages 404 Not Found [IP: 101.6.15.130 443]
是因为清华源里没有i386,更换华为源,解决
同样是修改/etc/apt/sources.list为

deb https://repo.huaweicloud.com/ubuntu/ focal main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal-updates main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal universe
deb https://repo.huaweicloud.com/ubuntu/ focal-updates universe
deb https://repo.huaweicloud.com/ubuntu/ focal-backports main restricted universe
deb https://repo.huaweicloud.com/ubuntu/ focal-security main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal-security universe

配置公钥

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update

报错keyserver receive failed: Server indicated a failure
不是公钥没有加入Ubuntu服务器,而是VMware还没联网,重启一下就好了

安装ROS
http://wiki.ros.org/cn/Installation/Ubuntu
配置软件源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

注意,系统软件源用了华为源,而ros软件源这里用了清华源,懒得改

sudo apt update
sudo apt install ros-noetic-desktop-full
apt search ros-noetic
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

安装构建依赖

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo rosdep init
rosdep update

报错The read operation timed out
是因为raw.githubusercontent.com被墙了
改用国内的rosdepc,解决

sudo apt install python3-pip
sudo pip install rosdepc
sudo rosdepc init
rosdep update

测试ROS是否安装成功
开启第一个终端,初始化ROS环境

roscore

开启第二个终端,启动图形化界面

rosrun turtlesim turtlesim_node

开启第三个终端,查看节点通信

rosrun rqt_graph rqt_graph

开启第四个终端,启动运动控制

rosrun turtlesim turtle_teleop_key

成功实现键盘控制小乌龟运动

报错Command 'roscore' not found
报错package 'turtlesim' not found
报错package 'rqt_graph' not found
是依赖项没安装,解决

sudo apt install ros-noetic-roslaunch
sudo apt install ros-noetic-ros-tutorials
sudo apt install ros-noetic-rqt-graph

报错Done checking log file disk usage. Usage is <1GB
是因为roslaunch安装错版本了
不应该sudo apt install python3-roslaunch,但也卸不掉,直接安装noetic版本,解决

sudo apt install ros-noetic-roslaunch

报错Command 'rosrun' not found
是依赖项没安装
不能按照提示安装sudo apt install rosbash,应该安装noetic版本,解决

sudo apt install ros-noetic-rosbash

配置Git密钥

git --version
git config --global user.name "velvet"
git config --global user.email "[email protected]"
git config --global --list
ssh-keygen -t rsa -C "[email protected]"
cat ~/.ssh/id_rsa.pub

复制到GitHub的SSH keys中,命名为ruby_1801newPC_ubuntu

虚拟机连接U盘

插入U盘,在VMware的菜单栏,选择虚拟机,选择可移动设备,选择小米U盘,选择连接虚拟机断开主机
U盘无法读取,因为虚拟机设置中只支持USB2.0
挂起状态无法编辑虚拟机设置,需要关机才行。在绿色三角形开启图标下,有关机选项,选择关机,放弃挂起状态,编辑虚拟机设置,修改USB兼容性为3.1,显示所有USB输入设备
虚拟机开机,在VMware的菜单栏,选择虚拟机,选择可移动设备,选择小米U盘,选择连接虚拟机断开主机,成功连接

环境配置

安装Ubuntu20.04,ros-noetic,gazebo,下载本仓库放入catkin_ws/src

mkdir ~/catkin_ws
mkdir ~/catkin_ws/src
cd ~/catkin_ws/src
git clone [email protected]:CrescentVelvet/dancer_car.git
cd ..
catkin_make
source devel/setup.bash

报错The specified source space "/home/velvet/catkin_ws/src/src" does not exist
是误入src文件夹了,cd ..,解决

报错Could not find a package configuration file provided by "controller_manager"
报错Could not find a package configuration file provided by "effort_controllers"
报错Could not find a package configuration file provided by "gazebo"
报错Could not find a package configuration file provided by "gazebo_plugins"
报错Could not find a package configuration file provided by "gazebo_ros"
报错Could not find a package configuration file provided by "gazebo_ros_control"
报错Could not find a package configuration file provided by "joint_state_controller"
报错Could not find a package configuration file provided by "robot_state_publisher"
报错Could not find a package configuration file provided by "joint_state_publisher"
报错Could not find a package configuration file provided by "joint_state_publisher_gui"
报错Could not find a package configuration file provided by "rqt_gui"
报错Could not find a package configuration file provided by "rviz"
报错Could not find a package configuration file provided by "xacro"
报错Could not find a package configuration file provided by "pr2_controller_manager"
报错Could not find a package configuration file provided by "fake_localization"
报错Could not find a package configuration file provided by "teleop_twist_keyboard"
是各种依赖项没安装,解决

sudo apt install ros-noetic-controller-manager
sudo apt install ros-noetic-effort-controllers
sudo apt install gazebo11
sudo apt install libgazebo11-dev
sudo apt install ros-noetic-gazebo-ros-pkgs
sudo apt install ros-noetic-gazebo-ros-control
sudo apt install ros-noetic-joint-state-controller
sudo apt install ros-noetic-robot-state-publisher
sudo apt install ros-noetic-joint-state-publisher
sudo apt install ros-noetic-joint-state-publisher-gui
sudo apt install ros-noetic-rviz
sudo apt install ros-noetic-xacro
sudo apt install ros-noetic-pr2-controller-manager
sudo apt install ros-noetic-fake-localization
sudo apt install ros-noetic-teleop-twist-keyboard
rosstack profile
rospack profile
rospack list

安装后依然报错找不到gazebo
估计是创建包时写的gazebo写错了,把~/catkin_ws/src/CMakeLists.txt,以及car_control,car_keyboard,car_model文件夹的CMakeLists.txt中find_package的gazebo删掉,解决

报错RLException: [display.launch] is neither a launch file in package [car_model] nor is [car_model] a launch file name
是因为忘记刷新了,source devel/setup.bash,解决

rviz

查看模型

cd ~/catkin_ws
roslaunch car_model display.launch

将Global Options的Fixed Frame选取为world_link
在左下角Add添加部件RobotModel和Camera
在冒出来的gui小窗口上控制关节转动
效果如图
RVIZ

找不到gui小窗口,先安装依赖包sudo apt install ros-noetic-joint-state-publisher-gui
将~/catkin_ws/src/dancer_car/car_model/launch/display.launch中的

  <arg name="gui" default="False" />
  <node name="joint_state_publisher"
    pkg="joint_state_publisher"
    type="joint_state_publisher" />

修改为

  <arg name="gui" default="True" />
  <node name="joint_state_publisher_gui"
    pkg="joint_state_publisher_gui"
    type="joint_state_publisher_gui" />

警告'state_publisher' executable is deprecated
将~/catkin_ws/src/dancer_car/car_model/launch/display.launch中的

  <node name="state_publisher"
    pkg="state_publisher"
    type="state_publisher" />

修改为

  <node name="robot_state_publisher"
    pkg="robot_state_publisher"
    type="robot_state_publisher" />

警告'use_gui' parameter was specified
没啥用,忽略

gazebo

加载场景地图

sudo scp -r ~/catkin_ws/src/dancer_car/car_model/worlds/car_world02.jpg /usr/share/gazebo-11/media/materials/textures/car_world.jpg
sudo scp -r ~/catkin_ws/src/dancer_car/car_model/worlds/gazebo.material /usr/share/gazebo-11/media/materials/scripts/gazebo.material

键盘控制小车

cd ~/catkin_ws
roslaunch car_model gazebo.launch

效果如图
GAZEBO
控制前进后退与转弯
|---|---|---|-------------|
| u | i | o | 左右方向前进 |
| j | k | l | 原地转与停止 |
| m | < | > | 左右方向后退 |
|---|---|---|-------------|
控制加速减速与角度
|---|---|----------------|
| q | a | 线速度加减速10% |
| w | s | 角速度加减速10% |
|---|---|----------------|
控制三根杆子运动
|---|---|-----------|
| r | t | 杆子一转动 |
| f | g | 杆子二摆动 |
| v | b | 杆子三转动 |
|---|---|-----------|

报错找不到gazebo/spawn_model
将~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中的

<!-- car model -->
  <node name="spawn_model"
    pkg="gazebo"

修改为

<!-- car model -->
  <node name="spawn_model"
    pkg="gazebo_ros"

报错找不到gazebo_world
将~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中的

  <include file="$(find gazebo_world)/launch/empty_world.launch">

修改为

  <include file="$(find gazebo_ros)/launch/empty_world.launch">

运行gazebo时黑屏
是进程没结束,以后要先关闭gazebo页面再Ctrl+C结束终端

killall gzserver

报错找不到robot_description
使用urdf文件时,在~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中添加

<param name="robot_description" textfile="$(find car_model)/robots/car_model.URDF"/>

使用xacro文件时,在~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中添加

<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find car_model)/robots/car_model.xacro'" />

警告KDL does not support a root link with an inertia
给root link添加一个不具有inertia的parent

警告Deprecated syntax
将~/catkin_ws/src/dancer_car/car_model/robots/car_model.xacro中的

  <transmission name="tran_column_link1">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_column_link1">
      <hardwareInterface>EffortJointInterface</hardwareInterface>

修改为

  <transmission name="tran_column_link1">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_column_link1">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>

报错new node registered with same name
是节点名称冲突,直接删掉~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中的

<include file="$(find pr2_controller_manager)/controller_manager.launch" />

报错Error in REST request,警告找不到api.ignitionfuel.org
将home/.ignition/fuel/config.yaml中的URL行的api.ignitionfuel.org修改为api.ignitionrobotics.org

小车各个零部件固定在原点一动不动,或者小车狂舞乱飞无法无天 是因为质量、摩擦力设置过小,PID参数设置有误,在~/catkin_ws/src/dancer_car/car_model/config/car_control.yaml中修改

报错cmd /opt/ros/melodic/lib/gazebo_ros/spawn_model 将~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中$(find car_model)/robots/car_model.URDF-urdf -model car_model"的urdf中间加个空格

control启动(控制吊杆运动)(无用)

roslaunch car_control robot_control.launch

手动输入指令(无用)

rostopic pub -1 /car_model/joint_column_link1_controller/command std_msgs/Float64 "data: 1.5"
rostopic pub -1 /car_model/joint_column_link2_controller/command std_msgs/Float64 "data: 1.5"
rostopic pub -1 /car_model/joint_column_link3_controller/command std_msgs/Float64 "data: 1.5"

输入指令为转动关节角度的弧度值[-PI,PI]
使用rqt发布指令(无用)

rosrun rqt_gui rqt_gui

在Topics中选择Message Publisher,
添加/car_model/joint_column_link1_controller/command
设置frequency为100Hz,设置data为sin(i/100)
添加/car_model/joint_column_link2_controller/command
设置frequency为100Hz,设置data为sin(i/100)*3
添加/car_model/joint_column_link3_controller/command
设置frequency为100Hz,设置data为sin(i/50)
在前面的框中打钩,控制杆子转动

报错RLException: roslaunch file contains multiple nodes named [/robot_state_publisher]

报错[ERROR] [1681570294.287918622, 0.644000000]: A controller named 'joint_state_controller' was already loaded inside the controller manager 是因为gazebo.launch启动了robot_control.launch,两个文件的控制器重名了,不需要启动robot_control.launch, 直接删掉~/catkin_ws/src/dancer_car/car_model/launch/gazebo.launch中的

  <include file="$(find car_control)/launch/robot_control.launch" />

在空白gazebo中添加模型

roslaunch gazebo_ros empty_world.launch

添加urdf模型文件

rosrun gazebo_ros spawn_model -file $(find car_model)/robots/car_model.URDF -urdf -z 1 -model car_model.URDF

添加xacro模型文件

rosrun gazebo_ros spawn_model -file $(find car_model)/robots/car_model.xacro -xacro -z 1 -model car_model.xacro

补充信息

建立模型

SolidWorks

插件安装
github上有sw2urdfSetup插件,可以将SolidWorks模型转换成urdf文件,但是原作者删除了exe版本,需要自己编译,或者可以在CSDN上下载exe版本
导出教程:https://zhuanlan.zhihu.com/p/114300275
安装在SolidWorks的安装文件夹内即可
转轴配置
对于装配体,选择file导出到urdf,在PropertyManager建立link和子link,选择对应的零部件
在FeatureManager,选择Insert ReferenceGeometry,选择Axis轴,圆柱体中心线,重命名
坐标系建立
在FeatureManager,选择Insert ReferenceGeometry,选择Point点,圆形中点
与转轴一起选中,插入Coordinate System,点击x轴前面的箭头调整方向,重命名
在Preview and Export里把每个link对应的转轴与坐标系选择好,输出为文件夹

urdf

安装urdf各种辅助功能插件

sudo apt install liburdfdom-tools

检查urdf有无语法错误

cd ~/catkin_ws/src/dancer_car/car_model/robots
check_urdf car_model.urdf

得到结果

robot name is: car_model
---------- Successfully Parsed XML ---------------
root Link: world_link has 1 child(ren)
    child(1):  car_body
        child(1):  column_link1
            child(1):  column_link2
                child(1):  column_link3
                    child(1):  camera_link
        child(2):  left_back_wheel
        child(3):  left_front_wheel
        child(4):  right_back_wheel
        child(5):  right_front_wheel

生成pdf图片文件展示urdf里的父子关系

cd ~/catkin_ws/src/dancer_car/car_model/robots
urdf_to_graphiz car_model.urdf

结果如图
URDF
urdf转换为sdf文件

cd ~/catkin_ws/src/dancer_car/car_model/robots
gz sdf -p car_model.urdf

xacro转换为urdf文件

cd ~/catkin_ws/src/dancer_car/car_model/robots
rosrun xacro xacro car_model.xacro > car_model.urdf

报错[rosrun] Couldn't find executable named xacro.py below /opt/ros/noetic/share/xacro
是因为xacro.py已被舍弃,改为xacro无后缀,即可
直接手写创建urdf模型文件
第一步,写link部件,计算collision碰撞,visual可视化,inertial转动惯量

  <link name="car_body">
    <collision>
      <origin
        xyz="0 0 ${car_c/2}"
        rpy="0 0 0" />
      <geometry>
        <box size="${car_a} ${car_b} ${car_c}" />
      </geometry>
    </collision>
    <visual>
      <origin
        xyz="0 0 ${car_c/2}"
        rpy="0 0 0" />
      <geometry>
        <box size="${car_a} ${car_b} ${car_c}" />
      </geometry>
      <material name="blue">
        <color rgba="0 0.5 0.8 1"/>
      </material>
    </visual>
    <inertial>
      <origin
        xyz="0 0 ${car_c/2}"
        rpy="0 0 0" />
      <mass value="${car_mass}" />
      <inertia
        ixx="${car_mass / 12.0 * (car_b*car_b + car_c*car_c)}"
        ixy="0.0"
        ixz="0.0"
        iyy="${car_mass / 12.0 * (car_a*car_a + car_c*car_c)}"
        iyz="0.0"
        izz="${car_mass / 12.0 * (car_a*car_a + car_b*car_b)}" />
    </inertial>
  </link>

第二步,写joint关节,用fixed固定和continuous活动来连接两个link,设置力矩和摩擦力

  <joint name="joint_column_link1" type="continuous">
    <axis xyz="0 0 1" rpy="0 0 0" />
    <parent link="car_body" />
    <child link="column_link1" />
    <origin xyz="${car_a/2-column_width} 0 ${car_c}" />
    <limit effort="100" velocity="100" />
    <joint_properties damping="0" friction="0" />
  </joint>

第三步,创建小车机械臂模型功能包car_model

cd ~/catkin_ws/src/dancer_car
catkin_create_pkg car_model joint_state_publisher robot_state_publisher rviz gazebo_plugins gazebo_ros gazebo_ros_control xacro car_control

第四步,把car_model.urdf文件放入~/catkin_ws/src/dancer_car/car_model/robots文件夹中
把display.launch和gazebo.launch文件都放入~/catkin_ws/src/dancer_car/car_model/launch文件夹中

xacro

urdf转换为xacro文件
第一步,在urdf文件开头添加

<robot name="car_model" xmlns:xacro="http://www.ros.org/wiki/xacro">

第二步,添加一个虚拟的世界坐标,用joint关节将小车和世界坐标连在一起

  <link name="world_link">
  </link>
  <joint name="joint_world" type="fixed">
    <parent link="world_link" />
    <child link="car_body" />
  </joint>

第三步,为每一个joint关节添加transmission驱动标签,使得关节能够被驱动控制
注意,这里的hardware_interface/PositionJointInterface是关节位置控制,直接控制关节运动的位置
而hardwareInterface/EffortJointInterface是关节力矩控制,如果inertial中的inertia转动惯量矩阵设置不对,机械臂就抬不起来

  <transmission name="tran_column_link1">
    <!-- 指定传动类型 -->
    <type>transmission_interface/SimpleTransmission</type>
    <!-- 传动系统所连接的关节 -->
    <joint name="joint_column_link1">
     	<!-- 指定硬件接口,注意,当在Gazebo中加载此传动系统是,值应为EffortJointInterface -->
     	<!-- 而在RobotHW中加载此传动系统时,值应为hardware_interface/EffortJointInterface -->
      <!-- 另外,位置控制是JointPositionController,力矩控制是EffortJointInterface -->
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor_column_link1">
      <!-- 可选,指定硬件接口 -->
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <!-- 可选,指定关节制动器之间机械减速比,并非所有传动系统都需要此标签 -->
      <mechanicalReduction>1</mechanicalReduction>
      <motorTorqueConstant>1</motorTorqueConstant>
    </actuator>
  </transmission>

第四步,添加gazebo plugin插件
将ROS和gazebo仿真环境连接起来

  <gazebo>
    <plugin name="gazebo_ros_control" 
      filename="libgazebo_ros_control.so">
      <robotNamespace>/car_model</robotNamespace>
      <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
    </plugin>
  </gazebo>

第五步,添加gazebo reference插件
为gazebo中的小车机械臂设置颜色与摩擦力
之前link中设置的颜色只能在rviz中显示,不能在gazebo中显示

  <gazebo reference="column_link1">
    <mu1>0.2</mu1>
    <mu2>0.2</mu2>
    <material>Gazebo/Green</material>
  </gazebo>

第六步,修改display.launch文件中的读取模式

  <param name="robot_description"
    command="$(find xacro)/xacro --inorder '$(find car_model)/robots/car_model.xacro'" />

第七步,修改gazebo.launch文件中的读取模式

  <param name="robot_description"
    command="$(find xacro)/xacro --inorder '$(find car_model)/robots/car_model.xacro'" />

第八步,在~/catkin_ws/src/dancer_car/car_model/config文件夹下创建car_control.yaml参数文件,写入关节控制器的PID参数
注意,如果第三步transmission中用了关节位置控制,这里要用position_controllers/JointPositionController
如果transmission中用了关节力矩控制,这里要用effort_controllers/JointPositionController

  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50
  joint_column_link1_controller:
    type: effort_controllers/JointPositionController
    joint: joint_column_link1
    pid: {p: 10.0, i: 0.01, d: 0}

第九步,在gazebo.launch文件中添加一行
加载car_model里的car_control.yaml参数文件,而不是car_control里的robot_control.yaml
注意,不需要car_control控制功能包,xacro模型文件和yaml参数文件全都放进car_model模型功能包中即可

  <rosparam file="$(find car_model)/config/car_control.yaml" command="load"/>

第十步,在gazebo.launch文件中添加机械臂关节控制

  <node name="joint_controller_spawner" 
    pkg="controller_manager" 
    type="spawner" 
    respawn="false"
    output="screen" 
    ns="/car_model" 
    args="joint_state_controller 
          joint_column_link1_controller 
          joint_column_link2_controller
          joint_column_link3_controller"/>

第十一步,在gazebo.launch文件中添加小车速度控制

  <node name="control_vel"
    pkg="car_keyboard"
    type="car_keyboard.py"
    output="screen" />

总结一下,无需car_control,用car_model里的yaml文件来控制机械臂运动,用car_keyboard里的py文件来控制小车运动
urdf
link: collision, visual, inertial
joint: axis, parent, child, origin, effort, friction
xacro
world_link, fixed joint
transmission: PositionJointInterface, EffortJointInterface
gazebo_ros_control
gazebo reference: mu1, mu2, material
yaml
joint_column_link1_controller: position_controllers, effort_controllers
launch
node: joint_controller_spawner, control_vel

仿真模型

catkin_create_pkg car_model joint_state_publisher robot_state_publisher rviz gazebo_plugins gazebo_ros gazebo_ros_control xacro car_control

编写xacro文件和launch文件,link与joint,以及collision、visual、inertial

控制模型

catkin_create_pkg car_control controller_manager joint_state_controller robot_state_publisher rqt_gui effort_controllers rviz gazebo_ros gazebo_plugins gazebo_ros_control xacro

编写yaml文件和launch文件,gazebo reference、transmission、gazebo plugin

运行检查

运行rviz或gazebo时,开启ROS QT可视化工具显示节点node状态关系图

rosrun rqt_graph rqt_graph
rostopic pub -1 /car_model/joint_column_link1_controller/command std_msgs/Float64 "data: 1.5"

全部节点如图
RQT-active
当前节点如图
RQT-only
列出所有node订阅和发布topic的信息
查看node在指定topic上发布的数据及类型

rostopic list -v
rostopic echo <topic>
rostopic type <topic>

查看node输出信息

rosrun rqt_console rqt_console

控制指令

sin(i/rate*speed)*diff + offset
rate是频率,speed是速度系数,diff是上下界之差,offset是上界减去diff

About

The control of four wheel car, mechanical arm and camera in rviz and gazebo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published