Gazebo与RViz联合仿真时odom消失
-
@小鱼 有rqt_graph了 RViz中tf还是断开的
-
@924453613 你看这里,一个话题有两个发布者,robot_state_publisher都不知道听谁的,所以导致TF错误,按照我上一条回复把joint_state_publisher干掉试试。
-
@小鱼
干掉之后是这样的 RViz中tf还是断开的
-
@924453613 现在还是有两个发布者在发布joint_states,只需要一个gazebo即可,请按照之前帖子里的提示删掉arbotix控制器程序。
另外需要注意的是,arbotix的功能和urdf中配置的differential_drive_controller功能是相同(从两者的配置可以看出,都有轮子名称,轮子间距等配置),但differential_drive_controller才是用于gazebo仿真使用的。
-
@小鱼 感谢鱼总这么晚还在解答我的问题 我删除arbotix后 我重新查看tf树发现以下问题
1.odom到base_link断开
2.tf树与最初发布帖子时不同
rqt_graph如下
-
@924453613 首先恭喜你,离成功越来越近了,注意两轮差速模型的配置项
robotBaseFrame
,该项为其发布的joint_states参考的frame名称。<plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller"> <robotBaseFrame>base_footprint</robotBaseFrame> </plugin>
尝试进一步修改:
- 将
<robotBaseFrame>
的base_footprint
->base_link
,这样gazebo发布数据时应该会将base_link
->left/right_joint
- 尝试删除静态发布
footprint
->base_link
,因为在我看来,它也是多余的,两者之间的关系在URDF中已经给出。
<node name="tf_footprint_base" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 40" />
- 将
-
@小鱼 感谢鱼总,目前tf树仍有问题,夜已深鱼总早点休息,明早我会继续尝试,非常感谢。
-
@924453613 ok,目前看到对应的tf还是没有链接起来,需要注意的地方就是上文中提到的,可以多次修改尝试,祝早日成功,早点休息。
-
@小鱼 非常感谢鱼总的解答目前已经解决,问题大概率是出现在odom_rviz.launch中重复出现了/arbotix,导致tf树出错了,谢谢
-
@924453613 很高兴能够看到该问题被解决掉,如果方便可以贴一下解决后的代码在本帖子中,方便其他小伙伴在遇到相同问题提供帮助。
-
解决后代码:
irobot.urdf<?xml version="1.0" encoding="utf-8"?> <robot name="irobot"> <link name="base_link"> <inertial> <origin xyz="0.035298 6.2375E-05 0.0016857" rpy="0 0 0" /> <mass value="5" /> <inertia ixx="0.038" ixy="0" ixz="0" iyy="0.026" iyz="0" izz="0.06" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/base_link.STL" /> </geometry> <material name=""> <color rgba="0 0 0 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/base_link.STL" /> </geometry> </collision> </link> <link name="top_link"> <inertial> <origin xyz="-0.0050829 -0.00015289 0.0008765" rpy="0 0 0" /> <mass value="0.2" /> <inertia ixx="0.00081" ixy="0" ixz="0" iyy="0.00071" iyz="0" izz="0.0015" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/top_link.STL" /> </geometry> <material name=""> <color rgba="0 1 0 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/top_link.STL" /> </geometry> </collision> </link> <joint name="top_link2base_link" type="fixed"> <origin xyz="0 0 0.033795" rpy="0 0 0" /> <parent link="base_link" /> <child link="top_link" /> <axis xyz="0 -1 0" /> <limit lower="0" upper="0" effort="0" velocity="0" /> </joint> <link name="laser_link"> <inertial> <origin xyz="1.1845E-09 4.4075E-09 0.0030295" rpy="0 0 0" /> <mass value="0.1" /> <inertia ixx="4.11E-08" ixy="0" ixz="0" iyy="4.11E-08" iyz="0" izz="7.88E-08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/laser_link.STL" /> </geometry> <material name=""> <color rgba="1 0 0 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/laser_link.STL" /> </geometry> </collision> </link> <joint name="laser_link2base_link" type="fixed"> <origin xyz="0.155 0 0.038215" rpy="0 0 0" /> <parent link="base_link" /> <child link="laser_link" /> <axis xyz="0 -1 0" /> <limit lower="0" upper="0" effort="0" velocity="0" /> </joint> <link name="right_wheel"> <inertial> <origin xyz="-1.0317E-18 1.3878E-17 -1.7347E-18" rpy="0 0 0" /> <mass value="0.05" /> <inertia ixx="2.3E-05" ixy="0" ixz="0" iyy="4.3E-05" iyz="0" izz="2.3E-05" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/right_wheel.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/right_wheel.STL" /> </geometry> </collision> </link> <joint name="right_wheel2base_link" type="continuous"> <origin xyz="0 0.10045 -0.010735" rpy="0 0 0" /> <parent link="base_link" /> <child link="right_wheel" /> <axis xyz="0 -1 0" /> <limit lower="-3.14" upper="3.14" effort="100" velocity="2" /> </joint> <link name="left_wheel"> <inertial> <origin xyz="-1.1842E-18 0 -1.7347E-18" rpy="0 0 0" /> <mass value="0.05" /> <inertia ixx="2.3E-05" ixy="0" ixz="0" iyy="4.3E-05" iyz="0" izz="2.3E-05" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/left_wheel.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/left_wheel.STL" /> </geometry> </collision> </link> <joint name="left_wheel2base_link" type="continuous"> <origin xyz="0 -0.10045 -0.010735" rpy="0 0 0" /> <parent link="base_link" /> <child link="left_wheel" /> <axis xyz="0 -1 0" /> <limit lower="-3.14" upper="3.14" effort="100" velocity="2" /> </joint> <link name="driven_wheel"> <inertial> <origin xyz="0 -3.4443E-19 0" rpy="0 0 0" /> <mass value="0.02" /> <inertia ixx="1.27E-06" ixy="0" ixz="0" iyy="1.27E-06" iyz="0" izz="1.27E-06" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/driven_wheel.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://irobot/meshes/driven_wheel.STL" /> </geometry> </collision> </link> <joint name="driven_wheel2base_link" type="fixed"> <origin xyz="0.13 0 -0.031735" rpy="0 0 0" /> <parent link="base_link" /> <child link="driven_wheel" /> <axis xyz="0 -1 0" /> <limit lower="0" upper="0" effort="0" velocity="0" /> </joint> <link name="base_footprint"> <visual> <geometry> <sphere radius="0.001" /> </geometry> <material name=""> <color rgba="0 0 0 0" /> </material> </visual> </link> <joint name="base_link2base_footprint" type="fixed"> <parent link="base_footprint" /> <child link="base_link" /> <origin xyz="0 0 0.047" /> </joint> <!--color--> <gazebo reference="base_link"> <material>Gazebo/Black</material> </gazebo> <gazebo reference="top_link"> <material>Gazebo/Green</material> </gazebo> <gazebo reference="laser_link"> <material>Gazebo/Red</material> </gazebo> <gazebo reference="camera_link"> <material>Gazebo/Red</material> </gazebo> <gazebo reference="driven_wheel"> <material>Gazebo/White</material> </gazebo> <gazebo reference="left_wheel"> <material>Gazebo/White</material> </gazebo> <gazebo reference="right_wheel"> <material>Gazebo/White</material> </gazebo> <!-- controller --> <transmission name="left_wheel2base_link_trans"> <type>transmission_interface/SimpleTransmission</type> <joint name="left_wheel2base_link"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> </joint> <actuator name="left_wheel2base_link_motor"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="right_wheel2base_link_trans"> <type>transmission_interface/SimpleTransmission</type> <joint name="right_wheel2base_link"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> </joint> <actuator name="right_wheel2base_link_motor"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <gazebo> <plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller"> <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>left_wheel2base_link</leftJoint> <rightJoint>right_wheel2base_link</rightJoint> <wheelSeparation>0.277</wheelSeparation> <wheelDiameter>0.073</wheelDiameter> <broadcastTF>1</broadcastTF> <wheelTorque>30</wheelTorque> <wheelAcceleration>1.8</wheelAcceleration> <commandTopic>cmd_vel</commandTopic> <odometryFrame>odom</odometryFrame> <odometryTopic>odom</odometryTopic> <robotBaseFrame>base_footprint</robotBaseFrame> </plugin> </gazebo> <!--laser--> <gazebo reference="laser_link"> <sensor name="rplidar" type="ray"> <pose>0 0 0 0 0 0</pose> <visualize>true</visualize> <update_rate>5.5</update_rate> <ray> <scan> <horizontal> <samples>360</samples> <resolution>1</resolution> <min_angle>-3</min_angle> <max_angle>3</max_angle> </horizontal> </scan> <range> <min>0.10</min> <max>30.0</max> <resolution>0.01</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.01</stddev> </noise> </ray> <plugin filename="libgazebo_ros_laser.so" name="gazebo_rplidar"> <topicName>/scan</topicName> <frameName>laser_link</frameName> </plugin> </sensor> </gazebo> </robot>
odom_gazebo.launch
<launch> <include file="$(find gazebo_ros)/launch/empty_world.launch" /> <node name="spawn_model" pkg="gazebo_ros" type="spawn_model" args="-file $(find irobot)/urdf/irobot.urdf -urdf -model irobot" output="screen" /> <node name="fake_joint_calibration" pkg="rostopic" type="rostopic" args="pub /calibrated std_msgs/Bool true" /> </launch>
odom_rviz.launch
<launch> <param name="robot_description" textfile="$(find irobot)/urdf/irobot.urdf" /> <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" /> <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find irobot)/config/irobot.rviz" /> </launch>
-
-