Sailboat Support

If it works with a 180 offset than that is probably correct. You can check the reading in the GCS. It will report absolute wind direction but what you want is relative angle to check the wind vane. You can either move the vehicle until its yaw is exactly 0 such that relative and absolute angles are the same, or find MAV_APPWNDDIR in mission planner to get the value directly. It should be 0 when the vehicle is “head to wind”, that is the wind coming from directly in front of the vehicle.

i should have specified that when the wind reads 359, the sail is perpendicular the vessel. When the wind is at 180 the sail is in line with the vessel and will trim properly within a certain range. Its as if the sail is trying to sail backwards (rotated 180 degrees).
Huge fan by the way!

this sounds silly but is it possible that the vehicle being turned away from its waypoint is causing this behavior? Its the only thing i can think of that may have changed.

Ok, so if the windvane is working correctly the next thing to test is if the mainsail servo should be reversed. You can check in manual mode, the wiki gives the convertion.

https://ardupilot.org/rover/docs/sailboat-hardware.html#sail-winch

Note that is is possible to have both the servo and the RC input reversed such that is is correct in manual but incorrect in auto sailing modes.

If that does not fix it then some pictures of the vehicle would help me understand your setup better.

Hi,

I am currently modifying SITL::Sailboat to also simulate roll.

The very rough results can be seen in https://youtu.be/Ga_prM4Zpag?t=60

The question is how to add this to the sailboat sim properly

I can either add it directly to SITL::Sailboat, but, it would be nice to be able to model various types of sailboat and in an extensible way. ( the sim models a monohull with a bulb keel, but I would also like to simulate a multihull)

So what is the best way to go about it, create a new class, subclass, switch statements? , and how should a particular type of sailboat be selected when starting SITL?

Also I currently do have some issues with the 3d modelling. I could use some help with the Maths. Currently as you can see in the video, there is a little bit of pitch as the boat turns, so presumably my rotation sequence needs work. Here is the source.

The SITL::Sailboat heel calcs are at around https://github.com/kwikius/ardupilot/blob/andy_revo_sailboat_sim_mods/libraries/SITL/SIM_Sailboat.cpp#L352

Nice!

For copter we have a json format that can be used to define a vehicle. There is some more detail here:

Its quite a big job, but we could start adding some parameters there. We would have to have a think about the best way to define a vehicle, we don’t want to get too complex.

Happy to use json for parameters.

More than running missions My current goal is to try to get Ardupilot to get my catamaran flying a hull. https://youtu.be/BMNr9LYdxY0?t=160 This happens to be quite difficult to do manually, as can be seen in that video link.
The modelling of a catamaran is quite a lot different than a keelboat though.
Ultimately it would also be nice to make a model of an AC75. https://www.youtube.com/watch?v=8jAagJq_Gm0

2 Likes

Hi @skyscraper - if you’re interested in using Gazebo for simulation I’ve done some work there to support sailing vessels (land yachts and keel boats). It’s a bit more involved to set up, but the hydrodynamics and sail trim control is all implemented. It would not be difficult to create a model for your cat / tri and get it running using the current AP capabilities.

I used the Gazebo SITL model to tune model my land yacht in simulation before applying to the real thing.

Foiling craft would be more work - I believe it could be done, but that would require some further development on the lift - drag calculation to account for the fact that the lifting surface area changes as the hull lifts.

Here’s a clip of the land yacht sim: the heel controller is tuned to keep one wheel flying at around 5 - 10 deg.

1 Like

@rhys That is fantastic! ( Also see you have a gazebo simulation of a boat on realistic water!) The landyacht sim looks very close to what I want to do with my cat. I will certainly see if I can get Gazebo sim running ASAP.

Thanks!

@skyscraper let me know if you need any help. The starting point is to get the ArduPilot Gazebo plugin built and running. The AP Dev Wiki has a section covering that and there are more details in the plugin repo. It should now run Gazebo Garden or Harmonic.

One possibility for a pure SITL model would be to adapt some of the code in the wave / surface vehicle plugin to provide the physics - although it may be a step too far for the SITL library. For accurate buoyancy modelling you need the vehicle mesh so that the changing submerged surface can be updated as the boat heels or moves through waves. The alternative is to use linear potential fluid models and assume small displacements, but for small vessels that heel considerably (and multi-hulls) this quickly gets complex as well.

1 Like

@rhs My first goal is just to get the cat flying a hull in a straight line on a reach in Acro mode . I am guessing the landyacht sim may work well enough for that? Anyway making a simplified mesh of the hull should not be too complicated. The pic shows a simple catamaran hull shape done in pure OpenSCAD. Presumably the mesh doesn’t need to be hydrodynaically smooth for the sim to work?


