ArduPilot / SITL_Models

Models of aircraft for SITL
70 stars 111 forks source link

Contributing Weight-Shift Control Aircraft Model #116

Closed NDevDrone closed 5 months ago

NDevDrone commented 5 months ago

Weight-Shift Aircraft

Model for the Romaeris unmanned weight-shift control (uWSC) electric aircraft.

uWSC_motion

Usage

Gazebo and the plugins should be installed as per the ArduPilot Gazebo Plugin instructions.

Update the GZ_SIM_RESOURCE_PATH to include these models:

export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:\
$HOME/SITL_Models/Gazebo/models:\
$HOME/SITL_Models/Gazebo/worlds

Run Gazebo

gz sim -v4 -r wsc_aircraft_runway.sdf

Run ArduPilot SITL

sim_vehicle.py -v ArduPlane --model JSON --add-param-file=$HOME/SITL_Models/Gazebo/config/wsc_aircraft.param --console --map

The provided parameter configuration modifies the default plane parameter set to provide automatic flight control mode for the weight-shift aircraft model, as follows:

SERVO1_FUNCTION = 4
SERVO1_REVERSED = 0
SERVO2_FUNCTION = 19
SERVO2_REVERSED = 0
SERVO4_FUNCTION = 21
SERVO4_REVERSED = 0
SERVO5_FUNCTION = 78
SERVO5_REVERSED = 1
SERVO6_FUNCTION = 77
SERVO6_REVERSED = 1
SERVO10_FUNCTION = 74
SERVO10_TRIM = 1100
SERVO11_FUNCTION = 73
SERVO11_TRIM = 1100
INS_ACCOFFS_X   0.001
INS_ACCOFFS_Y   0.001
INS_ACCOFFS_Z   0.001
INS_ACCSCAL_X   1.001
INS_ACCSCAL_Y   1.001
INS_ACCSCAL_Z   1.001
INS_ACC2OFFS_X   0.001
INS_ACC2OFFS_Y   0.001
INS_ACC2OFFS_Z   0.001
INS_ACC2SCAL_X   1.001
INS_ACC2SCAL_Y   1.001
INS_ACC2SCAL_Z   1.001
INS_GYR_CAL      0
ARSPD_TYPE 0
BATT_MONITOR    4
RUDD_DT_GAIN = 1
LIM_PITCH_MAX = 2700
LIM_PITCH_MIN = -1000
LIM_ROLL_CD 2000
MIS_TOTAL = 413
NAVL1_DAMPING = 0.85
NAVL1_PERIOD = 50
RLL_RATE_P = 0.5
SIM_SAFETY_STATE = 2
WP_RADIUS = 10

uWSC_gasplume

Included camera gimbal demo

The model includes a 3-axis camera gimbal implementation that makes use of the Ardupilot 3-axis gimbal controls. GimbalDemo

Notes

Modelling and comparison to real weight-shift flight

Information on the aircraft model's body dynamics, aerodynamics, and comparison of the model fidelity with real weight-shift flight data can be found in the forthcoming conference paper titled "uWSC Aircraft Simulator: A Gazebo-based model for uncrewed weight-shift control aircraft flight simulation" that may be cited as follows:

@INPROCEEDINGS{uWSCAircraftSimulator2023,
    title = {{uWSC} {Aircraft} {Simulator}: {A} {Gazebo}-based model for uncrewed weight-shift control aircraft flight simulation},
    booktitle = {2023 IEEE Symposium on Robotics and Sensors Environments (ROSE)},
    author = {Nathaniel, Mailhot and Teresa, de Jesus Krings and Gilmar, Tuta Navajas and Boyan, Zhou and Davide, Spinello},
    month = nov,
    year = {2023},
}

Credits

NDevDrone commented 5 months ago

Hello @srmainwaring, here is my attempt at the PR to contribute the weight-shift control aircraft model.

The primary contributions can be found in the models and world folders. I also drafted a doc file that I left at the top level of the repo instead of the doc directory like it probably should be.

If these were to merge, I think you would want to move the doc file to the correct directory and delete the readme file I have for my fork (which is a copy of the doc file).

srmainwaring commented 5 months ago

Hi @NDevDrone - great addition! I'm looking forward to running this. A couple of quick change requests:

NDevDrone commented 5 months ago

Hi @srmainwaring, just did that!

Let me know if there is anything else to get it right.

Cheers.

srmainwaring commented 5 months ago

Let me know if there is anything else to get it right.

I've got the simulation running and it's working well - I really like the model.

I'll go through the model file in detail, but the major question I have is about the model orientation. It seems that the model axis is rotated 90 deg about z (so y is forward rather than x). There are offsets in the IMU sensor pose and ardupilot plugin poses to correct for this, but was there a reason for not aligning the model so that x-forward, y-left, z-up (this is the ROS REP 105 frame orientation convention)?

Unfortunately the zephr model in the ardupilot_gazebo repo is similarly aligned. This was inherited from the original model prior to modification to work with ArduPilot. I should change it as it is not a good example for setting up a ROS compliant vehicle.

If it's a major re-work to change the model to standard orientation we can do it in a follow up, but it would make integration with ROS 2 easier if the REP 105 conventions were applied from the outset (if that's something you have in mind for later).

I needed to set the pitch to an adjusted trim (rc 2 1552 IIRC) in order to arm the model - could you add a note in the model doc to advise on this and additional RC settings needed.

NDevDrone commented 5 months ago

I've got the simulation running and it's working well - I really like the model.

You happen to be our first external collaborator to try it out, so that's a relief! Thank you! As far as I know this is the first weight-shift aircraft of its kind implemented within Gazebo.

rotated 90 deg about z (so y is forward rather than x).

You're correct. This is a leftover quirk from how we started with the zephyr model as the starting reference, otherwise not an intentional choice.

If it's a major re-work to change the model to standard orientation we can do it in a follow up, but it would make integration with ROS 2 easier if the REP 105.

I would like to get the model out there, and fix this issue in a follow-up PR. At this present moment on my team's end, there won't be time to spare for a little while to fix it, I am afraid. It is certainly something we intend to do when we can, as we will be looking to develop using the ArduPilot-ROS2 integration in the future.

All that to be said, I'll fix up the doc to add the note like you had asked for arming rc 2 1552. Was there anything else? Or after that do you belief its ready to be merged?

NDevDrone commented 5 months ago

Hey @srmainwaring , I added two additional tweaks to the doc file to call out the orientation quirk, and the pitch midpoint arm issue you had mentioned.

Let me know if you identify any other problems. Otherwise, I'd be happy to merge this in its present state. When time allows it we'll try to fix the orientation issue with a revised model, but that might take a little bit of work.

srmainwaring commented 5 months ago

@NDevDrone - would you mind squashing the commits into a single commit and force push the update. ArduPilot repos only permit Rebase and merge and squashing keeps master branch cleaner. Also can you make sure to DCO sign the final commit. This is a line containing your name and email at the end of the commit (preceded by an empty line).

Signed-off-by: FirstName LastName <your.email@yourmailserver.com>

Some details from the ArduPilot wiki here:

srmainwaring commented 5 months ago

@NDevDrone - problem with a force push from me to squash your changes. Don't panic all the changes are here:

I've been reminded the hard way why you never use master for PR's...

I'll submit the PR from the squashed copy above - and reference this issue for details. My apologies for the error.

Merged in #117.