How to change the appearance of "standard_vtol" drone model with custom VTOL drone model?

Dear friends,
This is my first post on the “discuss.px4” and I would like to get your guidance for the described problem in the thread title.

I try to change the standard_vtol model’s appearance with my custom drone model which I am using “ROS Gazebo PX4” combination that I control my drone from ROS already.

I have designed x5 new models for each wanted “dae files” to use on the default “standard_vtol”. Normally, everything is same that nothing changed - excepted the appearance with my custom design.

However, when I launch the gazebo px4 with ros, everything is still same that the original appearance of “standard_vtol” drone didn’t change with my custom model appearance at all. I even deleted "src>sitl_gazebo>models + PX4-Autopilo>Tools>sitl_gazebo>models + even the "/usr/share/mavlink_sitl_gazebo>models"s standard_vtol meshes dae files but still when I run the program, standard vtol model is generated by the program while it shouldn’t be at all. At the end, I couldn’t figure out why my custom model is not generated at all.

This is my “launch-common3.sh” file’s inside:
cd ~/src/PX4-Autopilot/
DONT_RUN=1 make px4_sitl_default gazebo
source ~/catkin_ws/devel/setup.bash # (optional)

#source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default

source ~/src/PX4-Autopilot/Tools/setup_gazebo.bash ~/src/PX4-Autopilot/ ~/src/PX4-Autopilot/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo

This is my “launch-offb3.sh” file’s inside:
#!/bin/bash

source ./launch-common3.sh

roslaunch offb offb3.launch

This is my “launch-offb3.launch” file’s inside:
<?xml version="1.0"?>

    <node name="offb" pkg="offb" type="offb_node3" output="screen"/>
</launch>

This is the “mavros_posix_sitl.launch” from “src/PX4-Autopilot/launch” file’s inside:
<?xml version="1.0"?>

























    <!-- gazebo configs -->
    <arg name="gui" default="true"/>
    <arg name="debug" default="false"/>
    <arg name="verbose" default="false"/>
    <arg name="paused" default="false"/>
    <arg name="respawn_gazebo" default="false"/>
    <!-- MAVROS configs -->
    <arg name="fcu_url" default="udp://:14540@localhost:14557"/>
    <arg name="respawn_mavros" default="false"/>
    <!-- PX4 configs -->
    <arg name="interactive" default="true"/>
    <!-- PX4 SITL and Gazebo -->
    <include file="$(find px4)/launch/posix_sitl.launch">
        <arg name="x" value="$(arg x)"/>
        <arg name="y" value="$(arg y)"/>
        <arg name="z" value="$(arg z)"/>
        <arg name="R" value="$(arg R)"/>
        <arg name="P" value="$(arg P)"/>
        <arg name="Y" value="$(arg Y)"/>
        <arg name="world" value="$(arg world)"/>
        <arg name="vehicle" value="$(arg vehicle)"/>
        <arg name="sdf" value="$(arg sdf)"/>
        <arg name="gui" value="$(arg gui)"/>
        <arg name="interactive" value="$(arg interactive)"/>
        <arg name="debug" value="$(arg debug)"/>
        <arg name="verbose" value="$(arg verbose)"/>
        <arg name="paused" value="$(arg paused)"/>
        <arg name="respawn_gazebo" value="$(arg respawn_gazebo)"/>
    </include>
    <!-- MAVROS -->
    <include file="$(find mavros)/launch/px4.launch">
        <!-- GCS link is provided by SITL -->
        <arg name="gcs_url" value=""/>
        <arg name="fcu_url" value="$(arg fcu_url)"/>
        <arg name="respawn_mavros" value="$(arg respawn_mavros)"/>
    </include>
</launch>

This is the Path inside of my gedit ~/.bashrc file:
# PX4 Gazebo Path
# Set the plugin path so Gazebo finds our model and sim
export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:$HOME/src/sitl_gazebo/build
# Set the model path so Gazebo finds the airframes
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/src/sitl_gazebo/models
# Disable online model lookup since this is quite experimental and unstable
export GAZEBO_MODEL_DATABASE_URI=""

# Set path to sitl_gazebo repository
export SITL_GAZEBO_PATH=$HOME/src/sitl_gazebo

Right now, I am very confused. I couldn’t find anything related to this problem to solve, or any kind of tutorial related to this subject in the internet. I still want to use the default “standard_vtol” but with my custom drone model appearance. Thus, I will be very glad if you would like to guide me about this too, thank you very much.

Which file are you editing to change the appearance?

“standard_vtol” file from sitl_gazebo/models inside of the PX4-Autopilot > Tools.

I found the cause but there is a strange problem. Go to
/src/PX4-Autopilot/launch/mavros_posix_sitl.launch file and you will this line of code that directs you to /usr/share/mavlink_sitl_gazebo

