Still playing with the ardupilot gazebo cat sim.
Before the critique I should say that I love the Gazebo catamaran sim, but feel it needs work to get it working nicely for me anyway
For my old low end system I found that I could get a sim rate of around 95 % of real time eventually. (In the video below I think that the screen recorder takes off another 15% of realtime)
I had to make several changes.
First set the asv_wave_sim/gz-waves-models/world_models/waves/model.sdf file was modified to
<cell_count>4</cell_count>
<wind_speed>0.0</wind_speed>
Second the SITL_Models/Gazebo/worlds/catamaran_waves.sdf file was modified to
<max_step_size>0.005</max_step_size>
<real_time_factor>1</real_time_factor>
This reduces the update rate from 1 ms to 5 ms. I would have liked to try even lower rate
but something went boink in the gazebo startup output, so I left it there.
Next I modified the SITL_Models/Gazebo/config/catamaran.params file to set the default SCHED_LOOP_RATE of 50. The Ardupilot loop rate needs to be less than the sim loop rate AFAIK. Lower loop rate means potentially less power used anyway ( maybe can run it on a stm32L4 etc eventually)
I connected my Taranis RC Transmitter as a joystick and used the mavproxy joystick module.
I found that the sail controller is unusable in MANUAL mode with the default settings in the Gazebo/models/catamaran/model.sdf. The integral term means that Integral windup - Wikipedia is a real problem and makes it unusable. It takes around 30 secs to unwind at startup. I set the values to P:1 I:0 D:0 and that makes it work ok for me. Is there any need for a PID in the Gazebo sim? My feeling is that Ardupilot should control the sail position, not the sim.
For the sim itself. The boat currently travels too fast. I think ideally it would be good to model hull skin friction and wave drag, but in some ways the high speed works well since it highlights problems in control, since Gazebo models the effect of rudder throws well, so that if the model is travelling fast slight movements of the rudder have a large effect. This then throws up issues about how the Ardupilot::Sailboat handles turns for example. The direction controller probably need to take account of boatspeed? for a particular rudder angle, the torque is approx proportional to speed^2 after all.
There is a similar situation with the Heel controller. The apparent wind speed has a dramatic effect so the heel controller probably needs to have apparent wind speed as a parameter?
What is clear so far is that a catamaran is a lot more complicated than a keelboat! Anyway I plan to continue to play around with it and see if I can affect some of the issues. With the sim performance acceptable on my system, I now plan to see what I can do to the ardupilot Sailboat code
to make it work better with the sim catamaran
Here is a video of the current status, bearing in mind it is sensitive to windspeed. https://www.youtube.com/watch?v=lkCzBQWEEaU