Sailboat Support

Have you got an oscilloscope etc for debugging? Life will be hard if not!

I do have one. I was looking for the best way to drive the transducers without having to make custom hardware, apparently you can just use some TTL to RS232 adapters to drive the transducers directly from a pin.

Ultrasonic driver circuit is a good question. I would make a high voltage supply ( say 20V to start). Then use an RLC circuit. One end of Transducer, R, L to gnd. Other end of R to other of transducer, then to C . Other end of C to non gnd end of L. Then a high side switch from 20v supply to non gnd end of inductor. Then just switch on once for t <= 1/2 * f and put back to high z, which should be enough to get the transducer ringing. … Or something like that !

1 Like

my plan is to try and replicate your setup with the parking sensors for my solar rover, It’s big enough that it carry it as is, and I should be able to get it working without soo much issue using your code. i have a few other projects I’m working on with the sonars, so once i somewhere with them IL come back around to this.

1 Like

The schematics for the various versions, the unmodified one and the modified one. The schematic also shows the existing driver circuit

1 Like

I was just looking for 200khz wind sensors online, they have came right down in price since the last time I looked a couple of years ago, ali express have them for £68! they were about £300+ last time I looked. I think it would cost more to make a 200khz version that to just buy one.
https://www.aliexpress.com/item/1005007454724848.html

HaHa. Yes. Probably in terms of development time, but it would be more fun to try to make one. :slight_smile: Those types I think may work on resonance, measuring change in frequency input to get resonance , rather than pulse timing, And they can be very small. It would be interesting to look at update rate of those. They seem to update at a few Hz, whereas pulse timing is faster ( proportional to transducer frequency), but I could be wrong about that. I haven’t really investigated exactly how they work

Anyway here are some raw waterproof high frequency ultrasonic transducers
https://www.aliexpress.com/item/4000389134890.html

1 Like

Hi everyone,

I had my sailboat out today and it’s working pretty well. I have had trouble in the past with it not being able to turn downwind when it’s windy and was working on that today. The rudder goes hard over but the boat will not turn until the sail is eased, like many full scale sailboats.

I will spend some time on the sail trim servo settings to make sure that it is not oversheeting on a reach. I’m also considering a larger rudder. I am able to switch to manual mode and bear away by dumping the sail and turning when the boat is flat.

I tried a variety of heel PID numbers: changing the threshold to 20 degrees from 30 made a big change, and I increased the P gain too. After these changes it was able to turn downwind at the upwind waypoint every time, although the wind had also gotten lighter so I want to test more. The other thing that happens with these settings is the sail servo pumps very aggressively in waves as the boat tips, working the servo pretty hard. It’s a beefy servo so I’m leaving it that way for now. I see a sail slew rate parameter and tried some settings, can anyone tell me what the units are or the equation it uses? I’m also unsure how the feedforward gain is used, would that help?

What I would really like is to be able to aggressively ease the sail when the boat is heeled AND it is trying to bear away. Something like target heel is 30 degrees - K*(rudder percent). I don’t mind a lot of heel upwind but need to be able to help the rudder reaching and running.

Let me know if you have any ideas! Thanks.

Bin file link

GCS image shows rudder (ch3out) at max while sail (ch4out) pretty in (900 is all the way out) at 20 degrees heel. Wind was from the left on the map, boat is trying to turn right (downwind) at waypoint 2

2 Likes

It was a nice day on the river: @n3m0_the_robot_boat on Instagram: "N4N1 the autonomous sailboat instagram takeover. Nice day at Sherman island, tuning parameters and testing, still a little trouble bearing away in breeze but better! Look for the otter in the last clip! 🦦 @meholden"

1 Like

This is certainty a area that could be improved.

The slew rate limit param limits the value of P+D portion. There is a small section on the wiki for this, Limit Cycle Detection — Rover documentation. I would not expect it to do much in this case.