<arg name="vehicle" default="standard_vtol"/>
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/>
<arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg vehicle)/$(arg vehicle).sdf"/>

Although my defined path in “bashrc” is linked to “/src/sitl_gazebo” as plugin, models, resource path etc, why PX4 forces me to use mavlink_sitl_gazebo??? which it is kind of hard to change many things in PX4 while using ROS and Gazebo (but these are much easier to achieve in Ardupilot ROS Gazebo).

At the end, I changed the “.dae file” for standard_vtol and then this problem occurred (you can see it on the shared screenshot) which this issue is exist for trying to change any default PX4 vehicle models with your own custom vehicle models. I have done the same things at Ardupilot Gazebo models and thy are instantly changed into the model I have applied.

Therefore, I would like to ask that, how can I do the same things in PX4 too? There is zero information for such matter/subject in the internet. I will be very glad if someone would guide me to solve this problem (sorry if I complained some but I try to solve this issue for one week already), so at the end I wanted to seek guidance from discuss.px4.io section, thank you.

I still don’t understand why you have sitl_gazebo in /usr/share/mavlink_sitl_gazebo
Did you try installing sitl_gazebo?

$(find mavlink_sitl_gazebo) should not direct your path to /usr/share/mavlink_sitl_gazebo . If this is the case, your path is not configured correctly. To configure your path correctly try running as mentioned in https://dev.px4.io/master/en/simulation/ros_interface.html

cd <PX4-Autopilot_clone>
DONT_RUN=1 make px4_sitl_default gazebo
source ~/catkin_ws/devel/setup.bash    # (optional)
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch

and what is /src/sitl_gazebo ? where is this src?

This “mavlink_sitl_gazebo” is generated itself when I had installed PX4 from your given link already.
Official PX4 mavros_posix_sitl inside code which this “mavros_posix_sitl” only search for ROS Path which it was generated by PX4 itself. It seems like noone had ever tried to change the default drone models with their custom models to fly by using the default drone control with ros px4 gazebo; because there is zero information in internet.

When I wanted to set up PX4 - ROS - Gazebo for the first time, I had followed tutorials’ steps which one of the tutorial says to install “sitl_gazebo” separately as /home/aykut/src/sitl_gazebo where my PX4-Autopilot is installed there too ( /home/aykut/src/PX4-Autopilot), after you installed the PX4 - sitl gazebo installation which I had followed the steps there if you look at the website.

At that website for testing, it was saying type these commands which I had done the same
https://github.com/PX4/PX4-SITL_gazebo
## Testing
Gazebo will now launch when typing ‘gazebo’ on the shell:

. /usr/share/gazebo/setup.sh
. /usr/share/mavlink_sitl_gazebo/setup.sh
gazebo worlds/iris.world

Another tutorial I had followed for PX4 Sitl Gazebo Example is this too: PX4 SITL Example - Offboard . I am a newbie with PX4 so I just followed the tutorials which mainly because of PX4 offboard ros sitl example to apply that on PX4 official website - it only shows the example code but it doesn’t mention about previous steps to follow. As a newbie like me, I had confused a lot to make the proper setup and configuration and testing; because I want to control my drone from ROS with my own code (otherwise - already has done automatically with QGroundControl).

Right now, I am really confused what to do. Thus, if it is possible, would you tell me how to correct these? Such as my launch file that I want to control the “standard_vtol” (I follow what is typed in the official website too) or how to make computer to get the gazebo models for the given paths (which my given correct paths are not followed when I run my launch file).

And how to clean/remove these extra files from the system totally?

I will be very glad if you would guide me @Jaeyoung-Lim because I don’t know whom to ask or get some help and guidance and thank you for replying my questions with patient too.

After lots of testing and trials and checking the code of default PX4 drone model too, I found the main cause of everything… x8_wing.dae size which is the main body frame of “standard_vtol” drone model is too huge, it is like a mega VTOL drone model… (model path is here /home/aykut/src/PX4-Autopilot/Tools/sitl_gazebo/models/standard_vtol).

In addition to that, I have reorganized my Paths and I removed the unnecessary extra “sitl_gazebo” files.

# PX4 Gazebo Path - NEW PATH
export GAZEBO_PLUGIN_PATH=/home/aykutsirma/src/PX4-Autopilot/build/px4_sitl_default/build_gazebo:${GAZEBO_PLUGIN_PATH}

export GAZEBO_MODEL_PATH=/home/aykutsirma/src/PX4-Autopilot/tools/sitl_gazebo/models:${GAZEBO_MODEL_PATH}

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/aykutsirma/src/PX4-Autopilot/build/px4_sitl_default/build_gazebo

export GAZEBO_MODEL_DATABASE_URI=""

