URDF

本文详细介绍了如何将Solidworks模型转换为URDF格式,适用于机器人仿真与控制。涵盖三连杆机械臂示例、逆运动学计算及RViz可视化技巧。探讨了URDF文件的结构与语法检查,以及如何定义关节类型、坐标系和视觉元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Solidworks模型转化为URDF文件格式+三连杆机械臂示例+逆运动学

https://blog.youkuaiyun.com/gpeng832/article/details/73917487

 

关于SolidWorks导出URDF模型的总结

https://blog.youkuaiyun.com/mt_lixinzeng/article/details/80268572

 

 

Rviz:  RobotModel --Status: Error :如果关节是活动的比如: revolute , continuous 就要为他们编写相应的驱动程序并发布joint_status状态.否则rviz加载robot model之后status会显示错误状态,并且活动的关节也会显示错误.

检查urdf文件语法:check_urdf smartcar.urdf

在indigo版本的ROS中,执行如下命令即可: rosrun urdfdom check_urdf /tmp/pr2.urdf

可视化模型 , gui = true 可以让关节动起来:  roslaunch urdf_tutorial display.launch model:=path/to/your/xxx.urdf gui:=true

图形化显示URDF模型 :urdf_to_graphiz my_robot.urdf

origin:xyz以parent link为原点,child link的三维坐标系位置。

origin:rpy child link绕z轴旋转的滚动角(roll),绕y轴方向旋转的俯仰(pitch)角,和绕x轴旋转的偏转(yaw)角.

 

Things to note:

  • The fixed frame is transform frame where the center of the grid is located. Here, it’s a frame defined by our one link, base_link.
  • The visual element (the cylinder) has its origin at the center of its geometry as a default. Hence, half the cylinder is below the grid.

右手坐标系法则:

<box size="0.6 0.1 0.2"/> 分别对应xyz三个方向的值; 相对于原点<origin>,如果没有赋值的话就是几何形状<geometry>的中心点。 为了方便确定map中的右手坐标系,可以在rviz中勾选 show Axes来显示xyz坐标轴。
关于原点<origin>
Both of the shapes overlap with each other, because they share the same origin. If we want them not to overlap we must define more origins.

<joint> 和<link>中 <origin>元素的意义:

 

  • Let’s start by examining the joint’s origin. It is defined in terms of theparent’s reference frame.So we are -0.22 meters in the y direction (to our left, but to the right relative to the axes) and 0.25 meters in the z direction (up). This means that the origin for the child link will be up and to the right, regardless of the child link’s visual origin tag. Since we didn’t specify a rpy (roll pitch yaw) attribute, the child frame will be default have the same orientation as the parent frame.This is the transform from the parent link to the child link. The joint is located at the origin of the child link
  • Now, looking at the leg’s visual origin, it has both a xyz and rpy offset. This defines where thecenter of the visual element should be, relative to its origin. Since we want the leg to attach at the top, we offset the origin down by setting the z offset to be -0.3 meters. And since we want the long part of the leg to be parallel to the z axis, we rotate the visual part PI/2 around the Y axis.

<joint type ="continuous">  <axis>    

<joint name="head_swivel" type="continuous">
  <parent link="base_link"/>
     <child link="head"/>
     <axis xyz="0 0 1"/>
     <origin xyz="0 0 0.3"/>
</joint>

The connection between the body and the head is a continuous joint, meaning that it can take on any angle from negative infinity to positive infinity. The wheels are also modeled like this, so that they can roll in both directions forever.

The only additional information we have to add is the axis of rotation,here specified by an xyz triplet, which specifies a vector around which the head will rotate. Since we want it to go around the z axis, we specify the vector "0 0 1".

<joint type = "revolute">

    revolute joints. This means that they rotate inthe same way that the continuous joints do, but they have strict limits.

<joint type="prismatic">

This means thatit moves along an axis, not around it. This translational movement is what allows our robot model to extend and retractits gripper arm

Whereas the prismatic joint can only move along one dimension, a planar joint can move around in a plane, or two dimensions. Furthermore, a floating joint is unconstrained, and can move around in any of the three dimensions

 

Xacro 

The value of the contents of the ${} construct are then used to replace the ${}. This means you can combine it with other text in the attribute.

<xacro:property name=”robotname” value=”marvin” />
<link name=”${robotname}s_leg” />

This will generate

<linkname=”marvins_leg”/>