Anyway that is some way down the road. First I need to try to get Gazebo simulator working with ardupilot.

Thanks again!

We do have the SAIL PID controller, so it should be possible however its hard to tune because you need to be up against the SAIL_HEEL_MAX param before it does anything. I would set the param to the roll you need to just get the hull flying and then work from there. It will never sheet in to raise the hull, but it will sheet out when you get past that point. It will probably be easier to tune if it is a little too windy so the it does not have to be “subtle”.

If your trying to get more “dynamic” sailing then I would recommend increasing SCHED_LOOP_RATE we use 50 Hz by default on rover 400 is the default on copter and should work fine.

1 Like

I can probably do something with that model. Let me take a look to see if I can get the model floating and the sail articulated. Do you have a link to the original - STEP format is ok, or STL if you have it (Gazebo uses Collada, but that can be derived).

@rhys Sounds good to me! stls attached in the zip file. I have split into 3 stls; hull_platform, rig and wind sensor. (for completeness the wind sensor is meant to go on the spar sticking out of the front of the rig fwiw, so that it spends last time masked by the rig in a gybe… to be tested!)
catamarans_stls.zip (58.5 KB)

1 Like

@skyscraper - initial model here: GitHub - srmainwaring/SITL_Models at prs/pr-catarmaran. Set up with hydrodynamics and approximate inertial. Some dimensions are needed to refine the model:

  • mass and dimension of the hulls + platform
  • sail area
  • approx mass of rig and sails

Will also need rudders, if you have a STL file that would be great, otherwise rectlinear dimensions and mass will be enough for an initial approximation.

Do the hulls have a fin? If so, same question re. dimensions as for the rudder.

Question about the wind sensor: does the entire mast rotate (with the forward spar) or is the boom separate? The visual is one element but I suspect the forward spar should be fixed with the mast and the boom hinged at the gooseneck. Will need some editing of the mesh file to do this - I have the model loaded into Blender now, so should be straightforward.

@rhys. it looks great. (I have gazebo-ardupilot basically working so next is to try to do something useful!)

The rig arrangement is as shown in the video https://www.youtube.com/shorts/Jy8-cmgmLhk

(The rig is actually a development of the one in this video https://youtu.be/Us4DRlkozek?t=257 )

The stl dimensions are mm, so for reference a hull should be 830 mm long in x.

I added some foils in the attached zip.
cat_foil_stls.zip (191.4 KB)

The distance from the front of the hull to the leading edge of the foil is 340mm ( red markers in pic)
The distance from the front of the boat to the mast is 400mm (blue markers in pic)

Rudders hang on the back of the boat as shown in the youtube animation.

The following is a guess
Mass of boat should be around 1.4 kg.
C.g should be 450mm aft of front of the hull

We currently only support fixed wind sensors, we would need to add support for a second sensor to get the mast angle so the wind angle relative to the hull/flight-controller forward can be calculated.

Its not a insurmountable problem, but there will be a little dev work required.

For the purposes of the Gazebo model I’m sure you could do that calculation in Gazebo before forwarding the data to AP.

1 Like

@iampete. The advantage of this arrangement is that you get the angle of attack direct, so any error calculating the boom angle from mainsheet servo position is removed.

That is useful for sail trimming but for navigation we need to know where the wind is really coming from. As you say, we can’t really use boom angle interpolated from main sheet, so you need a second sensor of some sort. We do support directly actuated wing sails, in which case you probably could use the interpolated position.

It is something I would like to add support for at some point. Our AP Periph firmware can now to RC, MAVLink as well as servo outs, GPS compass ect over CAN. So you would only need power and CAN up to some smarts on the mast and just keep the main flight controller and batteries down in the hull.

1 Like

@skyscraper draft PR here: Gazebo: add sailing catarmaran model by srmainwaring · Pull Request #113 · ArduPilot/SITL_Models · GitHub

There is an author section in the model.config. Please let me know what details you’d like there for yourself, and any additional notes you’d like added in the model description.

  • The model is fully rigged - all joints, plugins etc are included.
  • The inertia moments need to be corrected - current estimates are too large.
  • The AP params for sailboat provided servo control of rudders and sail, rate controller PIDs are not tuned.
  • The sail and foil lift are not working correctly at the moment.
    • Foils need the CP adjusted (currently at link origin).
    • The sail lift drag and controller plugins are mis-behaving. The sail is is generating lift when back-winded which should not happen. Currently looking into that.
  • Docs need updating. There are plugin dependencies on external wave and sailing repos which need additional explanation.