利用Revolute Joint创建Motor

本文介绍如何将RevoluteJoint转换成Motor,并设置了关键参数,包括启用电机、设定旋转速度和最大扭矩,确保物体能够顺利越过最高点。

在上一篇中记录了如何创建Revolute Joint,现在在上一篇的基础上来修改Revolute Joint,使之变为一个Motor(动力装置,马达)。

主要代码:

var distanceBall:Ball = new Ball(10, new Point(300, 240), new Point(0, 0), new CircleSprite(), _container);
var revRect:Rect = new Rect(20, 100, new Point(300, 240), new Point(0, 0), new RectSprite(), _container);
var revCircle:Ball = new Ball(10, new Point(300, 150), new Point(0, 0), new CircleSprite(), _container);
var massData:b2MassData = new b2MassData();
massData.mass = 0;
revCircle.body.SetMass(massData);

_revoluteJointDef.Initialize(revCircle.body, revRect.body, new b2Vec2(300/PhyOption.PHYSCALE,150/PhyOption.PHYSCALE));
//motor可用
_revoluteJointDef.enableMotor = true;
//设置转动的速度,在此速度下,如果刚体无法越过其转动轨迹的最高点,则需要设置maxMotorTorque值更大。
_revoluteJointDef.motorSpeed = Math.PI / 3;
//maxMotorTorque值设置多大与转动速度无关,此值越大说明在当前转动速度下能越过轨迹最高点越容易。
_revoluteJointDef.maxMotorTorque = 200;
_revJoint = PhyOption.getInstance().world.CreateJoint(_revoluteJointDef) as b2RevoluteJoint;

var distantJointDef:b2DistanceJointDef = new b2DistanceJointDef();
var pos1:b2Vec2 = new b2Vec2();
pos1.x = revRect.body.GetPosition().x;
pos1.y = revRect.body.GetPosition().y + 50 / PhyOption.PHYSCALE;
var pos2:b2Vec2 = new b2Vec2();
pos2.x = distanceBall.body.GetPosition().x;
pos2.y = distanceBall.body.GetPosition().y;
distantJointDef.Initialize(revRect.body, distanceBall.body,pos1, pos2);
_distanceJoint = PhyOption.getInstance().world.CreateJoint(distantJointDef) as b2DistanceJoint;

先创建了一个球,用于创建一个Distance Joint。关键是第九到第十四行的设置。

1。要设置为Motor必须设置enableMotor为真。

2。设置转动的速度,单位是弧度每秒,此值直接反应转动的快慢。

3。设置最大的转矩,单位是焦耳,即力*距离,合力作用的距离所做的功的最大值。如果此值过小,则可能导致刚体无法越过其预期转动轨迹的最高点,此种情况下设置大的转动速度也无济于事,只能设置大的转矩。

具体的例子:

转载于:https://www.cnblogs.com/ywxgod/archive/2010/05/16/1736978.html

