Home | Tutorials | Wiki | Issues
Ask Your Question
0

Spawn hector quadrotor in custom gazebo world.

asked 2015-09-11 08:45:57 -0500

Tonystark124 gravatar image

I created a custom world using model editor in gazebo4, as shown below.

image description

I was trying to run a fun project where I can fly the quadrotor model through the rings, using vision based algorithm and solution. Thus, I came across hector quadrotor and wanted to use the robot model in this world.

This command can spawn the quadrotor into an empty world

    roslaunch gazebo_ros empty_world.launch

but this requires to have gazebo_ros. and that would remove gazebo4 and this world I created. Can I spawn the hector quadrotor directly into this world of gazebo4?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-09-13 09:50:37 -0500

niall gravatar image

Sure you can. I did exactly this with lots of worlds by just creating a catkin package called quad_world with a launch file in it that spawns the quadcopter and all kinds of other stuff (I used quadrotor_empty_world.launch as base).

As follows: start.launch contains:

<arg name="world_name" default="$(find quad_world)/worlds/tonystart124.world" />
<include file="$(find quad_world)/launch/world.launch">
  <arg name="world_name" default="$(arg world_name)"/>
</include>

<include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch" />

world.launch is the following: <launch>

  <!-- these are the arguments you can pass this launch file, for example paused:=true -->
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>

  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>
  <arg name="verbose" default="false" />

  <arg name="world_name" />

  <!-- set use_sim_time flag -->
  <group if="$(arg use_sim_time)">
    <param name="/use_sim_time" value="true" />
  </group>

  <!-- set command arguments -->
  <arg unless="$(arg paused)" name="command_arg1" value=""/>
  <arg     if="$(arg paused)" name="command_arg1" value="-u"/>
  <arg unless="$(arg headless)" name="command_arg2" value=""/>
  <arg     if="$(arg headless)" name="command_arg2" value="-r"/>
  <arg unless="$(arg verbose)" name="command_arg3" value=""/>
  <arg     if="$(arg verbose)" name="command_arg3" value="--verbose"/>
  <arg unless="$(arg debug)" name="script_type" value="gzserver"/>
  <arg     if="$(arg debug)" name="script_type" value="debug"/>

  <!-- start gazebo server-->
  <node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="false" output="screen"
    args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) $(arg world_name)" />

  <!-- start gazebo client -->
  <node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen"/>


</launch>

Good luck with your project!

edit flag offensive delete link more

Comments

thanks a lot for your answer. am considerably new to ROS and Gazebo. Could you please tell me how I should go about using these launch files? The world file I have saved is as ".sdf".

Tonystark124 gravatar imageTonystark124 ( 2015-09-13 20:39:13 -0500 )edit

should I save my world as .world?

Tonystark124 gravatar imageTonystark124 ( 2015-09-13 20:58:44 -0500 )edit

sorry for anotherquestion, but is gazeo_ros required for this?

Tonystark124 gravatar imageTonystark124 ( 2015-09-13 21:08:27 -0500 )edit
1

Yes and yes. Save it as .world instead of .sdf and if you look at the last command of world.launch you see the node `gazebo_ros` is started.

niall gravatar imageniall ( 2015-09-14 03:33:07 -0500 )edit
1

answered 2015-09-14 00:47:54 -0500

scpeters gravatar image

Try installing ros-indigo-gazebo4-ros-pkgs, since it sounds like you have already followed the instructions on getting packages from packages.osrfoundation.org.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-09-11 08:45:57 -0500

Seen: 1,733 times

Last updated: Sep 14 '15