当前位置:网站首页>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>
边栏推荐
- A new paradigm of distributed deep learning programming: Global tensor
- flinkSQLclient创建的job,flink重启就没了,有什么办法吗?
- Minimum ticket price (day 80)
- Director of meta quest content ecology talks about the original intention of APP lab design
- Contour detection based on OpenCV (1)
- If the detailed explanation is generated according to the frame code
- Characteristics and determination scheme of Worthington pectinase
- 深圳家具展首日,金可儿展位三大看点全解锁!
- Six determination methods of Worthington peroxidase activity
- C # using sqlsugar updatable system to report invalid numbers, how to solve it? Ask for guidance!
猜你喜欢

Kettle reads file split by line

Plato farm brings a new experience to community users through the LAAS protocol elephant swap

Application, addition and deletion of B-tree

基于OpenCV的轮廓检测(1)

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

Do you really understand code rollback?

复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别

Implementation of API short message gateway based on golang

Introduction to database - Introduction to database

Duplicate disc: what are the basic attributes of an image? What do you know about images? What are the parameters of the image
随机推荐
typescript ts 基础知识之接口、泛型
Threads and processes
Plato farm brings a new experience to community users through the LAAS protocol elephant swap
Minimum ticket price (day 80)
DNS record type and explanation of related terms
Detailed tutorial of typera
Design method and test method of APP interface use case
Record the problem of PHP program accessing system files incorrectly
[Android synopsis] kotlin multithreaded programming (I)
Typescript TS basic knowledge interface, generics
Plato Farm有望通过Elephant Swap,进一步向外拓展生态
Briefly sort out the dualpivotquicksort
Redis spike case, learn from Shang Silicon Valley teacher in station B
基于OpenCV的轮廓检测(2)
Program to change the priority of the process in LabVIEW
Csu18m91 is used as the master controller of the intelligent scale scheme
Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial
百融榕树数据分析拆解方法
Maximum continuous subsequence (day 77)
[tree chain dissection] 2022 Hangzhou Electric Multi school 21001 static query on tree