Hi all. I'm investigating an issue that I'm experiencing with my TinyPilot.
When tacking in compass mode, everything works really good. The parameters for tack rate and threshold are set to 10 degrees per second, and 50%, respectively.
Problems appear when trying to tack in wind mode (apparent). When tacking to port, the tacking subroutine completes immediately, and the normal ap algorithm eventually manages to slowly turn the boat onto the new tack.
When tacking to starboard, the boat violently turns (with the defined tack rate) into a 180 degree turn, where I manually disengaged the AP.
When looking at the code, there is one little thing that seems strange to me:
Could it be possible that the "direction" variable is assigned to the wrong side in line 153?
And is the "d" variable in line 151 correct?
Unless anyone immediately see any issues here, I could try to print some debug info next time I'm on the water, and share it in the thread.
Best regards, Leif
When tacking in compass mode, everything works really good. The parameters for tack rate and threshold are set to 10 degrees per second, and 50%, respectively.
Problems appear when trying to tack in wind mode (apparent). When tacking to port, the tacking subroutine completes immediately, and the normal ap algorithm eventually manages to slowly turn the boat onto the new tack.
When tacking to starboard, the boat violently turns (with the defined tack rate) into a 180 degree turn, where I manually disengaged the AP.
When looking at the code, there is one little thing that seems strange to me:
Code:
# tacking, moving rudder continuously at tack rate
if self.state.value == 'tacking':
# command servo to turn boat at tack rate
command = ap.heading_command.value
heading = ap.boatimu.SensorValues['heading_lowpass'].value
headingrate = ap.boatimu.SensorValues['headingrate_lowpass'].value
headingraterate = ap.boatimu.SensorValues['headingraterate_lowpass'].value
if 'wind' in ap.mode.value:
d = .5 - 2*heading / command
tack_heading = -command
direction = 1 if command < 0 else -1
else:
direction = 1 if self.current_direction == 'port' else -1
tack_heading = command - direction * self.tack_angle
d = direction * (command - resolv(heading, command)) / self.tack_angle
# see if we passed the tack user defined tack threshold
if 100*d > self.threshold.value:
self.state.update('none')
self.direction.toggle()
ap.heading_command.set(tack_heading)
return
# for now very simple filter based on turn rate for tacking
command = (headingrate + headingraterate/2)/self.rate.value + direction
command = min(max(command, -1), 1) # do not cause integrator windup
ap.servo.command.set(command)
return True # ensure current pilot is overridden
And is the "d" variable in line 151 correct?
Unless anyone immediately see any issues here, I could try to print some debug info next time I'm on the water, and share it in the thread.
Best regards, Leif