Sailboat Support

Hi @rhys, could you please point me to the place in your simulator repos code responsible for communication with SITL. I guess you’re not using standard Ardupilot gazebo plugin, are you? Thanks,

Hi @soldierofhell. It’s in this fork https://github.com/srmainwaring/ardupilot_gazebo/tree/feature/gazebo_sailboat_poc of the ardupilot_gazebo project. The main change is to the file ArduPilotPlugin.cc where I’ve added a controller for the sail trim.

There are also a couple of changes to the ardupilot SITL / Gazebo code here: https://github.com/srmainwaring/ardupilot/tree/feature/gazebo_sailboat_poc, mainly to do with setting the wind speed.

I need to revisit this: add support for anemometers then submit a PR, but have been side tracked on the getting up to speed on practical side of things for the last month or two. If there’s anything I can help with let me know.

Thank you, I didn’t noticed this repo

The docker file:

https://github.com/srmainwaring/sail_sim_docker/blob/feature/ardupilot_sailboat_poc/Dockerfile

lists all the repos and branches used in the example simulation if you’d like to replicate in a local build.

This is certainly something I would like to look into. We could sail to apparent wind angle rather than true wind as we do currently, or just change heading at some rate proportional to the heel controller.

The current code sails to true wind angle when going up wind and tacking. Other points of sail are done using the standard L1 controller, this means it trys to keep on line between two points. A first step in this direction is probability just to use heading control the whole time. This frees us to mess with the heading more. With the L1 control it will quite aggressively try and get back on the line so you would end up fighting against it the whole time.

A switch that changes the acro control from being ‘constant heading’ as it is now to ‘constant true wind angle’ or ‘constant apparent wind angle’ might be a nice first step to get a feel for how it would work.

2 Likes

Short update. Had a chance to try the new smaller control wing for the little D wing sail.
Wind was over 5 and mostly just under 6 m/s. It works fine, steering is neutral now.
The OSD with apparent wind really helps to sail it. It’s much more gusty than it appears from shore. Just trying to learn to sail it in manual mode.
I had magnetometer issues and need to check all settings and recalibrate before next try.

2 Likes

Here’s a short clip of the land yacht on sand. Unfortunately I had issues with the ground control station which meant I couldn’t get the steering tuned in the field today so no good performance in acro mode, but that will come.

Mean wind speed approx 3 m/s gusting to 9 m/s.

2 Likes

@iampete I’m trying to set up the motor sailing config on the Rover latest from 18 October but am not getting the results I’d expect. Some pointers would be much appreciated.

Here are the results of a parameter comparison between the standard set up and changes for motor-sailing:

Command Value New Value Comment
RC10_OPTION 41 74 Assigned to 3 pos switch for motor (S4, S5 on mz-12)
RC6_DZ 0 30 Assigned to control (DV on mz-12)
RC6_OPTION 0 207 As above
RC7_OPTION 0 31 Assigned to 2 pos switch for E-stop (S1 on mz-12)
SERVO3_FUNCTION 0 70
SERVO3_MAX 1900 2000
SERVO3_MIN 1100 1000
SERVO3_TRIM 1500 1000

The mainsail is assigned to servo 4.

Hold / Disarmed / Motor-sail=Low

  • main sheet fully out
  • steering disabled

Manual / Disarmed / Motor-sail=Low

  • main sheet fully in
  • steering enabled
  • no response to throttle
  • no response to DV control (assigned to main sail (207))

Manual / Armed / Motor-sail=Low

  • main sheet fully in
  • steering enabled
  • motor responds to throttle
  • no response to DV control (sail fully sheeted)

I can see the response to toggling the sailboat motoring 3pos switch in the MP messages tab (i.e. SailboatMotor LOW). I’m not sure why the motor is active in sail only mode and why I’m not getting any sailing control on the aux control?

Just had a practice in SITL ./Tools/autotest/sim_vehicle.py -v Rover -f sailboat-motor if you want to try it, the motor enable/disable is set to RC7.

I think the issue is simply that it doesn’t do anything in manual, manual mode is all manual. It works to select the form of propulsion in speed control modes, ie acro and above.

The hack for manual so you can still control everything with one stick is to use e-stop to disable the motor when you want to sail. Or you can setup option 207 as you have and have them on different channels. When in auto throttle modes it is all done one the throttle stick as set with RC_MAP (channel 3 unless you have changed it).

1 Like

Thanks Peter, I think I’ve got my head round how the sailboat motor mode operates now. It didn’t help that I’d not set up the min, max and trim settings for the aux RC channel assigned to 207 sensibly - which is why I wasn’t seeing any response there.

If I understand correctly setting RCX_OPTION 207 will override whatever you have in the servo output mapping. If I don’t set an aux channel, then the throttle simultaneously controls both the throttle and main sail in manual (which is what I see).

The sailboat motor 3pos switch is behaving correctly as far as I can tell in acro, the motor comes on in the HIGH position, goes off in LOW as expected. The other mode can’t really be tested inside. I assume the motor should be tuned using the method for Rovers (setting cruise speed etc)? The motor I’m running is a bit underpowered - ok for tarmac but no good for sand, so that will have to wait until a more powerful unit arrives.

Outside of tuning the steering, what I was hoping to use the motor for is recovery if the vehicle gets stuck in sand. I’d be happy to put the motor power on the aux channel instead of the throttle but can’t see any guidance on doing that. I did read something advising not to mess about with the primary RC channel mappings and assume that is for good reason!

On the hardware side I’m in the process of fitting some 200mm PU scooter wheels for the beach / hard. They may be a bit on the heavy side, but if they work should make the land yacht good for both terrains.

Correct

Yes, if its working reasonably well and its just a get you out of trouble motor there is no need to spend ages tuning, better to spend time on the steering.

