PX4 / PX4-Devguide

PX4 Devguide GitBook
http://dev.px4.io
Other
194 stars 482 forks source link

Missing Topic: How to integrate customised Gazebo copter models into the code base #398

Open hamishwillee opened 6 years ago

hamishwillee commented 6 years ago

From #391 "Another nice to have would be how to integrate customised gazebo quadcopter models into the code base. Took me a bit to figure that out and I’m still not sure that I’m following best practices."

taleteorganista commented 5 years ago

@jannsta1 Thank-you, it works!

hamishwillee commented 5 years ago

@lamping7 you make a very good point where you say:

I'm not really sure what is confusing you: I think it's the 10 month old info at the top.

@lamping7 @jannsta1

We're at the point now that the current state of this needs to be a PR. That we can work through and test. Then future change and issues can be discussions against a clear baseline. Can one of you guys volunteer to create a PR based on our current knowledge? Then we'll ask the other and @ChuplesKai if they can test those instructions.

Looking at this.

NOTE In general I am wary of tutorials. They are great if every step is very similar for all cases, but have a tendency to miss things that are off that centre path. So what I propose here is that whether or not we use a tutorial to illustrate, we start with the "these are the topics that we want to cover" as headings, and then start filling them in. @jannsta1 seems to have done that well but I'm not the right one to judge.

Thoughts?

hamishwillee commented 5 years ago

PS. We know we want the structure to include topics related to modelling the motors. @TSC21 proposed some topics needed: importing an URDF from SolidWorks and convert it to an SDF, what plugins to include in the model, modelling the motors, modelling the control surfaces ...

I am happy for many of these to be just TBD in the PR. But would be good if we could capture all the topic headings that we eventually intend to populate. So if there are any you would like to see, please add here.

hamishwillee commented 5 years ago

@lamping7 @TSC21 - Jan does not feel confident to create the initial structure of topics. Would you be willing to do so and populate with the current steps? (As discussed above: https://github.com/PX4/Devguide/issues/398#issuecomment-441152892)

TSC21 commented 5 years ago

@hamishwillee Yeah I will do that along this week.

taleteorganista commented 5 years ago

I would appreciate a documnetation on how to add sensors to the copter sdf file. I'd like also to understand how to perform multi-vehicle simulation with custom sensors (i.e. one copter with camera, another with laser scanner and so on...) and how to model my own drone. Thankyou

hamishwillee commented 5 years ago

@TSC21

Yeah I will do that along this week.

Nag nag nag

TSC21 commented 5 years ago

@hamishwillee I have a initial structure for it but I still feel some things are missing. Been out of bandwidth, sorry.

hamishwillee commented 5 years ago

@TSC21 That's fine :-) I'll keep nagging.

Veilkrand commented 5 years ago

What I do for using my own models without creating additional PX4 is to keep the same target and vehicle name iris and pass my model path with the sdf argument.

hamishwillee commented 5 years ago

@TSC21 And here I am again :-)

TSC21 commented 5 years ago

What I do for using my own models without creating additional PX4 is to keep the same target and vehicle name iris and pass my model path with the sdf argument.

This is not the point of the discussion here. This is rather if one wants to have a proper simulation of their vehicle, how can one add it to the PX4 SITL pipeline and Gazebo.

@TSC21 And here I am again :-)

@hamishwillee ahah I know sorry, have been quite busy lately.

RicardoM17 commented 5 years ago

Any progress here @hamishwillee ?? now it's my turn to nag :stuck_out_tongue_closed_eyes:

hamishwillee commented 5 years ago

@RicardoM17 That's a question for @TSC21 :-) I'm not going to even attempt to progress this without him.

Oliver-ss commented 5 years ago

I'm not really sure what is confusing you @jannsta1 and @ChuplesKai: I think it's the 10 month old info at the top. I also don't think it is understood how the setup and launching works. The basic thing to know that might remove some confusion is that there are two main ways to launch PX4 and Gazebo. One is with make and the other is with roslaunch. I play around with ROS, so I'm going to only touch on that.

Let's do a simple example: I'm going to show you how to make a copy of the iris model and launch it, explaining it a bit on the way. I'll call this new vehicle iris-copy. Hopefully this will show you what parts are important, where they live, and what changes are required.

Prerequisites:

1. Clone PX4 Firmware

2. Enter PX4 Firmware directory

3. Build the firmware
   `make posix_sitl_default`

4. Build sitl_gazebo, and do not launch gazebo yet
   `make posix_sitl_default sitl_gazebo`

5. Setup your environment. For example, this is in my `~/.bashrc`:
# PX4
export PX4_SRC_DIR=~/px4/Firmware
source ${PX4_SRC_DIR}/Tools/setup_gazebo.bash ${PX4_SRC_DIR} ${PX4_SRC_DIR}/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${PX4_SRC_DIR}:${PX4_SRC_DIR}/Tools/sitl_gazebo

Here we go:

1. Go to the models directory in your PX4 Firmware directory
   `cd ~/Firmware/Tools/sitl_gazebo/models`

2. Copy the model directory, and enter it
   `cp -R iris iris-copy`
   `cd iris-copy`

3. Rename the file and some bits inside them
   `mv iris.sdf iris-copy.sdf`
   `sed -i 's/iris/iris-copy/g' model.config`
   `sed -i 's/name='"'"'iris'"'"'/name='"'"'iris-copy'"'"'/g' iris-copy.sdf`

4. Go to the startup (rcS) file directory
   `cd ../../../../ROMFS/px4fmu_common/init.d-posix`

5. Make a copy
   `cp 10016_iris 10017_iris-copy`

6. Enjoy!
   `roslaunch px4 posix_sitl.launch vehicle:=iris-copy`

Hi, I just wondering if I want to use my own custom model, how could I create my model file after cd ../../../../ROMFS/px4fmu_common/init.d-posix

hamishwillee commented 5 years ago

@TSC21 Would be nice to progress this ... I know you are always busy, so what can we do to make it more of a priority? If you will never have time available, is there someone else you can recommend to help with this?

imagotechteam commented 5 years ago

roslaunch px4 posix_sitl.launch vehicle:=iris-copy

What would that be to launch a custom vehicle with make ?

hamishwillee commented 5 years ago

@imagotechteam YOu post above is a technical support query, and not particularly relevant to this post. Please post on the discussion boards.

tuloski commented 5 years ago

Can also someone explain how the .sdf are generated from the .xacro? For example for the iris model it seems that the .sdf are automagically generated from .xacro (inside the /models/rotor_description/urdf) which is much more readable.

jannsta1 commented 5 years ago

Did you read the gazebo help pages about URDF? e.g. http://gazebosim.org/tutorials/?tut=ros_urdf. I think it's explained quite comprehensively there. I haven't used them a lot but the way I think of it is that the URDF gets converted into the .sdf, xacros are a feature of URDF. e.g. https://answers.ros.org/question/202162/urdf-or-xacro/

tuloski commented 5 years ago

Yeah, but I'd like to understand which script (I think there is one) in the px4 firmare builds the .sdf from the .xacro and how to add custom .xacro that will build automatically the .sdf for new models.

RicardoM17 commented 5 years ago

@tuloski https://github.com/PX4/sitl_gazebo/blob/a0b0eb8df12b11e8f63d3cc766dee97cefa32ab7/scripts/xacro.py

But please if you have further questions move this to discuss. ;) This thread is not the place for it.

tuloski commented 5 years ago

@RicardoM17 I think this is the thread, because in the documentation of how to integrate customized models I'd like to see explained how to use xacro instead of sdf.

Moreover on discuss none ever answer :) .