# Set path to sitl_gazebo repository
export SITL_GAZEBO_PATH=$HOME/src/PX4-Autopilot/tools/sitl_gazebo

I have added this in <collision name='base_link_collision'> section

model://standard_vtol/meshes/x8_wing.dae

And I have changed the <visual name='base_link_visual'> section’s scale part from <scale>0.001 0.001 0.001</scale> to <scale>1 1 1</scale> (normal size).

<collision name='base_link_collision'>
        <pose>0 0 -0.08 0 0 0</pose>
        <geometry>
          <mesh>
            <uri>model://standard_vtol/meshes/x8_wing.dae</uri>
          </mesh>
          <box>
            <size>0.55 2.144 0.05</size>
          </box>
        </geometry>
        <surface>
          <contact>
            <ode>
              <kp>100000</kp>
              <kd>1.0</kd>
              <max_vel>0.1</max_vel>
              <min_depth>0.001</min_depth>
            </ode>
          </contact>
          <friction>
            <ode/>
          </friction>
        </surface>
      </collision>
      <visual name='base_link_visual'>
        <pose>0 0 0.5 0 0 0</pose>
        <geometry>
          <mesh>
            <scale>1 1 1</scale> <!-- <scale>0.001 0.001 0.001</scale> -->
            <uri>model://standard_vtol/meshes/x8_wing.dae</uri>
          </mesh>
        </geometry>
        <material>
          <script>
            <name>Gazebo/DarkGrey</name>
            <uri>__default__</uri>
          </script>
        </material>
      </visual>

After everything has done, I wanted to see what is going to happen in gazebo as visually with a custom look and another problem occurred again: “The positioning became a mess with custom drone model” on standard_vtol example…

To make a nice model to use on default "

standard_vtol

" but by using our custom drone appearance, what should we do / how to prepare the "

standard_vtol.sdf

" file which is at the location of

/home/aykut/src/PX4-Autopilot/Tools/sitl_gazebo/models/standard_vtol

? thank you very much.

Good to see that you are making progress!

It seems like noone had ever tried to change the default drone models with their custom models to fly by using the default drone control with ros px4 gazebo; because there is zero information in internet.

I don’t think this is true. I think the reason you can’t find much information is because the problem you are trying to solve is not PX4 specific. If you know how to configure gazebo, it is quite straight forward how sitl_gazebo is structured. So you will have a better chance looking at how to add models in Gazebo, and not how to modify PX4 models

I have added this in <collision name='base_link_collision'> section

This means you are adding a “collision geometry” as your mesh, which is not visible. This has implications such as making your simulation more computationally expensive, since the simulation needs to compute the collision of your models through the mesh you defined. As you may have noticed, that is why the collision geometry of standard_vtol is a box rather than the actual geometery of the vehicle to save computational resources.

1 Like

Thank you Jeyoung. Yes you are right - this drone’s model modification is mainly related to gazebo but when I had compared the arducopter drone design in gazebo and the px4 drone design in gazebo are not so similar while preparing the “.sdf file in the models section of gazebo”. For these subjects, there are not good step by step tutorials to prepare complex / custom drones to use in PX4 or Arducopter etc for ros gazebo usage (for newbie people which there are rare tutorials for the current editions), at least this is what I have seen so far for the last one week research on the internet.

@Jaeyoung-Lim friend, I have one more question too. I had applied “iris_fpv_cam” to my drone via adding codes in sdf file in the model folder. However, when I try to get images with darknet ros, it doesn’t detect the camera node because the ros topic doesn’t receive anything.

Thus, do you know that how can we use the darknet ros with px4 drone in gazebo ros? I will be very happy if you would guide me about this too, thank you very much. I just want to add a nice feature to my drone model in ros px4 gazebo environment.

Would it be possible to write your experience down, and contribute a step by step guide to the PX4 documentation? https://github.com/PX4/PX4-user_guide

This will help people to not suffer with the same issue you had, and I believe you are the best person to write it since you are fresh from suffering.

@aykut_sirma I can see that your darknet_ros is not receiving any camera images, but have you checked if the gazebo_ros_camera plugin is publishing images? if so, it is simply a topic namespace issue

2 Likes

There are a lot of people interested, how to add/modify models in gazebo and use px4 for control.Looking forward to someone can provide some documentation, that would be great! :grinning:

@xdwgood My question is, why is http://gazebosim.org/tutorials?tut=build_model not enough?

Good information thanks for sharing
vmware

some ref. GitHub - mengchaoheng/DuctedFanUAV-Autopilot: This is an autopilot for DFUAV, forked from PX4-Aotupilot, supports gazebo simulation (ubuntu/macOS), and has been flight tested on DFUAV equipped with pixhawk.