当前位置:网站首页>URDF_ Xcaro
URDF_ Xcaro
2022-07-27 03:58:00 【2021 Nqq】
List of articles
roscore
rosrun xacro xacro demo01_helloworld.urdf.xacro
rosrun xacro xacro demo01_helloworld.urdf.xacro > demo01_helloworld.urdf from xacro File generation urdf file
Xacro grammar
attribute
Attribute definitions
Calling a
Arithmetic operations
<robot name = "mycar" xmlns:xacro = "http://wiki.ros.org/xacro">
<!-- 1. Attribute definitions The attribute name , The value of the property -->
<xacro:property name = "PI" value = "3.1415927" />
<xacro:property name = "radius" value = "0.03" />
<!-- 2. Calling a -->
<myUsrPropertyxxx name = "${PI}" />
<myUsrPropertyxxx name = "${radius}" />
<!-- 3. Arithmetic operations -->
<myUsrPropertyxxx result = "${PI / 2}" />
<myUsrPropertyxxx result = "${radius * 2}" />
</robot>
macro
Macro definition
Macro call
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 1. Definition of macro Parameters 1 Parameters 2-->
<xacro:macro name = "getSum" params = "num1 num2">
<result value = "${num1 + num2}" />
</xacro:macro>
<!-- 2. Macro call -->
<xacro:getSum num1 = "1" num2 = "5" />
</robot>
File contains
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- The presentation file contains -->
<xacro:include filename = "demo02_field.urdf.xacro" />
<xacro:include filename = "demo03_macro.urdf.xacro" />
</robot>
Xacro example
roslaunch urdf01_rviz demo06_car_base.launch
chassis launch file demo06_car_base.launch
<launch>
<!-- 1. Load in the parameter server URDF It is suggested to use the second way -->
<!-- <param name = "robot_description" textfile = "$(find urdf01_rviz)/urdf/xacro/demo05_car_base.urdf" /> -->
<param name = "robot_description" command = "$(find xacro)/xacro $(find urdf01_rviz)/urdf/xacro/demo05_car_base.urdf.xacro" />
<!-- 2. start-up rviz -->
<node pkg = "rviz" type = "rviz" name = "rviz" args = "-d $(find urdf01_rviz)/config/show_mycar.rviz"/>
<!-- 3. Add joint status publishing node -->
<node pkg = "joint_state_publisher" type = "joint_state_publisher" name = "joint_state_publisher" />
<!-- 4. Add robot status publishing node -->
<node pkg = "robot_state_publisher" type = "robot_state_publisher" name = "robot_state_publisher" />
<!-- 5. Joint motion control node -->
<node pkg = "joint_state_publisher_gui" type = "joint_state_publisher_gui" name = "joint_state_publisher_gui" />
</launch>
chassis xacro file demo05_car_base.urdf.xacro
<robot name = "mycar" xmlns:xacro = "http://wiki.ros.org/xacro">
<xacro:property name = "footprint_radius" value = "0.001" />
<!-- 1. add to base_footprint -->
<link name = "base_footprint">
<visual>
<geometry>
<sphere radius = "${footprint_radius}" />
</geometry>
</visual>
</link>
<!-- 2. Add chassis -->
<!-- shape : The chassis is cylindrical , radius 0.1m, high 0.08m Distance from the ground : 0.015m -->
<xacro:property name = "base_radius" value = "0.1" />
<xacro:property name = "base_length" value = "0.08" />
<xacro:property name = "lidi_space" value = "0.015" />
<xacro:property name = "base_joint_z" value = "${(base_length) / 2 + lidi_space}" />
<!-- 2-1 link -->
<link name = "base_link">
<visual>
<geometry>
<cylinder radius = "0.1" length = "0.08" />
</geometry>
<origin xyz = "0 0 0" rpy = "0 0 0"/>
<material name = "baselink_color">
<color rgba = "1 0.5 0.2 0.5" />
</material>
</visual>
</link>
<!-- 2-2 joint Height of half car body 0.08m/2+0.015m-->
<joint name = "link2footprint" type = "fixed">
<parent link = "base_footprint" />
<child link = "base_link" />
<!-- The joints z Settings on = Height of car body /2 + Height above ground -->
<origin xyz = "0 0 0.055" rpy = "0 0 0" />
</joint>
<!-- 3. Add drive wheels -->
<!-- shape : Cylinder radius : 0.0325m length : 0.015m -->
<!-- attribute -->
<xacro:property name = "wheel_radius" value = "0.0325" />
<xacro:property name = "wheel_length" value = "0.015" />
<xacro:property name = "PI" value = "3.1415927" />
<!-- Be careful : The result is a negative number -->
<xacro:property name = "wheel_joint_z" value = "${(base_length / 2 + lidi_space - wheel_radius) * (-1)}" />
<!-- wheel_name: left or right flag: 1 or -1 -->
<!-- Macro definition -->
<xacro:macro name = "wheel_func" params = "wheel_name flag">
<!-- 3-1 link -->
<link name = "${wheel_name}_wheel">
<visual>
<geometry>
<cylinder radius = "${wheel_radius}" length = "${wheel_length}" />
</geometry>
<!-- Under normal circumstances, the cylinder face up , Here the drive wheels are on the left and right , Euler angle needs to be modified , Along the x Shaft rollover 90 degree , about 1.57 radian -->
<origin xyz = "0 0 0" rpy = "${PI / 2} 0 0"/>
<material name = "wheel_color">
<color rgba = "0 0 0 0.3" />
</material>
</visual>
</link>
<!-- 3-2 joint The joints -->
<joint name = "${wheel_name}2link" type = "continuous">
<parent link = "base_link" />
<child link = "${wheel_name}_wheel" />
<!-- x: 0 No offset y: 0.1 Body radius z: 0.04 + 0.015 - 0.0325 = 0.055 - 0.0325 = 0.0225, Negative numbers below Joint height = Height of car body / 2 + Distance from the ground - Wheel radius -->
<origin xyz = "0 ${0.1 * flag} ${wheel_joint_z}" rpy = "0 0 0" />
<!-- Rotate around Y Axis -->
<axis xyz = "0 1 0" />
</joint>
</xacro:macro>
<!-- The call takes effect -->
<xacro:wheel_func wheel_name = "left" flag = "1" />
<xacro:wheel_func wheel_name = "right" flag = "-1" />
<!-- 4. Add Cardan wheel -->
<!-- shape : The ball radius : 0.0075m -->
<!-- attribute -->
<xacro:property name = "small_wheel_radius" value = "0.0075" />
<!-- Joint height : Height of car body / 2 + Distance from the ground - Radius of universal wheel = 0.04 + 0.015 - 0.0075 / 2 = 0.0475 -->
<xacro:property name = "small_joint_z" value = "${(base_length / 2 + lidi_space - small_wheel_radius) * (-1)}" />
<!-- macro -->
<xacro:macro name = "small_wheel_func" params = "small_wheel_name flag" >
<!-- 4-1 link -->
<link name = "${small_wheel_name}_wheel">
<visual>
<geometry>
<sphere radius = "${small_wheel_radius}" />
</geometry>
<origin xyz = "0 0 0" rpy = "0 0 0"/>
<material name = "wheel_color">
<color rbga = "0 0 0 0.3" />
</material>
</visual>
</link>
<!-- 4-2 joint -->
<joint name = "${small_wheel_name}2link" type = "continuous">
<parent link = "base_link" />
<child link = "${small_wheel_name}_wheel" />
<!-- x: 0.08 Less than the radius y: 0 z: 0.04 + 0.015 - 0.0075 = 0.0475 -->
<origin xyz = "${0.08 * flag} 0 ${small_joint_z}" rpy = "0 0 0" />
<!-- Rotate around Y Axis -->
<axis xyz = "0 1 0" />
</joint>
</xacro:macro >
<!-- call -->
<xacro:small_wheel_func small_wheel_name = "front" flag = "1" />
<xacro:small_wheel_func small_wheel_name = "back" flag = "-1" />
</robot>
Xacro Practice
On the foundation of the front trolley chassis , Add cameras and radar sensors
camera xacro file demo06_car_camera.urdf.xacro
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Camera components -->
<!-- 1. Parameters -->
<!-- Parameters : Connecting rod properties : The thickness of the (x Direction )、 Width (y Direction )、 Height (z Direction ) Joint attributes : x y z Offset ,z Offset = Half the chassis height + Half the height of the camera -->
<xacro:property name = "camera_length" value = "0.02" /> <!-- The thickness of the (x)-->
<xacro:property name = "camera_width" value = "0.05" /> <!-- Width (y)-->
<xacro:property name = "camera_height" value = "0.05" /> <!-- Height (z)-->
<xacro:property name = "joint_camera_x" value = "0.08" /> <!-- The joints (x)-->
<xacro:property name = "joint_camera_y" value = "0" /> <!-- The joints (y)-->
<xacro:property name = "joint_camera_z" value = "${base_length / 2 + camera_height / 2}" /> <!-- The joints (z)-->
<!-- 2. Design connecting rod joints -->
<!-- 2-1 link -->
<link name = "camera">
<visual>
<geometry>
<box size = "${camera_length} ${camera_width} ${camera_height}" />
</geometry>
<material name = "black">
<color rgba = "0 0 0 0.8" />
</material>
</visual>
</link>
<!-- 2-2 The joints -->
<joint name = "camera2base" type = "fixed">
<parent link = "base_link" />
<child link = "camera" />
<origin xyz = "${joint_camera_x} ${joint_camera_y} ${joint_camera_z}" rpy = "0 0 0" />
</joint>
</robot>
radar xacro file demo07_car_laser.urdf.xacro
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Radar components -->
<!-- Parameters -->
<!-- 1. Bracket Support size : radius Height Joint offset : x y z 2. radar Support size : radius Height Joint offset : x y z -->
<xacro:property name = "support_radius" value = "0.01" />
<xacro:property name = "support_length" value = "0.15" />
<xacro:property name = "laser_radius" value = "0.03" />
<xacro:property name = "laser_length" value = "0.05" />
<xacro:property name = "joint_support_x" value = "0" />
<xacro:property name = "joint_support_y" value = "0" />
<!-- joint1 z = Height of car body / 2 + Support height / 2 -->
<xacro:property name = "joint_support_z" value = "${base_length / 2 + support_length / 2}" />
<xacro:property name = "joint_laser_x" value = "0" />
<xacro:property name = "joint_laser_y" value = "0" />
<!-- joint2 z = Support height / 2 + Radar altitude / 2 -->
<xacro:property name = "joint_laser_z" value = "${support_length / 2 + laser_length / 2}" />
<!-- 1. Bracket -->
<link name = "support">
<visual>
<geometry>
<cylinder radius = "${support_radius}" length = "${support_length}" />
</geometry>
<material name = "yellow">
<color rgba = "0.8 0.5 0 0.5" />
</material>
</visual>
</link>
<joint name = "support2base" type = "fixed">
<parent link = "base_link" />
<child link = "support" />
<origin xyz = "${joint_support_x} ${joint_support_y} ${joint_support_z}" rpy = "0 0 0"/>
</joint>
<!-- 2. radar Fix -->
<link name = "laser">
<visual>
<geometry>
<cylinder radius = "${laser_radius}" length = "${laser_length}" />
</geometry>
<material name = "black">
<color rgba = "0 0 0 0.5" />
</material>
</visual>
</link>
<joint name = "laser2support" type = "fixed">
<parent link = "support" />
<child link = "laser" />
<origin xyz = "${joint_laser_x} ${joint_laser_y} ${joint_laser_z}" rpy = "0 0 0"/>
</joint>
</robot>
Combined chassis 、 camera 、 radar xacro file car.urdf.xacro
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Including chassis 、 camera 、 Radar xacro file -->
<xacro:include filename = "demo05_car_base.urdf.xacro" />
<xacro:include filename = "demo06_car_camera.urdf.xacro" />
<xacro:include filename = "demo07_car_laser.urdf.xacro" />
</robot>
launch file car.launch
<launch>
<!-- 1. Load in the parameter server URDF It is suggested to use the second way -->
<!-- <param name = "robot_description" textfile = "$(find urdf01_rviz)/urdf/xacro/demo05_car_base.urdf" /> -->
<param name = "robot_description" command = "$(find xacro)/xacro $(find urdf01_rviz)/urdf/xacro/car.urdf.xacro" />
<!-- 2. start-up rviz -->
<node pkg = "rviz" type = "rviz" name = "rviz" args = "-d $(find urdf01_rviz)/config/show_mycar.rviz"/>
<!-- 3. Add joint status publishing node -->
<node pkg = "joint_state_publisher" type = "joint_state_publisher" name = "joint_state_publisher" />
<!-- 4. Add robot status publishing node -->
<node pkg = "robot_state_publisher" type = "robot_state_publisher" name = "robot_state_publisher" />
<!-- 5. Joint motion control node -->
<node pkg = "joint_state_publisher_gui" type = "joint_state_publisher_gui" name = "joint_state_publisher_gui" />
</launch>
边栏推荐
- GetObject call timing of factorybean
- About the solution of using hyperbeach to appear /bin/sh: 1: packr2: not found
- Contour detection based on OpenCV (2)
- Deployment of ruoyi's environment and operation of the system
- 这个FlinkCDC会监控数据库中所有的表?还是指定的表呢?我看后台日志,他是监控了所有表,如果监控
- 477-82(236、61、47、74、240、93)
- [tree chain dissection] 2022 Hangzhou Electric Multi school 21001 static query on tree
- ZJCTF_ login
- C language force deduction question 43 string multiplication. Optimized vertical
- Ming min investment Qiu Huiming: behind the long-term excellence and excess, the test is the team's investment and research ability and the integrity of strategy
猜你喜欢

