Sailboat Support

Ah, I forgot to mention, regarding when to automatically tack, I was originally thinking we could use the WP_OVERSHOOT parameter… which is used in regular Rover/Boats to decide when it should slowdown because it’s getting too far from the line between waypoints. The default for that parameter is far too small for sailboats (2m) but we could increase the default (or ask users to set it to a higher value for now).

Good idea to allow triggering the tack from an auxiliary switch.

Very nice video. That is great to see.

Thanks for all this work!! A filter on the wind vane is a good idea. I plan to have mine on the masthead and, at 6 feet above the water ,the apparent will move around a lot when going up and down waves. Cross track parameters for both max and min is probably a good idea. As the boat gets closer to the windward waypoint you don’t want it tacking to much if it is a sluggish tacking boat like mine.

I started the process of converting my EC12 today. Mostly brain storming how I want to set up the components. I decided I will mount two pieces of aircraft plywood in the hull that can be easily removed. One will be for power management. It will have a few buss bars on it. Easy access for 10 - 12.6 volt from the 3s LiPo, a Castle 20 Amp BEC set to 6 or 6.5 volts for the RMD sail winch and rudder servo, and a 10 Amp BEC set at 5 volts for the later addition of a RFD 900 unit and the ability to power a Gopro off the ships power. The other plywood piece will have the Pixhawk, GPS, basic 100mw telemetry module, and receiver on it. I plan on ordering the wind speed indicator and windvane pot that Randy ordered in the morning. My initial set up will have the wind equipment on the masthead so I will cross that fabrication bridge when the stuff arrives. Hopefully in about two weeks I’m ready to go.

Have I forgotten anything?

1 Like

@David_Boulanger Great! I think that is everything, you don’t need the wind vane if the rest of its ready to go, It should do a reasonable job with constant true wind direction so long its not too shifty. I guess we could calculate the effect of pitch and roll rate in waves on the windvane if we have its height as a parameter, might be some tricky maths tho.

More testing today but no vid. I have added the cross track error parameter and tested it, it works well to tack up my testing river. I have fixed and tested acro tacking, this allows tacking on the aux switch in acro mode, the boat just matches the current angle to the true wind on the new tack.

I thought I had reduced the maximum allowed rate when sailing in a straight line in auto but it seems to not work, will have to have another look at it.

I have added but not yet tested reducing the rudder output scaling when going slowly, I found it will get stuck head to wind because it will just use full rudder to tack even if its going very slowly. Maybe this would be better controled by reducing the target turn rate?

I have been thinking about the best way to filter the wind vane outputs, I think a fast-ish moving average over a second or so, I can’t decide if we should do a slower filter of true wind angle to use just for tacking, but then we would loose out on how quickly it follows the shifts currently, I think the reduced straight line rate, if i can get it working and a faster filter would be better. And if we can detect a stuck vane we could use a faster filter, I was thinking maybe if the apparent wind angle hasn’t changed by some small amount just don’t up date the true wind angle, and use the last one. But then we might lose information where apparent wind is the same because a change in true wind angle or speed had been masked by a change in boat heading or speed. Maybe with the addition of the wind speed sensor we could weight the vane results with wind speed, ie strong wind - vane is defiantly right, light wind - vane is probably close, no wind - vane is useless. Duno i keep changing my mind, any ideas?

Any thoughts on the best way to do loiter mode? I guess we should just define a circle and sail within it. There a couple if ways we could do it, we could go into a hold style head to wind and keep reseting to the upwind side, i think this might result in getting stuck head to wind from some boats, maybe hold mode should not be dead into the wind but more of a tacking angle but the the sails still loose, I think I will add a parameter for this. We could just sail back and forth on a reach at 90deg to the wind, we could sail back and forth upwind and down wind, or we could do a plane style loiter and sail as close as we can to the perimeter of the circle.

Once loiter is done all useful modes should be supported. I don’t think guided should do any automatic heading stuff, I don’t see much point in steering mode for a sailboat and smartRTL would be abit pointless as it wouldn’t necessarily avoid anything if it has to tack up to the next RTL waypoint, duno we could impose the cross track error on it I suppose but I cant see it working that well.

I suspect I keep having issues that would be far less important in a bit of a stronger and steadier wind, there has not been much here recently, If it was windy I would be doing the heel control code.

2 Likes

I would think one of the most important things in Loiter is to keep the boat moving enough so it does not get locked in irons. Beam reach idea would keep the boat controllable. Big problem with sail boats is that in order to tack you need to have some boat speed/momentum.

How is the potentiometer wired to the controller? Wind speed sensor also. I ordered the stuff last night and looks like it will arrive early next week. I better pick up the pace a little.

I think the I will implement the reaching back and forth for loiter, we can always add other methods in the future. I quite like the idea of the plane style circling loiter so I might do that too.

