URDF、Xacro编写及介绍及其在RVIZ中显示与控制:
https://blog.csdn.net/answerMack/article/details/89523746
urdf教程:http://wiki.ros.org/urdf/Tutorials
solidworks转urdf教程:
1.http://wiki.ros.org/sw_urdf_exporter
2.https://blog.csdn.net/gpeng832/article/details/73917487
moveit setup assistant教程:
1.http://docs.ros.org/indigo/api/moveit_tutorials/html/doc/setup_assistant/setup_assistant_tutorial.html
2.http://docs.ros.org/hydro/api/moveit_setup_assistant/html/doc/tutorial.html
urdf转xacro参考教程:
1.http://wiki.ros.org/urdf/Tutorials/Using Xacro to Clean Up a URDF File
<robot
name="car-3">
<link
name="base_link">
<inertial>
<origin
xyz="0.000454836605433948 1.27332861349781E-18 0.000181934642173575"
rpy="0 0 0" />
<mass
value="0.497309733552923" />
<inertia
ixx="0.000379491084127215"
ixy="-2.59493525107028E-19"
ixz="-3.57796209039485E-06"
iyy="0.00138864533975945"
iyz="-4.48378120593819E-21"
izz="0.00169173411179082" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/base_link.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/base_link.STL" />
</geometry>
</collision>
</link>
<link
name="wheel_1">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -6.93889390390723E-18"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801096E-06"
ixy="-3.54146284907832E-09"
ixz="-4.2351647362715E-22"
iyy="1.27373747424717E-05"
iyz="7.11375326795604E-23"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_1.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_1.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_1_to_base_link"
type="continuous">
<origin
xyz="0.07 0.052 0"
rpy="0 -0.75239 0" />
<parent
link="base_link" />
<child
link="wheel_1" />
<axis
xyz="0 1 0" />
</joint>
<link
name="wheel_2">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_2.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_2.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_2_to_base_link"
type="continuous">
<origin
xyz="-0.07 0.052 0"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="wheel_2" />
<axis
xyz="0 1 0" />
</joint>
<link
name="wheel_3">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_3.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_3.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_3_to_base_link"
type="continuous">
<origin
xyz="0.07 -0.052 0"
rpy="0 0 3.1416" />
<parent
link="base_link" />
<child
link="wheel_3" />
<axis
xyz="0 -1 0" />
</joint>
<link
name="wheel_4">
<inertial>
<origin
xyz="2.08756043780511E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_4.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_4.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_4_to_base_link"
type="continuous">
<origin
xyz="-0.07 -0.052 0"
rpy="0 0 3.14159265358979" />
<parent
link="base_link" />
<child
link="wheel_4" />
<axis
xyz="0 -1 0" />
</joint>
</robot>
将urdf文件分为了car_body.urdf.xacro和gazebo.urdf.xacro文件
<?xml version="1.0"?>
<robot name="car_body" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:property name="M_PI" value="3.14159"/>
<xacro:include filename="$(find car-3)/robot_description/urdf/gazebo.urdf.xacro"/>
<xacro:property name="base_x" value="0.33" />
<xacro:property name="base_y" value="0.33" />
<link name="base_link">
<inertial>
<origin
xyz="0.000454836605433948 1.27332861349781E-18 0.000181934642173575"
rpy="0 0 0" />
<mass
value="0.497309733552923" />
<inertia
ixx="0.000379491084127215"
ixy="-2.59493525107028E-19"
ixz="-3.57796209039485E-06"
iyy="0.00138864533975945"
iyz="-4.48378120593819E-21"
izz="0.00169173411179082" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/base_link.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/base_link.STL" />
</geometry>
</collision>
</link>
<link
name="wheel_1">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -6.93889390390723E-18"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801096E-06"
ixy="-3.54146284907832E-09"
ixz="-4.2351647362715E-22"
iyy="1.27373747424717E-05"
iyz="7.11375326795604E-23"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_1.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_1.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_1_to_base_link"
type="continuous">
<origin
xyz="0.07 0.052 0"
rpy="0 -0.75239 0" />
<parent
link="base_link" />
<child
link="wheel_1" />
<axis
xyz="0 1 0" />
</joint>
<link
name="wheel_2">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_2.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_2.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_2_to_base_link"
type="continuous">
<origin
xyz="-0.07 0.052 0"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="wheel_2" />
<axis
xyz="0 1 0" />
</joint>
<link
name="wheel_3">
<inertial>
<origin
xyz="2.08756043780373E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_3.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_3.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_3_to_base_link"
type="continuous">
<origin
xyz="0.07 -0.052 0"
rpy="0 0 3.1416" />
<parent
link="base_link" />
<child
link="wheel_3" />
<axis
xyz="0 -1 0" />
</joint>
<link
name="wheel_4">
<inertial>
<origin
xyz="2.08756043780511E-05 5.32859680283521E-06 -1.44387083394547E-35"
rpy="0 0 0" />
<mass
value="0.0282994666235368" />
<inertia
ixx="6.59828205801097E-06"
ixy="-3.54146284907845E-09"
ixz="4.94314925543529E-39"
iyy="1.27373747424718E-05"
iyz="-8.12167230901508E-39"
izz="6.61215628796161E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_4.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://car-3/meshes/wheel_4.STL" />
</geometry>
</collision>
</link>
<joint
name="wheel_4_to_base_link"
type="continuous">
<origin
xyz="-0.07 -0.052 0"
rpy="0 0 3.14159265358979" />
<parent
link="base_link" />
<child
link="wheel_4" />
<axis
xyz="0 -1 0" />
</joint>
<xacro:car_gazebo />
</robot>
<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="car_gazebo">
<xacro:macro name="car_gazebo">
<gazebo reference="base_link">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="wheel_1">
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="wheel_2">
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="wheel_3">
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="wheel_4">
<material>Gazebo/FlatBlack</material>
</gazebo>
</xacro:macro>
</robot>
<launch>
<arg name="world_name" default="worlds/empty.world"/>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(arg world_name)"/> <!-- world_name is wrt GAZEBO_RESOURCE_PATH environment variable -->
<arg name="paused" value="false"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="headless" value="false"/>
<arg name="debug" value="false"/>
</include>
<arg name="model"/>
<arg name="gui" default="True"/>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find car-3)/robot_description/urdf/car_body.urdf.xacro'" />
<param name="use_gui" value="$(arg gui)"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find car-3)/urdf.rviz" />
<node name="tf_footprint_base" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 40" />
<node name="spawn_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -model -unpause -param
robot_description " output="screen" />
<node name="fake_joint_calibration" pkg="rostopic" type="rostopic" args="pub /calibrated std_msgs/Bool true" />
</launch>
rosrun rqt_tf_tree rqt_tf_tree
rosrun rqt_graph rqt_graph
husky包:https://github.com/husky/husky
某些文件参考的husky的。
解决方法:安装xacro文件
github地址:
https://github.com/ros/xacro/tree/kinetic-devel
http://wiki.ros.org/xacro
参考连接:https://blog.csdn.net/answerMack/article/details/89881213
20190503
20190506
未完待续