Sailboat Support

Thanks Pete, I got your reply in time for sailing last Sunday but never got a chance to sail. However, a long weekend is coming up due to dragon boat holiday, so there will be more chances.
I checked your parameters a bit and noticed your ACRO_TURN_RATE is set to 100 and my is at 40. I will keep mine to begin with but change my WP_PIVOT_RATE to 40, it was way higher before.
For using the motor when calibrating the steering, its really like you say that my motor can pivot around. But, its usually still if only have the motor in little wind, as long as the wing tab is at centre position. Usually when sailing in Acro mode it will never be in centre.

Question: If I put motor switch to Always on, What will happen in Acro mode? I expect I can control rudder but what will happen with the Wing tab? Can I control it manually and set to centre? Motor will be controlled with throttle stick or by the FC?
Cant test it before outsideā€¦

In motoring acro the throttle stick controls target speed, the motor is then controlled by the flight controller to meet the target speed. The trim tab will be set to center.

Clear. Great :smiley:
Will try to tune the steering using the motor then.

Yes,
yesterday was thunderstorms with lots of rain and strong winds but today was ideal for adjusting the steering - no wind at all :slight_smile:

Had a very pleasant experience where the motor and the code really behaived just as I expected.
When putting low throttle in Acro mode the motor just now and then came to work when speed was below the target, else just kept still.
The purpose was to calibrate/tune the PIDs for the steering.
Using mainly Always motor and then try Acro, Auto, RTL, Loiter.

Since I was worried motor would bring on too much thrust so that the freedom of pivot would bring the boat to a capsize, I put the cruise speed as well as the wp speed to 0.5 m/s, thatā€™s about 1 knot.

Checking the asked and achieved steering rate I am not sure its overshoots or undershoots, I think it looks reasonable okay. However, sometimes the curves are far from synchronised.

To experiment, I rather than crank the PID or the FF rates up, I suspected that the speed was too low, so I tried to be brave and crank up both the cruise speed and wp speed up from 0.5 to 0.7 m/s at the last third of the log.
That resulted in a boat speed around 1-1.7 knots and worked better (than before with boat speed just around 1 knots).
I also put the D term from 0 to 0.1 to get the FC some number to chew on. Not really hoping for improvements but giving face to the great developers that spend time to implement the D term, why not use it :slight_smile:

This is the log
https://drive.google.com/file/d/1m-zws9tdk7Z8ryPCgePbPuZfICznxj3X/view?usp=sharing

Would be great if you can share your view on the tuning so far.

Hope to do more sailing this weekend.
From todays experience I do not expect the boat to follow wp or tack successfully if boat speed under 1 knot.

1 Like

No sailing :sweat: This summer has been week in and week out with same weather with only 2 m/s wind. I will be out of town until beginning of September, hope wind better then.

1 Like

Hello,

Pete made a contribution to my Gazebo boat simulator which has prompted me to look into integrating it with the ArduPilot sailboat SITL. Itā€™s still in draft form but it looks like it can be made to work. Hereā€™s a quick preview:

So far Iā€™ve managed to get rudder and sail control and imu sensor integration. Adding the boats wind sensor is going to require a few changes to the ardupilot SITL code and the ardupilot_gazebo plugin - I might need some advice from the experts on how to best approach that.

1 Like

Great work!

I have to admit Iā€™m a compete beginner at Gazebo, the experts hangout over on the Simulation channel of the developer discord, Iā€™m sure they would be happy to help.


I will do what I can on the AP side if you need anything, I will add a SITL windvane back end, we actually need one for another sailing simulator project.

@khancyr knows a bit about gazebo

Iā€™ve put a docker image together with a proof of concept version of the simulator. There is a long list of improvements but it gives you an idea of how the SITL / Gazebo integration works for boats. Unfortunately I had to switch all the waves off otherwise the gyros etc. wonā€™t calibrate, and the dynamic environment control is not readyā€¦

Excuse the chunky docker image: it contains a full ROS distro, Gazebo, ArduPilot and all the associated tooling. Ideally the simulation would be split between a couple of images and containers - but I havenā€™t yet figured out how to get the SITL / Gazebo networking configured correctly.

For the docker-compose file you need to pull the branch not master :

git clone https://github.com/srmainwaring/sail_sim_docker.git -b feature/ardupilot_sailboat_poc

