如何解决PyDrake:Meshcat无法通过伪球形关节可视化URDF
我正在尝试将反作用轮添加到Drake的机器人航天器模型中。为此,我要在飞船底座上添加3个旋转接头,以模拟反作用轮施加在底座上的扭矩。由于URDF规范不允许直接使用球形接头,因此我正在使用(伪)中间链接创建球形接头。 urdf文件的相关部分如下所示:
<link name="Base"/>
<link name="Base_roll"/>
<!-- S/C Roll Joint -->
<joint name="Joint_base_roll" type="continuous">
<parent link="Base"/>
<child link="Base_roll"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="1 0 0"/>
</joint>
<transmission name="Joint_base_roll_trans">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="$Joint_base_roll_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="Joint_base_roll">
<hardwareInterface>PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<link name="Base_pitch"/>
<!-- S/C Pitch Joint -->
<joint name="Joint_base_pitch" type="continuous">
<parent link="Base_roll"/>
<child link="Base_pitch"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 1 0"/>
</joint>
<transmission name="Joint_base_pitch_trans">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="$Joint_base_pitch_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="Joint_base_pitch">
<hardwareInterface>PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<!-- S/C Yaw Joint -->
<joint name="Joint_base_yaw" type="continuous">
<parent link="Base_pitch"/>
<child link="Spacecraft"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
</joint>
<transmission name="Joint_base_yaw_trans">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="$Joint_base_yaw_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="Joint_base_yaw">
<hardwareInterface>PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<!--Spacecraft-->
<link name="Spacecraft">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="2550"/>
<inertia ixx="6200" ixy="48.2" ixz="78.5" iyy="3540" iyz="-29.2" izz="7090"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<Box size="2.2 2.1 2" />
</geometry>
<material name="Grey"/>
</visual>
</link>
带有反作用轮的航天器+机器人手臂的完整urdf可以在这里找到:https://pastebin.com/0G1GSeqk,而没有反作用轮的完整urdf可以在这里找到:https://pastebin.com/v9Ne8Nv8
我使用它来运行以下脚本,以向基座施加扭矩并相应地模拟系统的旋转:
builder = DiagramBuilder()
# Adds both MultibodyPlant and the SceneGraph,and wires them together.
plant,scene_graph = AddMultibodyPlantSceneGraph(builder,time_step=1e-4)
# Note that we parse into both the plant and the scene_graph here.
Parser(plant,scene_graph).AddModelFromFile(SCpath)
# Remove gravity
plantGravityField = plant.gravity_field()
plantGravityField.set_gravity_vector([0,0])
plant.Finalize()
# Adds the MeshcatVisualizer and wires it to the SceneGraph.
meshcat = ConnectMeshcatVisualizer(builder,scene_graph,zmq_url=zmq_url,delete_prefix_on_load=True)
diagram = builder.Build()
context = diagram.CreateDefaultContext()
plant_context = plant.GetMyMutableContextFromroot(context)
jointAcutation = np.zeros((plant.num_actuators(),1))
jointAcutation[3] = 1
plant.get_actuation_input_port().FixValue(plant_context,jointAcutation)
simulator = Simulator(diagram,context)
meshcat.load()
simulator.Advanceto(30.0 if running_as_notebook else 0.1)
但是,Meshcat可视化只能在urdf中不使用反作用轮的情况下工作。当我添加(伪)链接和关节时,可视化效果完全空白。我是否可以假设这是由于urdf中的(伪)链接引起的?如果是这样,sdf格式是创建球形接头并使其可视化的更好方法吗?
P.S我试图通过在移动机器人手臂来模拟反作用轮的同时在基座上施加扭矩来控制航天器的姿态。我认为添加球形关节将是添加“关节控制器”以实现此目的的最简单方法。也许有更好的方法可以做到这一点。
更新:可以使用以下在Google Colab上的笔记本复制此问题:https://colab.research.google.com/github/vyas-shubham/DrakeTests/blob/main/freeFloating/FreeFloatingTumbleTest.ipynb
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。