Servers by jDrones

Include own JSBSim-Model in ardupilot


(Max Alt) #1

Hello. Our Team is trying to simulate a quadplane. We want to use most Systems which are in ArduPlane but with our own aerodynamic-model (JSBSim). Therefore we already build a model which works in FlightGear. Now we want to include the model in ardupilot. For that we copied the model into “ardupilot\Tools\autotest\aircraft”. …
To start the simulation we first start FlightGear(3.4.0) with our model. Than we type in the Cygwin Terminal. “cd ~/ardupilot/ArduPlane” and “sim_vehicle.py -f jsbsim:MyModel”. Now the simulation starts as it should. But the problem is that after connecting to MissionPlanner(1.3.50.0), the vehicle can’t fly or even take-off. We have tried the same with “sim_vehicle.py -f jsbsim:Rascal” with the same problem.

When typing in “sim_vehicle.py -j4 -f quadplane -L KSFO” everything works.

Could you please help us to find out what we did wrong?

Thanks :slight_smile:


(peterbarker) #2

Could you please help us to find out what we did wrong?

Are you setting parameters appropriate to the frame?

This is currently done magically for “quadplane”
(https://github.com/ardupilot/ardupilot/blob/master/Tools/autotest/pysim/vehicleinfo.py#L138)

It looks like setting parameters based on a jsbsim frame could be
problematic. So instead of trying to fix that initially, you could
attempt to load your own parameter file using “param load” in the SITL
"console".


(Max Alt) #3

Hi. Thanks for the quick answer!

Yes we already tried to setup some parameters in there. But not all, because we first wanted to test if it is flying at all or not. This morning we looked again but haven’t understand how we can define the table date for CL_due_to_alpha or CD_due_to_alpha or even the wingarea / CoG.

Or differently asked where does ardupilot takes its aerodynamic form? Is this hidden in the parameter files of ArduPlane / quadplane? Or uses ardupilot therefore the standard vehicle “Rascal”?
(When typing in “sim_vehicle.py -j4 -f quadplane -L KSFO”)


(Kevin Schnitzler) #4

hey Quadro
I got exactly the same problem by using my JSBSim Model in ardupilot.

I want to do a SITL Simulation without any Hardware. I got my VTOL Plane and want to simulate it before real flying.
I also want to use my own aerodynamics and can’t find any parameters like CL/CD or geometrics in the Ardupilot Mission Planner parameter list.

It would be really interesting if somebody could solve this problem or got any hints what is going wrong.


(peterbarker) #5

Yes we already tried to setup some parameters in there. But not all, because
we first wanted to test if it is flying at all or not. This morning we
looked again but haven’t understand how we can define the table date for
CL_due_to_alpha or CD_due_to_alpha or even the wingarea / CoG.

When using JSBSim, JSBSim is solely responsible for determining the
aerodynamics. ArduPilot’s only job is to fly the vehicle JSBSim is
representing.

The Parameters I was refering to were ArduPilot’s parameters helping
to define the vehicle’s own concept of its outputs and its responses to
the input that the simulated vehicle is supplying - so definition of which
outputs are on which (virtual) servo outputs, PID settings, that sort of
thing.

Or differently asked where does ardupilot takes its aerodynamic form? Is
this hidden in the parameter files of ArduPlane / quadplane? Or uses
ardupilot therefore the standard vehicle “Rascal”?
(When typing in “sim_vehicle.py -j4 -f quadplane -L KSFO”)

The quadplane model is in-built. The code for this is present in
theArduPilot source tree - when running with this model, the same binary
also pretends to be a plane.

https://github.com/ardupilot/ardupilot/blob/master/libraries/SITL/SIM_QuadPlane.cpp#L97

More than enough use of the word “coefficient” to satisfy most people:
https://github.com/ardupilot/ardupilot/blob/master/libraries/SITL/SIM_Plane.cpp#L145

It’s a VERY simply quadplane model - really just bolting a quad onto a
plane. Improvements are very welcome, of course!

Peter


(Max Alt) #7

Hallo Peter. Thanks again for the quick and extensive answer :slight_smile:

The last two days we tried to fix the parameters you was referring. (sim_vehicle.py -f jsbsim:MyModel) In some cases it “reacts” but don’t moves like it should, but so we now know that they can communicate. (With the same Parameter-setting in “sim_vehicle.py -j4 -f quadplane” it is flying).

As well we tried the other way with SIM_Plane.cpp and SIM_QuadPlane.cpp and changed some aerodynamic-values. AND its flying! Thanks for that.

But ^^
We still want to try it with JSBSim. Do you have one more idea why it could be why it isn’t flying?
Could it be that the ardupilot don’t gets the data where we defined the motors and so on in our “OwnAicrfat-FlightGear-Model”?
So have we to make a file where the outputs are defined, so that ardupilot knows where the motors are?
We also tried the arducopter model with “sim_vehicle.py -f jsbsim:arducopter” it also don’t flies.

Thanks for your patience :slight_smile:


(peterbarker) #8

Could it be that the ardupilot don’t gets the data where we defined the
motors and so on in our “OwnAicrfat-FlightGear-Model”?
So have we to make a file where the outputs are defined, so that ardupilot
knows where the motors are?

ArduPilot knows where the outputs are based on its own parameters. You
can manipulate these within SITL (sim_vehicle.py) using the "param"
command. I suggest you fiddle around within that environment to see if
you can get the parameters set up to fly your vehicle. In particular, you
want to be looking at the SRV* parameters and Q_ENABLE

You might try loading the quadplane parameters:

param load Tools/autotest/default_params/quadplane.parm


(Max Alt) #9

Hi. Thanks again :slight_smile:

We have found out that we maybe made an mistake by defining our engines in our “OwnAicrfat-FlightGear-Model”. So if we just simulate the same model with only one engine, it is flying with JSBSim. As soon as we add a second engine to our model, the vehicle isn`t flying anymore.
(sim_vehicle.py -f jsbsim:OwnModel)

Now we had an team-meeting and our group-master decided, that we first should try the easier way with SIM_Plane.cpp and so on. (sim_vehicle.py -j4 -f quadplane)

But when we will have time we will try the JSBSim- variant with five engines. And we will update this forum if we have success and how.


(peterbarker) #10

Now we had an team-meeting and our group-master decided, that we first
should try the easier way with SIM_Plane.cpp and so on. (sim_vehicle.py -j4
-f quadplane)

That seems entirely reasonable. The flight dynamics won’t be as
representative as JSBSim - but its certainly easier!

But when we will have time we will try the JSBSim- variant with five
engines. And we will update this forum if we have success and how.

If you’re happy to share that work, you could push it up to a repository
somewhere where others can look at it. Havinga quadplane model for JSBSim
would be great!

I should note there’s a third option - RealFlight8 has pretty good support
for ArduPilot now!


(Max Alt) #11

Hello.
Thanks Peter!

We tried a long time to set up a QuadPlane-JSB-Sim Model. Finaly we don’t get it.
Now we use the internal Simulation of Ardupilot and simulate it with “sim_vehicle.py -j4 -f quadplane”. Finaly it flies.

BUT we don’t trust the P-I-D- setup. Because of that we decided to write a Matlab-Program which calculates the PID values. This values we later want to setup in the Parameters for MissionPlanner.

We will keep you upto date, if you want.

Max


(peterbarker) #12

Now we use the internal Simulation of Ardupilot and simulate it with
“sim_vehicle.py -j4 -f quadplane”. Finaly it flies.

BUT we don’t trust the P-I-D- setup. Because of that we decided to write a
Matlab-Program which calculates the PID values. This values we later want
to setup in the Parameters for MissionPlanner.

We have a lot of PIDs :slight_smile: Which ones don’t you trust, and why?

We will keep you upto date, if you want.

Please do.


(wangxiaozuo) #13

Dear Peter:
The plane dynamic model is in-build into arduplane. it can be found in libraries/sitl dir. but I cannot find the moment of inertia matrix of plane in the file Sim-plane.cpp. But the rot_accel can be calculated in case of no inertia data. why? the code as follow:
Vector3f force = getForce(aileron, elevator, rudder);
rot_accel = getTorque(aileron, elevator, rudder, thrust, force); //Here ,torque is getted ,but no multiple by inertia matrix inverse, why? and i cannot seen the inertia matrix variable.

if (have_launcher) {
    /*
      simple simulation of a launcher
     */
    if (launch_triggered) {
        uint64_t now = AP_HAL::millis64();
        if (launch_start_ms == 0) {
            launch_start_ms = now;
        }
        if (now - launch_start_ms < launch_time*1000) {
            force.x += launch_accel;
            force.z += launch_accel/3;
        }
    } else {
        // allow reset of catapult
        launch_start_ms = 0;
    }
}

// simulate engine RPM
rpm1 = thrust * 7000;

// scale thrust to newtons
thrust *= thrust_scale;

accel_body = Vector3f(thrust, 0, 0) + force;
accel_body /= mass;    **_//this is my note , accel_body is divided by mass but,can not seen inertia matrix inverse_**

(peterbarker) #14

Looks like an inadequacy in our modelling…

I’m not sure any of our sims care about rotational inertia…

Other models scale according to the terminal rotation rate, but plane
doesn’t even seem to do that…


(wangxiaozuo) #15

en,I know. thanks I try to correct it in a few days. thks for u


(wangxiaozuo) #16

Dear Peter:
I have try to fixed the problem in sitl simulation plane model. May be progress rapid. Try to make it as arduplane.elf file. But i found the file(35M) which i make is too big than the file download form fullurl = {http://firmware.ardupilot.org/Tools/MissionPlanner/sitl/ArduPlane.elf} (2M) here. Please tell me why? Second, can i rename the arduplane.elf to arduplane.exe directly to instead of the file download?because i try to sitl simulate in MP,but no sucess.


(peterbarker) #17

I suggest using sim_vehicle.py instead of trying to use Mission Planner to
run the simulation.

http://ardupilot.org/dev/docs/sitl-simulator-software-in-the-loop.html


(Max Alt) #18

Hi, we just want you to know that we now dont try any longer to include our own JSBSim-Model to ardupilot.
We now try to write a Simulink model based on our vehicle-dynamics and ardupilot.

If you are interested in it:
https://discuss.ardupilot.org/t/quadrocopter-simulink-model-of-the-ardupilot-code/27969