$\color{white}\colorbox{FE9227}{Building momentum and expanding understanding!}$
▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░ 40%
The next step in simulating our robot is to create our robot tf2
tree. Having a tight and accurate tf2
tree is essential for a working robot simulation.
The first thing to note when starting to build your robot tf2
tree is aligning your simulation frame with your robot frame. Within rviz
, the x-axis is shown in red, the y-axis is green, and the z-axis is blue. Your robot should be aligned such that the x-axis points to the front of the robot, the y-axis spans the width of the robot, and the z-axis aligns with the height of the robot.
<aside>
⚠️ These conventions are very important! These will align your odometry
properly to the map
frame, which will be important when doing navigation and SLAM
.
</aside>
An especially useful tool when creating robots is using xacro:macros
. This will create a cleaner and shorter file to describe your robot because you can use the same macro, but mirrored, for wheels on opposite sides of the robot. See the XACRO ****for more information.
Let’s start by creating the “master” XACRO
, this will be the file that will include all the external XACRO
files used to describe the joints
, sensors
, and ros2_control
.
cd ~/humble_ws/src/hunter_se/hunter_se_description/models/xacro
touch hunter_se.xacro
Open that hunter_se.xacro
file with your preferred code editor and begin by initializing the XACRO
filespace and your robot name.
<?xml version="1.0"?>
<robot name="hunter_se" xmlns:xacro="<http://wiki.ros.org/xacro>">
</robot>
First, let’s include some xacro:properties
for the Hunter SE. We are going to include the dimensions of the Hunter SE body, the steering axle offsets, the motor axle offsets, the wheel dimensions, and the robot namespace.
<xacro:property name="base_x_size" value="0.800" />
<xacro:property name="base_y_size" value="0.350" />
<xacro:property name="base_z_size" value="0.200" />
<xacro:property name="steering_axle_x_offset" value="0.34219" />
<xacro:property name="steering_axle_y_offset" value="0.20" />
<xacro:property name="steering_axle_z_offset" value="-0.145" />
<xacro:property name="steering_wheel_z_offset" value="0" />
<xacro:property name="steering_wheel_y_offset" value="0.065" />
<xacro:property name="max_steer" value="0.69" />
<xacro:property name="motor_axle_x_offset" value="-0.2078" />
<xacro:property name="motor_axle_y_offset" value="0.270" />
<xacro:property name="motor_axle_z_offset" value="-0.1495" />
<xacro:property name="wheel_length" value="0.10" />
<xacro:property name="wheel_radius" value="0.14" />
<xacro:property name="robot_namespace" value="hunter_se" />
<aside> ⚠️ These values will be different for your robot, but the same format for creating the properties can be used.
</aside>
Next, we are going to define the robot base_link. Let's first add the base_link
mesh to our meshes folder. Place the hunter_body.dae
file into your meshes
folder.