ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Issues utilizing xacro properties [closed]

asked 2021-02-25 08:52:59 -0600

hamdi sharaf gravatar image

updated 2021-02-25 09:51:05 -0600

launch file

<?xml version="1.0"?>

<launch>
    <arg name ="model"/>
    <param name="robot_description" textfile="$(find three_wheel_robot)/urdf/robot.xacro"/>
    <param name="use_gui" value="true"/>
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"/>
    <node name="rviz" pkg="rviz" type="rviz" args ="" required="true"/>

</launch>

xacro file

<?xml version="1.0"?>
<robot name="macroed" xmlns:xacro="http://ros.org/wiki/xacro">

  <xacro:property name="width" value="0.2" />
  <xacro:property name="leglen" value="0.6" />
  <xacro:property name="polelen" value="0.2" />
  <xacro:property name="bodylen" value="0.6" />
  <xacro:property name="baselen" value="0.4" />
  <xacro:property name="wheeldiam" value="0.07" />
  <xacro:property name="pi" value="3.1415" />

  <material name="blue">
    <color rgba="0 0 0.8 1"/>
  </material>

  <material name="black">
    <color rgba="0 0 0 1"/>
  </material>

  <material name="white">
    <color rgba="1 1 1 1"/>
  </material>

  <xacro:macro name="default_inertial" params="mass">
    <inertial>
      <mass value="${mass}" />
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
    </inertial>
  </xacro:macro>

  <link name="base_link">
    <visual>
      <geometry>
        <cylinder radius="${width}" length="${bodylen}"/>
      </geometry>
      <material name="blue"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="${width}" length="${bodylen}"/>
      </geometry>
    </collision>
    <xacro:default_inertial mass="10"/>
  </link>

  <xacro:macro name="wheel" params="prefix suffix reflect">

    <link name="${prefix}_${suffix}_wheel">
      <visual>
        <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
        <geometry>
          <cylinder radius="${wheeldiam/2}" length="0.1"/>
        </geometry>
        <material name="black"/>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
        <geometry>
          <cylinder radius="${wheeldiam/2}" length="0.1"/>
        </geometry>
      </collision>
      <xacro:default_inertial mass="1"/>
    </link>
    <joint name="${prefix}_${suffix}_wheel_joint" type="continuous">
      <axis xyz="0 1 0" rpy="0 0 0" />
      <parent link="${prefix}_base"/>
      <child link="${prefix}_${suffix}_wheel"/>
      <origin xyz="${baselen*reflect/3} 0 -${wheeldiam/2+.05}" rpy="0 0 0"/>
    </joint>

  </xacro:macro>

  <xacro:macro name="leg" params="prefix reflect">
    <link name="${prefix}_leg">
      <visual>
        <geometry>
          <box size="${leglen} 0.1 0.2"/>
        </geometry>
        <origin xyz="0 0 -${leglen/2}" rpy="0 ${pi/2} 0"/>
        <material name="white"/>
      </visual>
      <collision>
        <geometry>
          <box size="${leglen} 0.1 0.2"/>
        </geometry>
        <origin xyz="0 0 -${leglen/2}" rpy="0 ${pi/2} 0"/>
      </collision>
      <xacro:default_inertial mass="10"/>
    </link>

    <joint name="base_to_${prefix}_leg" type="fixed">
      <parent link="base_link"/>
      <child link="${prefix}_leg"/>
      <origin xyz="0 ${reflect*(width+.02)} 0.25" />
    </joint>

    <link name="${prefix}_base">
      <visual>
        <geometry>
          <box size="${baselen} 0.1 0.1"/>
        </geometry>
        <material name="white ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by hamdi sharaf
close date 2021-05-08 17:32:07.185180

Comments

@hamdi sharaf in the future please use the 101010 button to format code blocks. I've edited your question and provided a more descriptive title. Best of luck getting your problem solved!

jarvisschultz gravatar image jarvisschultz  ( 2021-02-25 09:53:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-25 21:47:28 -0600

jdlangs gravatar image

You are setting the robot_description parameter to the contents of your xacro file but it actually needs URDF data, which you use the xacro program to generate. The way this is normally done is something like:

<param name="robot_description" command="$(find xacro)/xacro '$(find three_wheel_robot)/urdf/robot.xacro'" />

Using the command attribute instead of textfile runs the value as a shell command and sets the parameter value to the output of that command.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-02-25 08:52:59 -0600

Seen: 205 times

Last updated: Feb 25 '21