The Gazebo simulation is demanding on memory, CPU and graphics, it really needs a multi-core workstation with a good graphics card to run well.

1 Like

There is a param for that, INS_GYR_CAL = 0

Great work!, I will try it out this eve

Good to know! Iā€™ve tried my local setup with the gyro calibration off and the demo runs with waves on - so Iā€™ll update the docker config to reflect that and put an update out later on. Itā€™s more interesting with a sea state and you can see the AP working harder to keep the boat on course.

@rhys

Wow, really nice simulator. I am working on a water and wind forces energy-efficient path planner that will eventually be used on my boat and this would be an excellent test bed. When I get some time, Iā€™ll test it out my planner. That said, my planner is not currently meant for sailboats, but Iā€™m likely to expand it.

@iampete Iā€™ve set INS_GYR_CAL = 0 in the default params for sailboat for the demo, so I can start the simulation with waves, however when I try to arm the throttle I now see:

APM: PreArm: DCM Roll/Pitch inconsistent by 14 deg

which I didnā€™t see if I start with default params and disable the gyro once the simulation has started.

I did a quick search but couldnā€™t see a ā€˜DCMā€™ param that I could disable. Any suggestions?

There are few things that can cause this, but its safe to ignore in the SITL in most cases. I would suggest setting AHRS_EKF_TYPE to 0, you then just use the position directly from the physics backed rather rather than faking up sensors and trying to re-fuse them. You can then turn off both EKFs with EKF2_ENABLED and EK3_ENABLE = 0. If it still wont arm just turn off that arming check, or force arm with arm throttle force (dont do this on a real vehicle :wink: )

Thanks Peter. In a proper version Iā€™ll add a facility for switching sea state and wind conditions on and off, so this shouldnā€™t be an issue.

I had a little play at getting this to work on WSL without much luck, seems to be something odd with docker and WSL.

Are you away that you can run the ArduPilot bit directly from MissionPlanner on windows? That might allow you to have the physics bit only in docker. Mission Planner can run pre-built STIL that it pulls from the build server based on master. You should be able to pass it the various options just as you would building locally.

https://ardupilot.org/planner/docs/mission-planner-simulation.html

Thanks for testing it out Peter. Iā€™ll have to set up a windows box or VM so I can try and replicate the WLS docker issue you are seeing. Iā€™m also trying to get Mission Planner running on mono on both macOS and linux so I can test your suggestion. Will MP be able to pull in a patched version of SITL? There are a couple of changes to support a gazebo-sailboat frame in the source code which are in the docker image. Iā€™ve not submitted a PR for them as itā€™s early days yet and I need to integrate wind sensor data from Gazebo to the SITL_Gazebo class first.

Iā€™ve also tried running SITL directly (i.e. not through sim_vehicle.py) with QGroundControl - this sort of works, but for some reason SITL is only getting half the default parameter set (it loads rover.parm but seems to ignore the sailboat.parm overlay), as a result rc 3 rather than rc 4 is being published. If I can get that working then I can provide separate docker images for Gazebo and the patched ArduPilot stack which may help.

Ah, no, it pulls directly from master, I didnā€™t realize you also had AP changes. Once they have got in it should make it a little easier for those using windows. No idea if it will work via mono tho.

You can connect QGC to SITL along with MAVProxy, just use port 5763, handy for doing RC inputs in mavproxy and also getting MP or QGC gui.

Unfortunately Mission Planner on mono is no-go for macOS Catalina - Apple have pulled all 32 bit support and MP uses some WinForms which are not 64 bit compatible.

I think my problem is with the arguments I pass when calling SITL directly:

./build/sitl/bin/ardurover
ā€“synthetic-clock
ā€“model gazebo-sailboat
ā€“home ā€œ51.5734550122,-3.99302875275,0.0,1.0ā€
ā€“speedup 1
ā€“defaults ā€œ./Tools/autotest/default_params/rover.parm, ./Tools/autotest/default_params/sailboat.parmā€
ā€“base-port 5670
ā€“sim-address 127.0.0.1
ā€“sim-port-in 9002
ā€“sim-port-out 9003
ā€“instance 0

I can connect from MAVProxy or QGC, but it appears that the sailboat specific parameters are ignored?

using -f sailboat should also load the correct defaults