本文主要是介绍gazebo抓取/轮式底盘仿真问题汇总,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
记录gazebo仿真中各种疑问
1、启动gazebo仿真环境后机器人不下落
<launch><arg name="world_name" default="worlds/empty.world"/><include file="$(find gazebo_ros)/launch/empty_world.launch" ><arg name="paused" value="true" /><arg name="gui" value="true"/><arg name="world_name" value="$(arg world_name)"/><arg name="debug" value="false"/></include><arg name="urdf_path" default="$(find lunyi_description)/urdf/lunyi_description.xacro"/><param name="robot_description" command="$(find xacro)/xacro --inorder $(arg urdf_path)"/><nodename="spawn_model"pkg="gazebo_ros"type="spawn_model"args="-urdf -param robot_description -model lunyi -z 0.17-J ur3_shoulder_lift_joint -1.57-J ur3_elbow_joint 1.57-J ur3_wrist_1_joint -1.57-J ur3_wrist_2_joint -1.57-J ur3_wrist_3_joint -1.57"output="screen" /><node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" /><node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
</launch>
上方代码中
args="-urdf -param robot_description -model lunyi -z 0.17
-z是让机器人在一定高度出现,我记得之前机器人出现之后,就会在重力的作用下,落到地面,但是今天机器人出现之后,直接悬浮在空中,死活不降落。
后来发现问题原因:
<?xml version="1.0" encoding="utf-8"?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) Commit Version: 1.6.0-4-g7f85cfe Build Version: 1.6.7995.38578For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot name="lunyi" xmlns:xacro="http://wiki.ros.org/xacro"><!-- <link name="world"/><joint name="w_b_joint" type="fixed"><origin xyz="0 0 0" rpy="0 0 0" /><parent link="world" /><child link="base_link" /></joint> -->
是因为我在xacro文件中加入了没有mass和inertia的world link, 导致机器人整个悬浮,去掉world就好了。
2、robotiq手抓在gazebo中无力下垂/乱转
我的环境是 ros melodic
先说无力下垂的原因:
<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro"><xacro:macro name="robotiq_85_gripper_transmission" params="prefix"><transmission name="${prefix}gripper_finger1_trans"><type>transmission_interface/SimpleTransmission</type><joint name="${prefix}gripper_finger1_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="${prefix}gripper_finger1_motor"><mechanicalReduction>1</mechanicalReduction><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></actuator></transmission><gazebo><!-- loading plugin: mimic joints works in gazebo now --><!-- libroboticsgroup_gazebo_mimic_joint_plugin.so --><!-- libgazebo_mimic_joint_plugin.so --><plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_1"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger2_joint</mimicJoint><!--multiplier>1.0</multiplier><offset>0.0</offset--></plugin><plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_2"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger2_inner_knuckle_joint</mimicJoint><!--multiplier>1.0</multiplier><offset>0.0</offset--></plugin><plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_3"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger1_inner_knuckle_joint</mimicJoint><!--multiplier>1.0</multiplier><offset>0.0</offset--></plugin><plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_4"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger1_finger_tip_joint</mimicJoint><multiplier>-1.0</multiplier><offset>0.0</offset></plugin><plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_5"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger2_finger_tip_joint</mimicJoint><multiplier>-1.0</multiplier><offset>0.0</offset></plugin></gazebo><gazebo><plugin name="gazebo_grasp_fix" filename="libgazebo_grasp_fix.so"><arm><arm_name>ur5_grasp_robot</arm_name><palm_link> ur3_wrist_3_link </palm_link><gripper_link>gripper_finger1_finger_tip_link</gripper_link><gripper_link>gripper_finger2_finger_tip_link</gripper_link><gripper_link>gripper_finger1_inner_knuckle_link</gripper_link><gripper_link>gripper_finger2_inner_knuckle_link</gripper_link><gripper_link>gripper_finger1_knuckle_link</gripper_link><gripper_link>gripper_finger2_knuckle_link</gripper_link></arm><forces_angle_tolerance>90</forces_angle_tolerance><update_rate>130</update_rate><grip_count_threshold>2</grip_count_threshold><max_grip_count>8</max_grip_count><release_tolerance>0.005</release_tolerance><disable_collisions_on_attach>true</disable_collisions_on_attach><contact_topic>__default_topic__</contact_topic></plugin></gazebo></xacro:macro></robot>
以上是robotiq_85_gripper/robotiq_85_description/urdf/robotiq_85_gripper.transmission.xacro
的内容,可以看到,mimic_joint 需要插件驱动。
先是参考了这位https://blog.csdn.net/qq_44642372/article/details/123995916。下载了roboticsgroup_gazebo_plugins-master, 经过编译之后,得到libroboticsgroup_gazebo_mimic_joint_plugin.so
, 然后在robotiq_85_gripper/robotiq_85_description/urdf/robotiq_85_gripper.transmission.xacro
中使用 libroboticsgroup_gazebo_mimic_joint_plugin.so
即改为:
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_1"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger2_joint</mimicJoint><!--multiplier>1.0</multiplier><offset>0.0</offset--></plugin>
可能有人到这一步就可以了,但是我加载进gazebo之后,夹抓可以正常一会,之后就开始某些关节疯狂转圈,然后我替换了另外一个插件:
libgazebo_mimic_joint_plugin.so
相应代码就是:
<plugin filename="libgazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_85_1"><joint>${prefix}gripper_finger1_joint</joint><mimicJoint>${prefix}gripper_finger2_joint</mimicJoint><!--multiplier>1.0</multiplier><offset>0.0</offset--></plugin>
这个插件需要编译的包是robotiq_85_gripper/robotiq_gazebo
,应该在robotiq_gripper包里,github可以搜到。
最后为改成这个就正常了。
其他参考https://blog.csdn.net/lejou_lee/article/details/109644533,这个我没尝试,可能也有用,用升级版的。
3、夹抓夹不起来物体
原因:工作空间的环境没有抓取的插件:libgazebo_grasp_fix.so
下载两个包到工作空间编译即可:gazebo-pkgs
和 general-message-pkgs
,在github应该可以搜到。
4、给轮子添加摩擦系数
<gazebo reference="lf_link2"><mu1>100000000</mu1><mu2>100000000</mu2><kp>100000000</kp><kd>1</kd><minDepth>0.01</minDepth><maxVel>100</maxVel> </gazebo>
5、给两轮添加差速控制器
<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>lb_joint</leftJoint><!--left_joint--><rightJoint>rb_joint</rightJoint><!--right_joint--><wheelSeparation>0.4985</wheelSeparation><!--wheel_separation--><wheelDiameter>0.305</wheelDiameter><!--wheel_diameter--><broadcastTF>1</broadcastTF><wheelTorque>30</wheelTorque><wheelAcceleration>1.8</wheelAcceleration><commandTopic>cmd_vel</commandTopic><odometryFrame>odom</odometryFrame> <odometryTopic>odom</odometryTopic><robotBaseFrame>base_link</robotBaseFrame><!--<odometrySource>world</odometrySource><publishTf>1</publishTf>--></plugin></gazebo>
参数含义:https://blog.csdn.net/qq_27865227/article/details/132506820
这篇关于gazebo抓取/轮式底盘仿真问题汇总的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!