<?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.38578 For more information, please see http://wiki.ros.org/sw_urdf_exporter --> <robot name="liutestthree"> <link name="base_link"> <inertial> <origin xyz="-3.46944695195361E-18 -7.80625564189563E-18 -0.00242036559088666" rpy="0 0 0" /> <mass value="3144.78029709712" /> <inertia ixx="1.73375705311716" ixy="0" ixz="2.53473093365839E-17" iyy="1.61374376143613" iyz="1.88988761427752E-17" izz="3.33447160146723" /> </inertial> <visual> <geometry> <mesh filename="package://liutestthree/meshes/base_link.STL" /> </geometry> <material name=""> <color rgba="0.329411764705882 0.376470588235294 0.376470588235294 1" /> </material> </visual> <collision> <geometry> <mesh filename="package://liutestthree/meshes/base_link.STL" /> </geometry> </collision> </link> <link name="Empty_Link1"> <inertial> <origin xyz="1.86436151111153E-05 -0.0365378695655246 3.2881471692281E-05" rpy="0 0 0" /> <mass value="0.129478702853302" /> <inertia ixx="0.000140163975745107" ixy="2.38218895406492E-07" ixz="-1.07670497849909E-08" iyy="0.000212453783600004" iyz="1.30804126940922E-06" izz="0.000210749389122038" /> </inertial> <visual> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link1.STL" /> </geometry> <material name=""> <color rgba="0.670588235294118 0.623529411764706 1 1" /> </material> </visual> <collision> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link1.STL" /> </geometry> </collision> </link> <joint name="joint1" type="revolute"> <origin xyz="0 0 0.003475" rpy="-1.5708 0 2.4833" /> <parent link="base_link" /> <child link="Empty_Link1" /> <axis xyz="0 -1 0" /> <limit lower="-3.14" upper="3.14" effort="1000" velocity="10" /> <dynamics D="1" K="7000" damping="0.02" friction="1" mu_coulomb="0" mu_viscous="16" /> </joint> <link name="Empty_Link2"> <inertial> <origin xyz="0.0683925588904619 -8.04861490844694E-05 -0.00117086610566549" rpy="0 0 0" /> <mass value="0.0897038647705491" /> <inertia ixx="3.2331065480734E-05" ixy="3.93846951745817E-07" ixz="1.79834224415069E-05" iyy="0.000294676240765262" iyz="-1.42171786117114E-07" izz="0.00027985930464736" /> </inertial> <visual> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link2.STL" /> </geometry> <material name=""> <color rgba="0.329411764705882 0.376470588235294 0.376470588235294 1" /> </material> </visual> <collision> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link2.STL" /> </geometry> </collision> </link> <joint name="joint2" type="revolute"> <origin xyz="-0.0012 -0.052825 -0.009" rpy="-1.5708 0 -1.5708" /> <parent link="Empty_Link1" /> <child link="Empty_Link2" /> <axis xyz="0 0 -1" /> <limit lower="-1.57" upper="1.57" effort="300" velocity="10" /> <dynamics D="1" K="7000" damping="0.02" friction="0.5" mu_coulomb="0" mu_viscous="16" /> </joint> <link name="Empty_Link3"> <inertial> <origin xyz="0.0547788118603546 -2.34565884224894E-08 -0.00352685174366258" rpy="0 0 0" /> <mass value="0.0687023220678525" /> <inertia ixx="8.15992240342423E-06" ixy="-9.69245095436747E-12" ixz="2.60919750749482E-07" iyy="0.000152840397476826" iyz="2.15392101961929E-12" izz="0.000154310203930289" /> </inertial> <visual> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link3.STL" /> </geometry> <material name=""> <color rgba="0.792156862745098 0.819607843137255 0.933333333333333 1" /> </material> </visual> <collision> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link3.STL" /> </geometry> </collision> </link> <joint name="joint3" type="revolute"> <origin xyz="0.15 0 0.0018" rpy="0 0 0" /> <parent link="Empty_Link2" /> <child link="Empty_Link3" /> <axis xyz="0 0 1" /> <limit lower="-1.57" upper="1.57" effort="250" velocity="10" /> <dynamics D="1" K="7000" damping="0.02" friction="0.5" mu_coulomb="0" mu_viscous="16" /> </joint> <link name="Empty_Link4"> <inertial> <origin xyz="0.0370225551871837 1.67834496300756E-16 -0.00231721365976469" rpy="0 0 0" /> <mass value="0.0444887136834306" /> <inertia ixx="1.01953381225689E-05" ixy="5.02950087693639E-20" ixz="-1.70984131749591E-07" iyy="1.23320672521514E-05" iyz="6.85920310973725E-20" izz="5.57822073343811E-06" /> </inertial> <visual> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link4.STL" /> </geometry> <material name=""> <color rgba="0.505882352941176 0.529411764705882 0.549019607843137 1" /> </material> </visual> <collision> <geometry> <mesh filename="package://liutestthree/meshes/Empty_Link4.STL" /> </geometry> </collision> </link> <joint name="joint4" type="revolute"> <origin xyz="0.12 0 0.0018" rpy="0 0 0" /> <parent link="Empty_Link3" /> <child link="Empty_Link4" /> <axis xyz="0 0 1" /> <limit lower="-1.57" upper="1.57" effort="30" velocity="1" /> <dynamics D="1" K="7000" damping="0.02" friction="0.8" mu_coulomb="0" mu_viscous="16" /> </joint> <transmission name="trans_joint1"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint1"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="joint1_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_joint2"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint2"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="joint2_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_joint3"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint3"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="joint3_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_joint4"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint4"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="joint4_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotNamespace>/</robotNamespace> </plugin> </gazebo> </robot>
最新发布
06-11
Parameter 'initial' s<?xml version="1.0" ?> <!-- =================================================================================== --> <!-- | This document was autogenerated by xacro from /opt/ros/noetic/share/franka_description/robots/fr3/fr3.urdf.xacro | --> <!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | --> <!-- =================================================================================== --> <robot name="fr3"> <!-- sub-link defining detailed meshes for collision with environment --> <link name="world"> </link> <joint name="dummy_joint" type="fixed"> <parent link="world" /> <child link="fr3_link0" /> </joint> <link name="fr3_link0"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link0.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link0.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link0_sc"> <collision> <origin rpy="0 1.5707963267948966 0" xyz="-0.075 0 0.06" /> <geometry> <cylinder length="0.03" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="-0.06 0 0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="-0.09 0 0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link0_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link0" /> <child link="fr3_link0_sc" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link1"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link1.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link1.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link1_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 -0.1915" /> <geometry> <cylinder length="0.283" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.05000000000000002" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.33299999999999996" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link1_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link1" /> <child link="fr3_link1_sc" /> </joint> <joint name="fr3_joint1" type="revolute"> <origin rpy="0 0 0" xyz="0 0 0.333" /> <parent link="fr3_link0" /> <child link="fr3_link1" /> <axis xyz="0 0 1" /> <limit effort="87.0" lower="-2.3093" upper="2.3093" velocity="2.0" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.3093" soft_upper_limit="2.3093" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link2"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link2.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link2.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link2_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 0" /> <geometry> <cylinder length="0.12" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link2_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link2" /> <child link="fr3_link2_sc" /> </joint> <joint name="fr3_joint2" type="revolute"> <origin rpy="-1.5707963267948966 0 0" xyz="0 0 0" /> <parent link="fr3_link1" /> <child link="fr3_link2" /> <axis xyz="0 0 1" /> <limit effort="87.0" lower="-1.5133" upper="1.5133" velocity="1.0" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-1.5133" soft_upper_limit="1.5133" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link3"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link3.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link3.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link3_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 -0.145" /> <geometry> <cylinder length="0.15" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.06999999999999999" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.21999999999999997" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link3_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link3" /> <child link="fr3_link3_sc" /> </joint> <joint name="fr3_joint3" type="revolute"> <origin rpy="1.5707963267948966 0 0" xyz="0 -0.316 0" /> <parent link="fr3_link2" /> <child link="fr3_link3" /> <axis xyz="0 0 1" /> <limit effort="87.0" lower="-2.4937" upper="2.4937" velocity="1.5" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.4937" soft_upper_limit="2.4937" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link4"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link4.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link4.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link4_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 0" /> <geometry> <cylinder length="0.12" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.06" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link4_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link4" /> <child link="fr3_link4_sc" /> </joint> <joint name="fr3_joint4" type="revolute"> <origin rpy="1.5707963267948966 0 0" xyz="0.0825 0 0" /> <parent link="fr3_link3" /> <child link="fr3_link4" /> <axis xyz="0 0 1" /> <limit effort="87.0" lower="-2.7478" upper="-0.4461" velocity="1.25" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.7478" soft_upper_limit="-0.4461" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link5"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link5.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link5.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link5_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 -0.26" /> <geometry> <cylinder length="0.1" radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.21000000000000002" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.31" /> <geometry> <sphere radius="0.09" /> </geometry> </collision> <collision> <origin rpy="0 0 0.08" xyz="0 0.08 -0.13" /> <geometry> <cylinder length="0.14" radius="0.055" /> </geometry> </collision> <collision> <origin xyz="0 0.08 -0.06" /> <geometry> <sphere radius="0.055" /> </geometry> </collision> <collision> <origin xyz="0 0.08 -0.2" /> <geometry> <sphere radius="0.055" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link5_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link5" /> <child link="fr3_link5_sc" /> </joint> <joint name="fr3_joint5" type="revolute"> <origin rpy="-1.5707963267948966 0 0" xyz="-0.0825 0.384 0" /> <parent link="fr3_link4" /> <child link="fr3_link5" /> <axis xyz="0 0 1" /> <limit effort="12.0" lower="-2.48" upper="2.48" velocity="3.0" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.48" soft_upper_limit="2.48" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link6"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link6.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link6.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link6_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 -0.03" /> <geometry> <cylinder length="0.08" radius="0.08" /> </geometry> </collision> <collision> <origin xyz="0 0 0.010000000000000002" /> <geometry> <sphere radius="0.08" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.07" /> <geometry> <sphere radius="0.08" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link6_sc_joint" type="fixed"> <origin rpy="0 0 0" /> <parent link="fr3_link6" /> <child link="fr3_link6_sc" /> </joint> <joint name="fr3_joint6" type="revolute"> <origin rpy="1.5707963267948966 0 0" xyz="0 0 0" /> <parent link="fr3_link5" /> <child link="fr3_link6" /> <axis xyz="0 0 1" /> <limit effort="12.0" lower="0.8521" upper="4.2094" velocity="1.5" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="0.8521" soft_upper_limit="4.2094" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <!-- sub-link defining detailed meshes for collision with environment --> <link name="fr3_link7"> <visual> <geometry> <mesh filename="package://franka_description/meshes/visual/link7.dae" /> </geometry> </visual> <collision> <geometry> <mesh filename="package://franka_description/meshes/collision/link7.stl" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- sub-link defining coarse geometries of real robot's internal self-collision --> <link name="fr3_link7_sc"> <collision> <origin rpy="0 0 0" xyz="0 0 0.01" /> <geometry> <cylinder length="0.14" radius="0.07" /> </geometry> </collision> <collision> <origin xyz="0 0 0.08" /> <geometry> <sphere radius="0.07" /> </geometry> </collision> <collision> <origin xyz="0 0 -0.060000000000000005" /> <geometry> <sphere radius="0.07" /> </geometry> </collision> <collision> <origin rpy="0 1.5707963267948966 0" xyz="0.06 0 0.082" /> <geometry> <cylinder length="0.01" radius="0.06" /> </geometry> </collision> <collision> <origin xyz="0.065 0 0.082" /> <geometry> <sphere radius="0.06" /> </geometry> </collision> <collision> <origin xyz="0.055 0 0.082" /> <geometry> <sphere radius="0.06" /> </geometry> </collision> <inertial> <mass value="0.1" /> <origin xyz="0 0 0" rpy="0 0 0" /> <inertia ixx="0.03" iyy="0.03" izz="0.03" ixy="0.0" ixz="0.0" iyz="0.0" /> </inertial> </link> <!-- fixed joint between both sub-links --> <joint name="fr3_link7_sc_joint" type="fixed"> <origin rpy="0 0 0.7853981633974483" /> <parent link="fr3_link7" /> <child link="fr3_link7_sc" /> </joint> <joint name="fr3_joint7" type="revolute"> <origin rpy="1.5707963267948966 0 0" xyz="0.088 0 0" /> <parent link="fr3_link6" /> <child link="fr3_link7" /> <axis xyz="0 0 1" /> <limit effort="12.0" lower="-2.6895" upper="2.6895" velocity="3.0" /> <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.6895" soft_upper_limit="2.6895" /> <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16" /> </joint> <link name="fr3_link8" /> <joint name="fr3_joint8" type="fixed"> <origin rpy="0 0 0" xyz="0 0 0.107" /> <parent link="fr3_link7" /> <child link="fr3_link8" /> </joint> <transmission name="trans_fr3_joint1"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint1"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint1_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint2"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint2"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint2_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint3"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint3"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint3_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint4"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint4"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint4_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint5"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint5"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint5_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint6"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint6"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint6_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <transmission name="trans_fr3_joint7"> <type>transmission_interface/SimpleTransmission</type> <joint name="fr3_joint7"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="fr3_joint7_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotNamespace>/</robotNamespace> </plugin> </gazebo> </robot> hould be an array of (group, pose) structs.
05-28
<think>好的,我现在需要解决用户提出的关于“joint_state_publisher没有无关节的问题”。首先,用户提到遇到了“joint_state_publisher no joints issue”,需要找到解决方案。根据我的知识,这可能与ROS中的joint_state_publisher包有关,尤其是在配置机器人模型时出现的常见问题。 首先,我应该回顾joint_state_publisher的作用。这个节点负责发布关节状态信息,通常与robot_state_publisher配合使用,将关节状态转换为tf变换。如果出现“no joints”的问题,可能原因包括URDF文件中关节定义不正确、参数配置错误,或者节点启动参数的问题。 接下来,我需要考虑用户可能的情况。用户可能没有在URDF文件中正确定义关节(joint),或者在启动joint_state_publisher时没有正确指定关节名称。例如,URDF中的关节需要正确设置类型(如revolute或continuous),而如果所有关节都是fixed类型,joint_state_publisher可能不会处理它们,导致没有关节被发布。 另外,用户可能没有正确设置gui参数,或者没有通过命令行参数传入关节名称。例如,启动节点时可能需要使用`joint_names`参数显式指定关节列表,尤其是在URDF中存在多个固定关节或非活动关节的情况下。 同时,用户提供的引用中提到了gazebo_msgs/SetJointProperties和UV打包的问题,这可能与Gazebo仿真中的关节属性设置有关。虽然这不一定直接关联,但可能用户在仿真中遇到了关节配置的问题,导致joint_state_publisher无法正确读取关节状态。 可能的解决步骤包括检查URDF文件中的关节定义,确保至少有一个非fixed类型的关节;检查启动文件或命令行参数是否正确传递了关节名称;以及验证是否启用了GUI参数以便手动发布关节状态。此外,用户可能需要查看日志信息,确认是否有错误提示,例如URDF解析失败或关节未被识别的情况。 最后,可能需要建议用户使用命令行工具如`check_urdf`来验证URDF文件的正确性,或者通过ROS的rostopic工具检查发布的关节状态话题是否存在。如果问题依然存在,可能需要进一步查看节点的源代码,确认是否存在配置或代码层面的问题。</think>关于`joint_state_publisher`出现“无关节”(no joints)的问题,通常与URDF模型配置或节点参数设置相关。以下是分步解决方案: --- ### 1. 检查URDF关节定义 - **关键点**:确保URDF中至少有一个**非fixed类型**的关节(如`revolute`/`continuous`/`prismatic`)。 - **示例**: ```xml <joint name="wheel_joint" type="continuous"> <parent link="base_link"/> <child link="wheel"/> <axis xyz="0 1 0"/> </joint> ``` - **错误示例**:若所有关节均为`type="fixed"`,则会被视为静态关节,不会被`joint_state_publisher`处理[^1]。 --- ### 2. 确认节点启动参数 - **参数设置**:在启动`joint_state_publisher`时,需显式指定关节列表(尤其当URDF未自动加载时): ```xml <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"> <rosparam param="source_list">["joint_states"]</rosparam> <rosparam param="joints">["joint1", "joint2"]</rosparam> <!-- 替换为实际关节名 --> </node> ``` - **GUI模式**:若需手动控制关节,添加`use_gui`参数: ```xml <param name="use_gui" value="true"/> ``` --- ### 3. 验证URDF解析 - **工具检查**:使用`check_urdf`命令验证URDF语法: ```bash sudo apt install liburdfdom-tools check_urdf your_robot.urdf ``` - **常见错误**:若输出显示“No joints”,则需返回步骤1修正关节定义。 --- ### 4. 排查ROS话题与TF树 - **查看话题列表**: ```bash rostopic list | grep joint_states ``` - **检查TF发布**: ```bash rosrun tf view_frames ``` 若未生成关节的TF变换,说明`robot_state_publisher`未正确接收关节状态。 --- ### 5. 仿真环境特殊处理(Gazebo) 若涉及Gazebo仿真,需确保: - 添加`<transmission>`标签关联关节与控制器: ```xml <transmission name="trans_joint1"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint1"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="motor_joint1"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> ``` - 引用Gazebo插件时需正确加载关节属性。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值