Feedforward won’t do anything in this case because there is a constant target from the parameter value.

You could try adding some filtering with ATC_SAIL_FLTE, a low value will slow everything down. Maybe start at 5Hz and go lower.

Thanks for the info!

I took a crack at it. I hadn’t compiled anything in a couple of years and it was a pain to get my development environment going again! But anyway.

I have a branch on my fork here: ardupilot/Rover/sailboat.cpp at Bear_Away_Ease · meholden/ardupilot · GitHub

I bench tested it and it seems correct, I hope to test it on the water soon. The gain is hard-coded at the top. It lowers the heel PID setpoint if the rudder is past 50% and turning in the bear-away direction based on the rudder sign and the apparent wind sign.

heel_setpoint = heel_setpoint - K*(abs(rudder)-0.5)*2

The factor of 2 is so the setpoint is reduced by K degrees when the rudder is 100%

My boat requires one other hack which is in a separate branch, and a third branch combines them together, if I did the git stuff correctly.

Let me know if you have any suggestions, I will follow up here once I have tested it in enough breeze.

2 Likes

Looks good, I have left some comments.

Thanks for the coments! I am in San Diego for a few days dropping my son at SDSU after Thanksgiving break, managed to fit the boat in the car and did some testing at the mission bay model yacht pond yesterday.

The boat sailed windward-leeward courses for 1.5 hours without needing any help, it was windy but not extreme. The ease-on-bear-away code seems to work and help with the steering. I should have set up some beam-reach to downwind legs to test it, but am hopeful this will be a good code for my boat. I will revise to add the hard-code numbers as parameters once I’m home (I have one new gain and also my boat works better with 2 other hardcoded parameters set differently so I’ll try to make them all parameters in my fork.)

Here is a link to the bin file.

Clip inserted below if I got this right…

I did update the code with Pete’s suggestions, and to create parameters I need for my sailboat.

There is one new parameter for the ease on bear-away gain.

I also made two tacking #defines from the code into parameters because my boat works better with different numbers. My vane is mounted on the back of the boat and the yaw-rate-induced errors in a tack need to be ignored for a while, so I set the timeout to 8 seconds and skip the tacking_accuracy test altogether by setting it to a negative number.

I have only bench-tested it at this point, won’t be able to go sailing for a week or two. I don’t know if this is of general interest enough for a pull request, but after I test it on the water and clean up some commented code I could submit it if you think so. Either way I am happy to have an up-to-date-hacked version for my boat!

This link should get you to the relevant bits:

I have seen similar issues with a vane at the top of the mast and the boat rocking back and fourth in waves. I have wondered about adding position parameters, like we have for GPS and IMU. We could then use the rotation rates of the vehicle to correct the measurements.

Great work on the bear away gain. I think we could look to merge that, we would just need to pick it out of your branch, you could open a PR or I can take a look over the holidays.

1 Like

Hi, I am new to Ardupilot and making progress. My sailboat has a Matek H743 Slim V3 running ArduRover 4.5.7 with GPS/Compass connected and working. Also an AS5600-based windvane working and displaying in analog video OSD. My primary purpose is to have real-time windvane, boat speed and view of tell tales to better sail the boat manually (I’m starting to explore auto features too). I have several questions relating to the throttle/mainsheet functioning:

  1. I have the throttle reversed, i.e. stick up sheets the sails in, I just prefer it that way. However, if I power on the boat with the throttle stick wholly or partially down, and the sheets are not already fully in when I do so, the servo swings to the sheets full-in position and then back to the set throttle position. This can result in sudden strong movements of the sails and I would like to avoid this. Can I prevent this behavior by adjusting AP parameters? It seems a bit inconsistent but usually occurs - is perhaps prevented or less common when I have the boat connected to MP on the bench.

  2. Perhaps relevant is that ARMING_REQUIRE = 1 and ARMING_CHECK = 0. The reason for this is that my understanding is that home for RTL purposes (and home data in OSD) is set when the boat is armed. So what I want to do is turn on the boat and test servo function ashore, perhaps before GPS signal is acquired, then put it in the water and ARM to set the home position (arming is on a switch and ARMING_RUDDER = 0). Is there any other way to set the home position than by arming?

  3. Also, can I get an arming indicator in the analog OSD? It seems this is probably only available with MSP.

  4. I’d like to have an OSD indicator of main sheet position. I have set OSD1_THROTTLE_EN = 1, but it just reads 0% regardless of throttle stick position.