The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of TCC mode

app端接口用例设计方法和测试方法

第五届强网杯全国网络安全挑战赛 题目复现(有题目附件,详解)

jmeter接口测试(登录、注册)

About the solution of using hyperbeach to appear /bin/sh: 1: packr2: not found

Smart pointer shared_ ptr、unique_ ptr、weak_ ptr

函数指针与回调函数

Solution to Chinese garbled code in console header after idea connects to database to query data

【无标题】JDBC连接数据库读超时

Interview question: the difference between three instantiated objects in string class
随机推荐
Textbox in easyUI inserts content at the cursor position
【安卓小叙】Kotlin多线程编程(一)
Worthington papain dissociation system solution
Kettle读取按行分割的文件
typescript ts 基础知识之接口、泛型
477-82(236、61、47、74、240、93)
flink cdc 到MySQL8没问题,到MySQL5读有问题,怎么办?
On the first day of Shenzhen furniture exhibition, the three highlights of Jin Ke'er booth were unlocked!
GetObject call timing of factorybean
03.获取网页源代码
明汯投资裘慧明:长期优异超额的背后考验的是团队的投研能力和策略的完整性
The function and application of lpci-252 universal PCI interface can card
If the detailed explanation is generated according to the frame code
Food chain (day 79)
Explain tool actual operation
How to interact with the server when the client sends an SQL message
Process analysis of object creation
Minimum ticket price (day 80)
Leetcode- > 2-point search and clock in (3)
Cocos game practice-05-npc and character attack logic