Boat Loiter unstable

Hi,

I have a boat (4.2.0) that works great in auto and guided mode, but is very oscillatory in loiter mode. It does not have much speed but the skid-steer is near max throttle left-turn, right-turn, left-turn, etc until it drifts away, does a 180 turn and repeats.

Here is a screenshot of the PID tuning plot with the yaw rate commands, you can see that in loiter and after reaching the guided waypoint I get the big oscillations in yaw-rate command (the biggest spikes are the 180 turn):

I did a short test yesterday just to gather data on this problem but unfortunately my dataflash got corrupted in an earlier mission and I don’t have a bin file. I do have the tlog file here. If it is not a well-known issue I will go out for another test to get the bin file and a video.

The steering motion is similar to an issue raised here (see the video, this is similar to what my boat does except with skid-steer and faster oscillations):

Does anyone know what I can tune to fix this? It works well in auto including pivot turns.

Thanks,
Mike

Hi Mike,

I’m not aware of this problem… I guess that it is caused by some issue in the tuning of the turn rate controller or perhaps with the configured vehicle limits but it’s just a guess. … a .bin log would be really good. The tlogs are a bit of a struggle to work with because they lack so much information.

2 Likes

Thanks. I suspect a limit as well- when I went into guided mode the boat had to do an 180ish turn and the command maxes out at a lower value than in loiter, but I’m not sure that is the only issue.

I’ll get the boat out again early next week and get a bin log file. I appreciate your help.

I gathered more data today. I meant to get a small log file of just the loiter behavior but it is a big file with an autonomous run at the end, sorry about that. But the loitering is in the beginning, and I guess you can also use this to see that the autonomous guidance works fine.

Here is the bin file: 2022-08-02.BIN

Here is a video of it trying to loiter:

Thanks for any ideas!

Seems like I read here some time ago about the same issue could be caused by the WP/loiter radius being too small. Hope that helps. Good luck!

1 Like

I had the same problem. I think the issue was related to the speed controllers being more powerful in the forward direction than the reverse direction. (This was built into the esc hardware.)

I was able to mostly tune it out by lowering the max trim in forward to match max output in reverse. Of course, this also limited my boats max speed and power during normal missions, so it wasn’t really an acceptable fix.

1 Like

I’m following up because I would really like a better-performing loiter for my boat. I need to know what parameters will affect the loiter heading response so I can turn it down to something less violent, and I’m still not sure.

I’ve been digging through the code and have a few questions on what could be making my boat oscillate so extremely in loiter mode. Here’s what I found:

First, loiter mode seems to be the only user of the function calc_steering_to_heading() for my application (it comes up for sailboat tacks, simple mode, and a form of guided mode but I’m not using any of these). The code has the option to set a max turn rate but does not use it here except for sailboats. I wonder if this should use max pivot rate or something? Link to code

Following the function calls:

  • calc_steering_to_heading()
    ** Calls attitude_control.get_steering_out_heading()
    *** Calls get_turn_rate_from_heading()
    **** Calls _steer_angle_p.get_p()
    ***** Which maps to a PID controller I think… which gains does this controller use?

get_turn_rate_from_heading() has a comment that says the max turn rate is either as passed in or it uses ATC_STR_RAT_MAX but I don’t see this default implemented. Out of date comments or maybe I missed it? Link to code

With the long chain of functions calling functions I’m not sure the best place to implement a max turn rate, this is the first thing I’d like to try. My boat pivot turns nicely but it has a max pivot turn rate limit that is in use often (you can see it in the guided mode portion of the plot at the top- 40 deg/sec). If the max turn rate isn’t the issue then I guess I will need to find out which PID gains are used in _steer_angle_p.get_p()

Anyway I hope someone like @rmackay9 can help with my questions and thanks!