紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
6.3.2章节描述机器人惯量错误
-
报错信息:
tingbo@DESKTOP-NHH5E05:~/chapt6/chapt6_ws$ ros2 launch fishbot_description display_robot.launch.py model:=/home/tingbo/chapt6/chapt6_ws/src/fishbot_description/urdf/fishbot/fishbot.urdf.xacro [INFO] [launch]: All log files can be found below /home/tingbo/.ros/log/2024-04-19-11-07-25-252392-DESKTOP-NHH5E05-75355 [INFO] [launch]: Default logging verbosity is set to INFO [ERROR] [launch]: Caught exception in launch (see debug for traceback): executed command failed. Command: xacro /home/tingbo/chapt6/chapt6_ws/src/fishbot_description/urdf/fishbot/fishbot.urdf.xacro Captured stderr output: error: name 'l' is not defined when evaluating expression 'l' when instantiating macro: box_inertia (/home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/urdf/fishbot/common_inertia.xacro) instantiated from: imu_xacro (/home/tingbo/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/urdf/fishbot/sensor/imu.urdf.xacro) in file: /home/tingbo/chapt6/chapt6_ws/src/fishbot_description/urdf/fishbot/fishbot.urdf.xacro
base.urdf.xacro代码如下:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/common_inertia.xacro"/> <xacro:macro name="base_xacro" params ="length radius"> <link name="base_footprint" /> <link name="base_link"> <visual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <cylinder radius="${length}" length="${length}"/> </geometry> <material name="white"> <color rgba="1.0 1.0 1.0 0.5"/> </material> </visual> <collision> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <cylinder radius="${length}" length="${length}"/> </geometry> <material name="white"> <color rgba="1.0 1.0 1.0 0.5"/> </material> </collision> <xacro:cylinder_inertia m="1.0" r="${radius}" h="${length}"/> </link> <joint name="base_joint" type="fixed"> <parent link="base_footprint"/> <child link="base_link"/> <origin xyz=" 0.0 0.0 ${length/2+0.032-0.001}" rpy="0.0 0.0 0.0"/> </joint> </xacro:macro> </robot>
common_inertia.xacro代码如下:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" > <xacro:macro name="box_inertia" params="m l w h"> <inertial> <mass value="${m}"/> <inertia ixx="${(m/12) * (h*h + l*l)}" ixy="0.0" ixz="0.0" iyy="${(m/12) * (w*w + l*l)}" iyz="0.0" izz="${(m/12) * (w*w + h*h)}"/> </inertial> </xacro:macro> <xacro:macro name="cylinder_inertia" params="m r h"> <inertial> <mass value="${m}"/> <inertia ixx="${(m/12) * (3*r*r + h*h)}" ixy="0.0" ixz="0.0" iyy="${(m/12) * (3*r*r + h*h)}" iyz="0.0" izz="${(m/2) * (r*r)}"/> </inertial> </xacro:macro> <xacro:macro name="sphere_inertia" params="m r"> <inertial> <mass value="${m}"/> <inertia ixx="${(2/5) * m * (r*r)}" ixy="0.0" ixz="0.0" iyy="${(2/5) * m * (r*r)}" iyz="0.0" izz="${(2/5) * m * (r*r)}"/> </inertial> </xacro:macro> </robot>
camera.urdf.xacro代码如下:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/common_inertia.xacro"/> <xacro:macro name="camera_xacro" params="xyz"> <!--=========相机模块=========--> <link name="camera_link"> <visual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <box size="0.02 0.1 0.02"/> </geometry> <material name="green"> <color rgba="0.0 1.0 0.0 0.8"/> </material> </visual> <collision> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <box size="0.02 0.1 0.02"/> </geometry> <material name="green"> <color rgba="0.0 1.0 0.0 0.8"/> </material> </collision> <xacro:box_inertia m="0.05" l="${l}" w="${w}" h="${h}"/> </link> <joint name="camera_joint" type="fixed"> <parent link="base_link"/> <child link="camera_link"/> <origin xyz="${xyz}"/> </joint> </xacro:macro> </robot>
imu.urdf.xacro代码如下:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro"> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/common_inertia.xacro"/> <xacro:macro name="imu_xacro" params="xyz"> <link name="imu_link"> <visual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <box size="0.02 0.02 0.02"/> </geometry> <material name="black"> <color rgba="0.0 0.0 0.0 0.8"/> </material> </visual> <collision> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <box size="0.02 0.02 0.02"/> </geometry> <material name="black"> <color rgba="0.0 0.0 0.0 0.8"/> </material> </collision> <xacro:box_inertia m="0.05" l="${l}" w="${w}" h="${h}"/> </link> <joint name="imu_joint" type="fixed"> <parent link="base_link"/> <child link="imu_link"/> <origin xyz="${xyz}"/> </joint> </xacro:macro> </robot>
fishbot.urdf.xacro代码如下:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="fishbot"> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/base.urdf.xacro" /> <!--传感器组件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/imu.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/laser.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/sensor/camera.urdf.xacro" /> <xacro:base_xacro length="0.12" radius="0.1" /> <!--传感器--> <xacro:imu_xacro xyz="0.0 0.0 0.02" /> <xacro:laser_xacro xyz="0.0 0.0 0.1" /> <xacro:camera_xacro xyz="0.1 0.0 0.075" /> <!--执行器组件--> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/actuator/wheel.urdf.xacro" /> <xacro:include filename="$(find fishbot_description)/urdf/fishbot/actuator/caster.urdf.xacro" /> <!--执行器主动轮+从动轮--> <xacro:wheel_xacro wheel_name="left" xyz="0.0 0.1 -0.06" /> <xacro:wheel_xacro wheel_name="right" xyz="0.0 -0.1 -0.06" /> <xacro:caster_xacro caster_name="front" xyz="0.08 0.0 -0.076" /> <xacro:caster_xacro caster_name="back" xyz="-0.08 0.0 -0.076" /> </robot>
-
@43996173 在 6.3.2章节描述机器人惯量错误 中说:
<xacro:box_inertia m="0.05" l="${l}" w="${w}" h="${h}"/>
</link>在使用的时候要给具体的值,比如imu,lwh 就给0.02 0.02 0.02 ,写成参数就要从外部传入
-
@小鱼
ok,好了