This currently not possible, basically because on all other rovers the throttle that controls the motor is then used to control the desired speed in auto throttle modes and must be zero for arming ect. Basically if we move the throttle control away from ‘throttle’ stick we break some of rovers assumptions about safety.

You could probability work around with a fancy mixer in the transmitter, but that is a bit of a pita, sorry.

1 Like

Peter, I’m not sure if this is an issue with hardware or with the AP software from the sailboat branch, but on a couple of occasions now I’ve had the FCU lock and not respond to any external communication (no RC, USB or telemetry radio). The FCU runs through its boot sequence and gives the start tone, then spins. It happens after rebooting when the initial connection to Mission Planner glitches / locks. Once it locks there is no recovery (rebooting does not help). The only solution I’ve found that works is erasing the FCU memory with STM32CubeProgrammer and re-flashing.

Have you any experience of this happening and any advice on how to diagnose?

That sounds bad. Make sure your boot loader is up to date. You should be able to still upload firmware in the normal way. The watchdog timer should be rebooting you and giving a ‘wdog’ messages in the messages tab and the log. This gives more info such as the line number the lockup happened on. This lower level stuff is a little outside my expertise, the dev team are always keen to get to the bottom of such issues tho, as ever discord is the place to ask.

Yes - it’s very strange. There is no log on the SD card for the session that failed or subsequent to that until the FCU was reprogrammed, so I can’t see what was going on internally. The audio tone suggests the FCU progresses through the boot stage but the lack of logging suggests otherwise.

I’ve found the STM32CubeProgrammer quite good for completely erasing the flash memory and uploading firmware so I’ll stick with that, but check the boot loader is current as you suggest, and check the watchdog is enabled in future.

I’ve been struggling to get my land yacht’s steering controller tuned properly so I thought I’d set up a simulation to try and get some insight into where things are going wrong. Here’s a demo of the model in Gazebo with the simulation running in auto mode. It’s running with the default SITL sailboat params with the wind at 6 m/s and SAIL_HEEL_MAX=20 as a limit test. Peter’s heel controller is working well but the centripetal force of a sharp turn around a way point is too much so we have a capsize at the end.

2 Likes

Nice! Great work!

I’m a little surprised to see the sail ‘wagging’ so much. Hard to tell the cause, there are wind speed and direction filters you could lower the frequency of.

For a land yacht who’s expected angle of lean is basically 0 you might have better luck with a lower SAIL_HEEL_MAX and less aggressive PIDs, I think it should be possible to get it to cruise along on two wheels.

For my mini-40 I also turned up the loop rate to 400hz, that is what is used on copter. (SCHED_LOOP_RATE) By default Rover is 50. There probably won’t be any huge in increase in performance but it should make the PIDs easier to tune.

1 Like

Thanks for the suggestions Peter.

I think the sail wagging may be caused by the PID controllers used in the Gazebo plugin, not AP settings. Gazebo joints are force or position controlled and you have to tune the PIDs for them so they behave like servos - AP then sets the servo PWM values. It’s either that or I have the centre of pressure for the sail in the wrong place which is introducing instabilities. I still have to add the anemometer to the simulation so SITL gets the apparent wind - that could also explain some of the behaviour. In short there’s still some work to do there!

It’s a much lighter simulation than the ocean one, so quicker to iterate through and test. I plan to keep adding the sailing simulation functionality to it then port it across to the water vehicle version.

What is good is that I can see some of the recovery behaviour working in the AP when the vehicle oversteers round a waypoint and gets into irons (because of tuning issues on my part I might add) - it rolls back, counter steers, and heads off - not sure if that’s all planned but its working!.

really nice! We should get this documented in the wiki. Looks like fun!

Perfect conditions for testing today - wind 4 - 5 m/s gusting 8 - 9 m/s.

  • Main sail sheeting in Acro mode is working well.
  • Ran a short Auto mission where the main track looks good in the logs, but I cut it short because I was concerned the steering was not responding well and the far WP was set a little to close to a pool for comfort.
  • I am not having much success getting the steering controller to respond well. From the video you can see in manual the vehicle can turn quite sharply even under full power - so it’s not a mechanical issue with the steering geometry or servo sizing.
  • The gains are turned right up on the ATC_STR_RAT_* params:
    • ATC_STR_RAT_FF = 10.0
    • ATC_STR_RAT_P = 2.0
    • ATC_STR_RAT_I = 0.5
  • I am wondering whether it is something else? One non-standard setting is the ground steering servo outputs are set with wide limits:
    • SERVO1_MIN = 800
    • SERVO1_MAX = 2200
      to get the full range of motion of the front wheel.

In SITL I noticed that the simulation constrains the steering servo output for Rover to [1000, 2000]. If this constraint was also applied to the servo output for a physical rover in Acro / Auto that might explain why I am not seeing a more aggressive response?

Appreciate any thoughts.

1 Like

First thing I notice is the target is a much larger magnitude the turn actual ever manages. Here i’m plotting GyrZ so you can also see the max rate in manual.

Setting ACRO_TURN_RATE to about half its current value should help, this would be about 50. Once the tune is working you can always look at increasing it again.

Currently the tune is hugely feed forward based. You can see where the feed forward ‘runs out’.

The actual changes with the feed forward but the high of the peeks is about 1/2 of the height it needs to be. The would probably leave you with a feed forward term of about 25. That is much higher than we would typically see, I guess that is just a factor of the steering setup. The steering is along way ahead of the vehicle and I guess with a relatively small range of motion and high castor angle.

Once the feed forward is in the ball park, some P and D should help smooth it all out, again you will need big values.

You can see the servo is often hitting the limits of travel in all modes.

1 Like