ROS中没有/cmd_vel话题的解决办法

事情的起因: 看看奥特学园P282集https://www.bilibili.com/video/BV1Ci4y1L7ZZ?p=282&spm_id_from=pageDriver的时候,跟老师步骤都一样,但是rviz中就是找不到/cmd_vel话题。

解决办法如下:
检查自己的move.xacro(根据自己的文件名而定,即写有差速器插件的代码文件)
检查其中的这几个地方

	<!-- 每一个驱动轮都需要配置传动装置 -->
    <xacro:joint_trans joint_name="left2car" />    <!-- !!!! -->
    <xacro:joint_trans joint_name="right2car" />   <!-- !!!! -->
	<gazebo>
        <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
            <rosDebugLevel>Debug</rosDebugLevel>
            <publishWheelTF>true</publishWheelTF>
            <robotNamespace>/</robotNamespace>
            <publishTf>1</publishTf>
            <publishWheelJointState>true</publishWheelJointState>
            <alwaysOn>true</alwaysOn>
            <updateRate>100.0</updateRate>
            <legacyMode>true</legacyMode>
            <leftJoint>left2car</leftJoint> <!-- 左轮 -->   <!-- !!!! -->
            <rightJoint>right2car</rightJoint> <!-- 右轮 -->  <!-- !!!! -->
            <wheelSeparation>${
    
    car_radius * 2}</wheelSeparation> <!-- 车轮间距 -->
            <wheelDiameter>${
    
    lr_wheel_radius * 2}</wheelDiameter> <!-- 车轮直径 -->
            <broadcastTF>1</broadcastTF>
            <wheelTorque>30</wheelTorque>
            <wheelAcceleration>1.8</wheelAcceleration>
            <commandTopic>cmd_vel</commandTopic> <!-- 运动控制话题 -->
            <odometryFrame>odom</odometryFrame> 
            <odometryTopic>odom</odometryTopic> <!-- 里程计话题 -->
            <robotBaseFrame>base_foot</robotBaseFrame> <!-- 根坐标系 -->
        </plugin>
    </gazebo>

备注是!!!!的地方都要检查,这几个地方的参数就是你原来xacro文件里自己设置的关节名称
在这里插入图片描述
可以看到我这里分别使用left和right将${name}替换即可,也就是说 move.xacro 中的 joint_nameleftJointrightJoint 的参数都要按照你自己定义的关节名称来写。
PS:我当时rviz中找不到/cmd_vel话题,就是因为我原本的xacro文件中的left后面多了个空格,搞的三天都没有任何进展,请大家一定要仔细检查o(╥﹏╥)o

猜你喜欢

转载自blog.csdn.net/HuangChen666/article/details/120808349