the contents in the ${} don’t have to only be a property . You can build up arbitrarily complex expressions in the ${} construct using the four basic operations (+,-,*,/), the unary minus, and parenthesis . In Jade and later distros, you can use more than the basic operations listed above, notably sin and cos

 

 joint_state_publisher从ROS参数服务器中读取robot_description参数, 找到所有non-fixed joint, 发布他们的JointState消息到/joint_states话题.

robot_state_publisher从/joint_states话题中获取机器人joint角度作为输入, 使用机器人的运动学树模型计算出机器人link的3D姿态, 然后将其发布到话题/tf和 /tf_static.

 

在rviz中查看各关节的ff关系

roslaunch urdf_tutorial display.launch model:=llb.urdf gui:=true

 

Problem converting simple urdf file in collada

https://answers.ros.org/question/198995/problem-converting-simple-urdf-file-in-collada/

<think>好的,用户的问题是关于如何在RViz中加载或配置URDF文件。首先,我需要回忆一下URDF和RViz的基本知识。URDF是用于描述机器人模型的XML格式文件,而RViz是ROS中的可视化工具。用户可能需要将他们的机器人模型导入RViz进行可视化调试。 接下来,我需要确定正确的步骤。首先,用户需要确保已经创建了正确的URDF文件,并且该文件没有语法错误。然后,他们可能需要使用ROS的包结构来管理这个URDF文件,比如将文件放在包的urdf目录下,并配置package.xml和CMakeLists.txt以确保文件被正确识别。 接下来,使用robot_state_publisher节点来发布机器人的状态是很重要的一步。这个节点会读取URDF文件,并通过ROS话题发布机器人的关节状态和变换信息。用户可能需要启动这个节点,同时运行RViz来查看模型。 然后,在RViz中添加RobotModel显示类型,并选择正确的TF前缀(如果有的话)。如果模型无法显示,常见的问题可能包括URDF文件路径错误、TF配置不正确,或者缺少必要的依赖包。需要检查这些方面,并确保所有相关节点正常运行。 另外,用户的引用中有提到关于模型路径的配置,比如引用3中提到的指定本地路径的方法,这可能类比到URDF文件的路径配置,确保RViz能够正确找到文件。同时,引用4和5提到的数据加载优化方法可能与模型加载的性能有关,但可能不直接相关,不过需要考虑是否有类似配置选项可以优化URDF的加载速度。 最后,生成相关问题时需要考虑用户在配置过程中可能遇到的进一步疑问,比如如何添加传感器或调试URDF错误。这些问题可以帮助用户更深入地理解整个流程,并解决潜在的问题。</think>### 在RViz中加载URDF文件的步骤 1. **准备URDF文件** 确保已创建正确的URDF文件(XML格式),描述机器人模型结构。例如: ```xml <robot name="my_robot"> <link name="base_link"> <visual> <geometry><box size="0.5 0.2 0.1"/></geometry> </visual> </link> </robot> ``` 2. **配置ROS包** - 将URDF文件保存在ROS包的`urdf`目录中(如`~/catkin_ws/src/my_robot/urdf/`)。 - 在`package.xml`中添加依赖: ```xml <exec_depend>urdf</exec_depend> <exec_depend>robot_state_publisher</exec_depend> ``` 3. **启动机器人模型发布节点** 通过`robot_state_publisher`节点加载URDF文件并发布TF数据: ```bash roslaunch my_robot display.launch ``` `display.launch`文件示例: ```xml <launch> <param name="robot_description" textfile="$(find my_robot)/urdf/my_robot.urdf" /> <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> </launch> ``` 4. **在RViz中加载模型** - 启动RViz: ```bash rosrun rviz rviz ``` - 添加`RobotModel`显示类型(左侧面板点击`Add` → `RobotModel`)。 - 设置`RobotModel`的`Description Topic`为`/robot_description`。 5. **检查TF坐标系** - 添加`TF`显示类型以查看坐标系关系。 - 确保所有关节的TF数据已正确发布[^3]。 --- ### 常见问题排查 - **模型未显示** 检查URDF文件路径是否正确,或使用`check_urdf`工具验证语法: ```bash sudo apt-get install liburdfdom-tools check_urdf my_robot.urdf ``` - **TF数据缺失** 确认`robot_state_publisher`节点是否正常运行,或手动发布关节状态: ```python # 示例Python脚本发布关节状态 import rospy from sensor_msgs.msg import JointState rospy.init_node('joint_publisher') pub = rospy.Publisher('/joint_states', JointState, queue_size=10) msg = JointState() msg.name = ['joint1'] msg.position = [0.0] pub.publish(msg) ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值