Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

Relative path for obj files

Hi, I would like to load OBJ files for the models inside my world but Gazebo can't find it even when I define the env GAZEBO_MODEL_PATH on gazebo 9.

Here is my gazebo launch file

<launch> <env name="GAZEBO_MODEL_PATH" value="$(find f190_gazebo)/models:$(optenv GAZEBO_MODEL_PATH)"/> <arg name="model" default="$(find f190_description)/urdf/gazebo.xacro"/> <arg name="namespace" default="/f190"/> <arg name="world_name" default="$(find f190_gazebo)/worlds/road.world"/> <arg name="cmd_timeout" default="0.5"/> <arg name="x" default="80.0"/> <arg name="y" default="1.0"/> <arg name="z" default="0.6"/> <arg name="roll" default="0.0"/> <arg name="pitch" default="0.0"/> <arg name="yaw" default="3.14"/>

<group ns="$(arg namespace)">

    <!-- Gazebo  -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" default="$(arg world_name)"/>    
    </include>

    <!-- Load the robot description -->
    <param name="robot_description" command="$(find xacro)/xacro $(arg model)"/>

    <!-- Load ros_controllers configuration parameters -->
    <rosparam file="$(find f190_control)/config/ctrl_ackermann_steering_controller.yaml" command="load" ns="$(arg namespace)" />
    <rosparam file="$(find f190_control)/config/control_ackermann_drive.yaml" command="load" ns="$(arg namespace)" />
    <rosparam file="$(find f190_control)/config/ctrl_gains.yaml" command="load" ns="$(arg namespace)" />
    <rosparam file="$(find f190_control)/config/ctrl_joint_state_publisher.yaml" command="load" ns="$(arg namespace)" />
    <rosparam file="$(find f190_control)/config/ctrl_steer_bot_hardware_gazebo.yaml" command="load" ns="$(arg namespace)" />

    <!-- Spawn the controllers -->
    <node pkg="controller_manager" type="spawner" name="controller_spawner" ns="$(arg namespace)"
        args="joint_state_publisher ackermann_steering_controller"
        output="screen" respawn="false" />

    <!-- Launch  the robot state publisher -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
        <param name="publish_frequency" value="50.0"/>
    </node>

    <!-- Launch a rqt steering GUI for publishing to /steer_bot/steer_drive_controller/cmd_vel -->
    <node pkg="rqt_robot_steering" type="rqt_robot_steering" name="rqt_robot_steering" >
        <param name="default_topic" value="$(arg namespace)/ackermann_steering_controller/cmd_vel"/>
    </node>

<!-- Launch rviz -->
<node type="rviz" name="rviz" pkg="rviz" args="-d $(find f190_viz)/rviz/f190.rviz" />

    <!-- Spawn robot in Gazebo -->
    <node name="spawn_vehicle" pkg="gazebo_ros" type="spawn_model"
        args="-urdf -param robot_description -model f190
            -gazebo_namespace /$(arg namespace)/gazebo
            -x $(arg x) -y $(arg y) -z $(arg z)
            -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"
        respawn="false" output="screen" />

</group>

</launch>

My file hierarchy is as follow :

f190_gazebo

  • models
    • obj files
  • world
    • world files

One of my world file :

<sdf version="1.6"> <world name="default"> <include> <uri>model://ground_plane</uri> </include> <include> <uri>model://sun</uri> </include>

<model name="road1">
  <pose>61.794 -0.693 0.10  1.57 0 0</pose>
  <static>true</static>
  <link name="body">
    <visual name="visual">
      <geometry>
        <mesh><uri>Asphalt_Subdiv_2_89.obj</uri><scale>0.01 0.01 0.01</scale></mesh>
      </geometry>
    </visual>
  </link>
</model>

<model name="road2">
  <pose>30 -0.34 0.10  1.57 0 0</pose>
  <static>true</static>
  <link name="body">
    <visual name="visual">
      <geometry>
        <mesh><uri>/home/user/Documents/f190_ws/src/f190/f190_gazebo/models/Asphalt_Subdiv_2_89.obj</uri><scale>0.01 0.01 0.01</scale></mesh>
      </geometry>
    </visual>
  </link>
</model>

<model name="road3">
  <pose>0 0 0.10  1.57 0 0</pose>
  <static>true</static>
  <link name="body">
    <visual name="visual">
      <geometry>
        <mesh><uri>/home/user/Documents/f190_ws/src/f190/f190_gazebo/models/Asphalt_Subdiv_2_89.obj</uri><scale>0.01 0.01 0.01</scale></mesh>
      </geometry>
    </visual>
  </link>
</model>

<model name="road4">
  <pose>-30.02 0.32 0.10  1.57 0 0</pose>
  <static>true</static>
  <link name="body">
    <visual name="visual">
      <geometry>
        <mesh><uri>/home/user/Documents/f190_ws/src/f190/f190_gazebo/models/Asphalt_Subdiv_2_89.obj</uri><scale>0.01 0.01 0.01</scale></mesh>
      </geometry>
    </visual>
  </link>
</model>

</world>

</sdf>

No issue when I try absolute paths.