The pot is just connected to a analog input pin, on my pixhawk i have used the 6.6v input so I can connect the power for the pot straight to 5v, you can use the 3.3v pins but you will need to add some resistors so you can’t get more then 3.3v on the output. Buy default the pin is defined to be the one usually used for the airspeed sensor. So you have one of the outer pins to 5v (for the 6.6v analog in) or <3.3 (for the 3.3v analog pin), the other outer pin is connected to ground. The central pin then goes to the analog input. Currently the code assumes the voltage increases as the vane moves clockwise so you may find you have to swap the two outer pins to get it to read correctly. The wind speed sensor has not been programmed yet.

2 Likes

Raining here today, so I have done some more work on the code. In the end the loiter code as it is looks like it will work fine for sailboats, it just needs a larger loiter radius, I have added a parameter for this.The code as it is should result in the boat ‘bouncing’ of the edge of the loiter circle and setting is heading to pass through the center and continuing until it hits the other side. I have added a hold mode angle parameter so you can define what angle to try and hold to the wind, this should prevent getting stuck head to wind. I have also enables aux switch and full rudder input hold mode tracking.

I have added a low pass filter to the windvane and put updating the vane in a 50hz loop. Also implemented the heel control PID values. However somewhere in the last lot i think, I have broken the code again, it will compile but not run, hopefully i can get it sorted tomorrow and go and try it out.

http://ardupilot.org/rover/docs/common-pixhawk-overview.html#adc-6-6v.

O.K… I’m not real good at this stuff. You are powering, grounding, and sending analog from the pot all from the ADC 6.6 connection on the Pixhawk?

One more silly question. Does the pot need to be calibrated? How does the code know initially what the analog input should be with the vane directly into the wind? I’m getting a bit ahead of myself being that I don’t have the code yet. Everything should be installed, minus the pot, and ready by the end of Sunday. Pot should be here early next week.

yeah that will work fine, middle pot pin to the ADC.

Yes, we haven’t got a calibration process yet, So its all manual. There are three praamiters, WNDVN_ANA_V_MIN, WNDVN_ANA_V_MAX and WNDVN_ANA_V_HEAD. For the first set up set the min and max volateges to the values you have connected them to. So min = 0, and max = 5. Then you need to check that wind direction changes in the correct direction, clockwise should result in a increasing number, if it does not you need to swap the outer pins on the pot. (you can display the wind directions in the mission planner quick tab) Then you can take a look at the max and minimum voltages. The minimum will probity be fine you may find the maximum needs changeing, if the vane saturates at 360 you should increase the max voltage if it never gets to 360 and jumps back to 0 you need to decrease the max voltage. Once thats set up you need to set the WNDVN_ANA_V_HEAD value, this is the voltage when the vane is set to a head to wind position. You should set the vane to head to wind and alter the paramiter until the wind direction equals the yaw angle.

Hopefully we can get a calibration set up for this at some point. Thinking about it the last parameter could be an angle not a voltage then it would be easier to set up.

I will upload a firmware for you today or tomorrow as i’m away at the weekend, its a pixhawk1 right?

Thanks for the explanation. I’m using a Pixhawk 1

If you can make the code available or tell me where to find that would be great. I’m ready for bench testing and giving the parameters a look over. I have not pulled out the mast or sails yet just looking to test the hardware and do calibrations. This is awesome!

ardurover.apj (746.0 KB)

That is the latest version, just been out and tested it today, all seems to work except loiter, and you have to reboot to change the windvane filter value. The code is on the github, i’m about to change to a new pull request since randy has helped me out with some stuff. That should get you started, I will upload new versions as stuff gets changed, and I will put my latest parameters up.

I think the new parameters should be fairly self explanatory, the windvane params are under WNDVN_… and the sailing one are SAIL_…

The mainsheet is servo output function 89, and tacking is aux switch function 59

Thank you so much. Just loaded on my Pixhawk. However the only WNDVN parameter I see is WNDVN_TYPE. I see the sail parameters.

you have to set it to a type before the rest will show up, 0 is wind vane disabled

// @Values: 0:None,1:Heading when armed,2:RC input offset heading when armed,3:Analog

O.K… Thanks again for everything.

Absolutely my last question. How does the code know this is a sailboat? Have a great weekend.

edit here. If wind vane type is set to 1 and the boat is into the wind upon arming can I run an auto mission? trying to understand what WNDVN_TYPE all means.

no worries, feel free to ask away, I will try and keep up-to date on the forum over the weekend, i’m excited to see how it works for another boat.

It knows is a sailboat because one of the servo outputs is defined as the main sheet (function 89).

Yep it will run a auto mission just if the wind changes too much it will get stuck. I would recommend setting it as type 2, PWM you can then define a RC channel with WNDVN_RC_IN_NO and use a knob on your transmitter to offset the armed wind direction by ±45 deg.

Hopefully I can get the last few things sorted out early next week and start tidying it up for a merge and do some proper documentation on the wiki.

1 Like

I have found a bug in the firmware you have, the SAIL_NO_GO_ANGLE that defines what angle to tack at upwind and SAIL_HOLD_ANGLE that defines what angle to try and hold with the sail out in hold mode are swapped. I suggest you just set them both to the tacking angle.

Alternatively this new firmware doesn’t have that bug but may have some new ones.

ardurover.apj (746.2 KB)

2 Likes

Thank you . Should have the boat ready for sail testing Monday morning.