Create custom model for SITL

This helps a lot and most importantly, it worked! Thanks :slight_smile:

1 Like

I am interested in making a model that in qgroundcontrol detects as a fixed-wing airplane. I don’t know if there is a pattern like iris in this case. I have tried plane but it detects it as a custom model.

I followed the instructions. Here is my issue:

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
Error: Unknown model my_vehicle (not found by name on /home/user/Desktop/File/PX4-Autopilot/build/px4_sitl_default/tmp/rootfs/etc/init.d-posix/airframes)
ERROR [px4] Startup script returned with return value: 256

I am new to these things but i checked the

/home/user/Desktop/File/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes

I can find the file which is instructions saying “4229_my_vehicle”

Can you help me about it ? Or are there any instructions for adding custom model(Couldn’t find properly) ?

@Fatih_Ozkan You need to add it to the cmake lists: PX4-Autopilot/CMakeLists.txt at master · PX4/PX4-Autopilot · GitHub

3 Likes

It handled the issue but now my model is not showin up in gazebo.

Thanks for your concern

@Fatih_Ozkan Please share exactly what you are doing and how it is failing. Otherwise we can’t help you other than tell you you are doing something wrong

HI, i tried the steps mentioned here but when i run make px4_sitl gazebo_76motordrone, it gets stuck at using the sdf file as shown but displayed no errors, its just stuck. Pls help me, thank you! :slight_smile:

src_path: /home/xavierrocker/Desktop/PX4-Autopilot
build_path: /home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default
GAZEBO_PLUGIN_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default/build_gazebo
GAZEBO_MODEL_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default/build_gazebo
empty world, default world 76motordrone.world for model found
Using: /home/xavierrocker/Desktop/PX4-Autopilot/Tools/sitl_gazebo/models/76motordrone/76motordrone.sdf

@Jaeyoung-Lim
Like @antonerasm said. I did:

  • I created a folder under Tools/sitl_gazebo/models for my model, named my_vehicle

  • I created the following files under Tools/sitl_gazebo/models/my_vehicle: model.config and my_vehicle.sdf (these can be based off the iris or solo models in Tools/sitl_gazebo/models)

  • I created a world file in Tools/sitl_gazebo/worlds called my_vehicle.world

  • I create my own airframe file in init.d-posix. Also i will use my own mixer.

  • I added the airframe name to the platforms/posix/cmake/sitl_target.cmake in the command set(models …)

  • And finaly i added name of it to PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes/CMakeLists.txt

My issues

  1. Can not connect to QGroundControl
  2. Now my model is showing up but can’t control. Motors spinnin freely.

Regards.

I created a world file in Tools/sitl_gazebo/worlds called my_vehicle .world

You need to remove your world file

My issues

  1. Can not connect to QGroundControl
  2. Now my model is showing up but can’t control. Motors spinnin freely.

This means that your mavlink interface is not configured properly with your mixers. To do it in steps and provide less confusion, change your custom model / airframe configs into a copy paste of the iris model, make sure everything works and then add your custom changes on top.
Otherwise you will have multiple issues showing up at once for everything you did wrong along the way.

1 Like

same ques, have u solved that? if you have,would u plz tell me how?

Sorry for late message. Thank you. I did it step by step and it solved.

I solved but can’t remember exactly but like @Jaeyoung-Lim said:

  1. First check your mixer and airframe. Most importantly check mixer.
  2. Go step by step and if you are getting specific error. Committing here will be helpful.
  3. For me my sdf wasn’t good enough so be sure about your model’s sdf. Check difference with same models and be careful about PX4 version

Hi, followed the same process. The model loads up and everything looks fine, but the terminal window is stuck at

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: IP Address

and loads up gazebo, but the terminal window doesn’t load any more text lines. I mean usually the [MSG] loads then lines come where we put commander takeoff. unable to get that with the custom mode, checked my mavlink interface and that looks normal.

sometimes get this error as well

[Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.

HI, i tried:

  • I created a folder under Tools/sitl_gazebo/models for my model, named x4vtail_vtol3
  • I created the following files under Tools/sitl_gazebo/models/x4vtail_vtol3: model.config and x4vtail_vtol3.sdf (which is based off the standard_vtol models in Tools/sitl_gazebo/models)
  • I create my own airframe file in init.d-posix, named 1044_x4vtail_vtol3. Also i will use my own mixer, name x4vtail_vtol3_sitl.main.mix.
  • I added the airframe name to the platforms/posix/cmake/sitl_target.cmake in the command set(models …)
  • And i added name of it to ROMFS/px4fmu_common/mixers-sitl/CMakeLists.txt.
    *Then, i run
cd build
cmake .. 
make
cd ..

*When i run
make px4_sitl gazebo_x4vtail_vtol3
it gets stuck at INFO [simulator] Waiting for simulator to accept connection on TCP port 4560 and gazebo do not open, here is the result:

[0/1] Re-running CMake...
-- PX4 version: v1.12.1
-- PX4 config file: /home/x/PX4-Autopilot/boards/px4/sitl/default.cmake
-- PX4 config: px4_sitl_default
-- PX4 platform: posix
-- PX4 lockstep: enabled
-- cmake build type: RelWithDebInfo
-- Building for code coverage
-- ccache enabled (export CCACHE_DISABLE=1 to disable)
-- build type is RelWithDebInfo
-- PX4 ECL: Very lightweight Estimation & Control Library v1.9.0-rc1-591-gb3fed06
-- ROMFS: ROMFS/px4fmu_common
-- Configuring done
-- Generating done
-- Build files have been written to: /home/x/PX4-Autopilot/build/px4_sitl_default
[0/4] Performing build step for 'sitl_gazebo'
ninja: no work to do.
[3/4] cd /home/x/PX4-Autopilot/build/px4_sitl_default/t...-Autopilot /home/x/PX4-Autopilot/build/px4_sitl_default
SITL ARGS
sitl_bin: /home/x/PX4-Autopilot/build/px4_sitl_default/bin/px4
debugger: none
program: gazebo
model: x4vtail_vtol3
world: none
src_path: /home/x/PX4-Autopilot
build_path: /home/x/PX4-Autopilot/build/px4_sitl_default
GAZEBO_PLUGIN_PATH :/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/px4_sitl_default/build_gazebo
GAZEBO_MODEL_PATH :/home/x/PX4-Autopilot/Tools/sitl_gazebo/models:/home/x/PX4-Autopilot/Tools/sitl_gazebo/models:/home/x/PX4-Autopilot/Tools/sitl_gazebo/models:/home/x/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH /home/x/catkin_ws/devel/lib:/opt/ros/melodic/lib:/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/posix_sitl_default/build_gazebo:/home/x/PX4-Autopilot/build/px4_sitl_default/build_gazebo
empty world, setting empty.world as default
Using: /home/x/PX4-Autopilot/Tools/sitl_gazebo/models/x4vtail_vtol3/x4vtail_vtol3.sdf
/home/x/PX4-Autopilot/Tools/sitl_run.sh: line 201: 30918 Segmentation fault      (core dumped) gzserver $verbose $world_path
SITL COMMAND: "/home/x/PX4-Autopilot/build/px4_sitl_default/bin/px4" "/home/x/PX4-Autopilot/build/px4_sitl_default"/etc -s etc/init.d-posix/rcS -t "/home/x/PX4-Autopilot"/test_data
INFO  [px4] Creating symlink /home/x/PX4-Autopilot/build/px4_sitl_default/etc -> /home/x/PX4-Autopilot/build/px4_sitl_default/tmp/rootfs/etc

______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
Info: found model autostart file as SYS_AUTOSTART=1044
INFO  [param] selected parameter default file eeprom/parameters_1044
[param] parameter file not found, creating eeprom/parameters_1044
  SYS_AUTOCONFIG: curr: 0 -> new: 1
  SYS_AUTOSTART: curr: 0 -> new: 1044
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
  CAL_MAG0_ID: curr: 0 -> new: 197388
  CAL_MAG1_ID: curr: 0 -> new: 197644
  SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
  SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
Gazebo multi-robot simulator, version 9.19.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
* SYS_AUTOCONFIG: curr: 1 -> new: 0
  IMU_INTEG_RATE: curr: 200 -> new: 250
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
PX4 SIM HOST: localhost
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4560

I have no idea about it ,can you help me? Please and Thanks! :sob:

I once added this model in another computer through the above steps. At that time, it could be successfully added, and my plane could fly normally. But this time I followed the same steps and failed. I don’t know why.

1 Like

I have the same problem
if anyone could help, it would be appreciated.
to find the solution to this problem, I used the iris model but just changed the name to something else, and I got the following errors:
@Jaeyoung-Lim Jaeyoung-Lim

[0/4] Performing build step for 'sitl_gazebo'
ninja: no work to do.
[3/4] cd /home/aminys/PX4-Autopilot/bu...s/PX4-Autopilot/build/px4_sitl_default
SITL ARGS
sitl_bin: /home/aminys/PX4-Autopilot/build/px4_sitl_default/bin/px4
debugger: none
program: gazebo
model: HB_x500
world: none
src_path: /home/aminys/PX4-Autopilot
build_path: /home/aminys/PX4-Autopilot/build/px4_sitl_default
GAZEBO_PLUGIN_PATH :/home/aminys/PX4-Autopilot/build/px4_sitl_default/build_gazebo
GAZEBO_MODEL_PATH :/home/aminys/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH :/home/aminys/PX4-Autopilot/build/px4_sitl_default/build_gazebo
empty world, setting empty.world as default
Using: /home/aminys/PX4-Autopilot/Tools/sitl_gazebo/models/HB_x500/HB_x500.sdf
Warning [parser.cc:833] XML Attribute[version] in element[sdf] not defined in SDF, ignoring.
Error [Param.cc:329] Invalid boolean value
Error [Param.cc:329] Invalid boolean value
Error [Param.cc:449] Invalid argument. Unable to set value [{{ mavlink_udp_port }} ] for key[mavlink_udp_port].
Error [Param.cc:449] Invalid argument. Unable to set value [{{ mavlink_tcp_port }} ] for key[mavlink_tcp_port].
SITL COMMAND: "/home/aminys/PX4-Autopilot/build/px4_sitl_default/bin/px4" "/home/aminys/PX4-Autopilot/build/px4_sitl_default"/etc -s etc/init.d-posix/rcS -t "/home/aminys/PX4-Autopilot"/test_data
Creating symlink /home/aminys/PX4-Autopilot/build/px4_sitl_default/etc -> /home/aminys/PX4-Autopilot/build/px4_sitl_def

I have a question, if I change let’s say the box size in the sdf file, will the physical properties change like will it simulate according to real life conditions based on the measurements given

Same error, anything new ?

Hello!
I’m relatively new to this, I was trying to follow these steps, but I find myself stuck at the last step. I can’t find the sitl_target.cmake. I don’t see in on main in Github as well. What changes should I incorporate to get this working?
Any help would be appreciated!
Thanks in advance!

Hi. I created the model according to the instructions. Error on startup. I also get the same error if I run some of the list of available models. For example:models iris, plane, plane_catapult, boat - start normally; models iris_rplidar, iris_opt_flow, plane_lidar, iris_foggy_lidar - do not start and give an error.

https://github.com/Andreykulachenko/catkin_ws/issues/1