Thanks for any help!

I don’t know much about OSD stuff. But we I’ll start there.

  • arming indicator - as you say seems to be MSP only.
  • Throttle - This reads from throttle motor output not the pilots throttle input. Its behaving as I would have expected. There is no way to display sheet position.

The GCS is the only way to set home apart from arming. (you could bind it to a RC switch using a custom lua script)

The throttle reversal thing depends on how you have reversed it. I would have expected it to sheet all the way out if the RC input is not detected. Then go to the throttle position when RC input is detected. If its not doing that then you might need to reverse both the throttle input and the mainsail output.

ARMING_CHECK 0 is really not recommended, especially if you want to try some of the more autonomous functions.

Thanks so much for your help!

Concerning “bind… to a RC switch… lua script”, I have bound the arm function to a switch using RC7_OPTION = 153. Is that OK too? MP reflects the arm/disarm successfully happening, although I can only test that at home, in the field I do not have a GCS connected. Also, the main sheet works whether it is armed or disarmed, I’m assuming that is by design (I assume throttle would not behave the same way).

Concerning the throttle reversal: When I posted my question, I had throttle not reversed in my Tx setup (TX16S/EdgeTX), and SERVO3_REVERSED = 1 and RC3_REVERSED = 0. If I just reverse the settings of SERVO3 and RC3 (i.e. to 0 and 1, respectively), on start up the sheet went to fully in and got stuck there (did not respond to throttle stick), although the rudder worked. However everything worked the way you described it should if I reversed throttle on the Tx and set both SERVO3_REVERSED = 0 and RC3_REVERSED = 0. I’m glad it works now but I’m curious why messing with RC3 had that effect. Actually, even with my original settings, sometimes the sheet went fully in and got stuck, I think this was happening when the GCS was still connected when I turned on the power on the boat (USB would have been powering the Rx already, turning on the power would just turn on the servos). Just for my understanding, I’d like to know if there is an explanation for all this, but in any event, all good now so thanks again!

Also, understood re ARMING_CHECK and the other issues. Cheers, Chris

Yes ARM via RC switch is fine too. Yes main sheet should work when disarmed for testing, we assume its not going to cut your fingers off like a propeller might.

OK, I have arming and RTL set up and finally had a chance to test it yesterday. RTL works great in general, with all settings at default. However when returning upwind in moderate wind the boat repeatedly failed to tack. When first in RTL mode it is on port tack at 1.5-2.0 km/h and tacks successfully onto starboard. However it repeatedly then tries to tack back to port but never waits long enough to let the boat speed get above 1.3 km/h and never quite gets through the wind, so it falls back to starboard and then repeats this; either it is attempting to tack at a speed that is too low or perhaps with too little rudder to kick it around. The jib is well trimmed (I can see telltales with the camera), and I think it’s either not waiting long enough to tack, sailing too close to the wind, or is letting out the jib before trying to tack because the max heel angle is too low. I wondered if you had general advice how to tune to resolve this. I am thinking I could:

  1. increase SAIL_ANGLE_IDEAL so that it sails a bit further off the wind
  2. increase SAIL_HEEL_MAX so that it doesn’t slack off the jib as it heels over
  3. increase SAIL_NO_GO_ANGLE so that it is not sailing too close to the wind
    but I’m not sure which of these is most likely to resolve the problem.

Thanks for any advice! I can share the video if it would help.