解决办法:将joint_state_publisher的那个节点删去或注释掉
我的错因(猜测):xml文件并不是从上到下执行代码,
如果先执行了joint_state_publisher_gui节点,摄像头就不会抖动,
因为你给摄像头确定的第一个状态 由控制joint的图形化界面中 滚动条的滚动决定,
而joint_state_publisher发布的第二个状态 就是 这第一个状态,所以摄像头只有一个状态,就不会抖动;
如果先执行了joint_state_publisher节点,摄像头就会抖动,
因为你首先给摄像头确定了一个状态,
当你用图形化界面控制摄像头旋转时,就相当于给了它另一个状态,然后摄像头就在两个状态之间反复横跳。
原代码
<launch>
<!--urdf file-->
<param name="robot_description" textfile="$(find learning_urdf)/urdf/urdf/joint.urdf" />
<!--start rviz-->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find learning_urdf)/config/show_mycar.rviz" />
<!--start status publishing nodes-->
<node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" />
<!--add joint controlling node-->
<!--This node is used to check whether the joint runs correctly-->
<node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui" />
</launch>
修改之后的代码
<launch>
<!--urdf file-->
<param name="robot_description" textfile="$(find learning_urdf)/urdf/urdf/joint.urdf" />
<!--start rviz-->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find learning_urdf)/config/show_mycar.rviz" />
<!--start status publishing nodes-->
<!--删掉或者注释掉下面这行代码,我注释掉了-->
<!--<node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" />-->
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" />
<!--add joint controlling node-->
<!--This node is used to check whether the joint runs correctly-->
<node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui" />
</launch>