This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to choose 'compass' mode when route is active
#1
When I have an active route in OpenCPN, I might still want to steer a compass heading.

However, the PyPilot plugin shows it forces gps mode. The only way to steer a compass heading is to deactivate the route, which is cumbersome.

Is there a trick to steer compass with an active route, or can this this be an enhancement?

Thx,

-

[Image: attachment.php?aid=523]


Attached Files Thumbnail(s)
   
  Reply
#2
It technically supports both gps and compass for route following, but opencpn does not produce apb route messages with compass headings.

So if pypilot receives APB with magnetic heading, it will use that and switch to compass mode, but opencpn does not produce it.

OpenCPN (or the autopilot route plugin) could be enhanced to produce this as an option, but it's not so simple as adding declination to the true course needed since the compass is not perfectly accurate.

What is the purpose of using compass mode to follow a gps route?

pypilot will soon have a wind pilot which does not rely on the compass at all. In this case, "gps" mode computes the difference between wind and gps, and follows a wind angle which is slowly adjusted to hold a given gps course.
  Reply
#3
(09-01-2019, 06:30 PM)seandepagnier Wrote: It technically supports both gps and compass for route following, but opencpn does not produce apb route messages with compass headings.

So if pypilot receives APB with magnetic heading, it will use that and switch to compass mode, but opencpn does not produce it.

OpenCPN (or the autopilot route plugin) could be enhanced to produce this as an option, but it's not so simple as adding declination to the true course needed since the compass is not perfectly accurate.

What is the purpose of using compass mode to follow a gps route?

pypilot will soon have a wind pilot which does not rely on the compass at all.  In this case, "gps" mode computes the difference between wind and gps, and follows a wind angle which is slowly adjusted to hold a given gps course.

I simply want to hold a course. This works when no route is activated. But I can't do it when a route is activated.
  Reply
#4
I don't understand why you don't deactivate the route and switch to compass mode then. What is the point of the active route? Can you just disable the tcp connection?
  Reply
#5
Typically you're on a track and you want to dodge something. Flick to compass mode, adjust heading, and when you're clear of the obstacle you go back to the track.

The original raymarine user interface I'm used to has three main modes. Standby, Auto (=compass) and Track (=gps). All these modes accessible with one push on the tiller pilot buttons. The track mode steers towards the APB or RMB message.

[Image: attachment.php?aid=524]

While we are at it, in fact there is another mode, which is 'waypoint advance'. The machine sounds an alarm and will maintain the current course until you actively acknowledge you agree with the heading change towards the next waypoint. Took me a while to get my head around, but I got to value this as a very useful, not to say absolutely vital safety measure. I would love to implement a waypoint arrival alarm for pypilot at the very least, otherwise using the track mode is not a safe option for me.

Come to think of it, processing the Arrival Alarm bit of the APB message in nmea.py, and forwarding it to a GPIO pin with a piezo buzzer on it would do the trick. Otherwise one would have to process the RMB message as well and use the Range to Destination for this. When arriving, set ap.mode to compass, and set it back to gps when the alarm is acknowledged.


Attached Files Thumbnail(s)
   
  Reply
#6
Or better would it be triggered by a waypoint ID change, I case you sail past the waypoint ouside the range of the arrival circle.
  Reply
#7
To get back to my own original topic again :-) I found that the following change to the body of receive_nmea in nmea.py in the tinypilot does allow me to switch to compass mode even when a route is active. 

        if line[3:6] == 'APB' and time.time() - self.last_apb_time > 1 
            and self.last_values['ap.mode'] == 'gps' and self.last_values['ap.enabled']:
            self.last_apb_time = time.time()
            data = line[7:len(line)-3].split(',')
            #if self.last_values['ap.enabled']:
            #    mode = 'compass' if data[13] == 'M' else 'gps'
            #    if self.last_values['ap.mode'] != mode:
            #        self.client.set('ap.mode', mode)

            command = float(data[12])
            xte = float(data[2])
            xte = min(xte, 0.15) # maximum 0.15 miles
            if data[3] == 'L':
                xte = -xte
            command += 300*xte; # 30 degrees for 1/10th mile
            if abs(self.last_values['ap.heading_command'] - command) > .1:
                self.client.set('ap.heading_command', command)

I had overlooked what was said in another thread, in which you explain the background of this functionality. I understand the design rationale now, but still, for my purpose I'd like to have it switched it off, like above. Is it possible to make this behaviour dependent on a parameter, so it can be switched on or off by an end user without having to change code?

Thx,
  Reply
#8
(09-03-2019, 08:04 PM)ironman Wrote: To get back to my own original topic again :-) I found that the following change to the body of receive_nmea in nmea.py in the tinypilot does allow me to switch to compass mode even when a route is active. 

        if line[3:6] == 'APB' and time.time() - self.last_apb_time > 1 
            and self.last_values['ap.mode'] == 'gps' and self.last_values['ap.enabled']:
            self.last_apb_time = time.time()
            data = line[7:len(line)-3].split(',')
            #if self.last_values['ap.enabled']:
            #    mode = 'compass' if data[13] == 'M' else 'gps'
            #    if self.last_values['ap.mode'] != mode:
            #        self.client.set('ap.mode', mode)

            command = float(data[12])
            xte = float(data[2])
            xte = min(xte, 0.15) # maximum 0.15 miles
            if data[3] == 'L':
                xte = -xte
            command += 300*xte; # 30 degrees for 1/10th mile
            if abs(self.last_values['ap.heading_command'] - command) > .1:
                self.client.set('ap.heading_command', command)

I had overlooked what was said in another thread, in which you explain the background of this functionality. I understand the design rationale now, but still, for my purpose I'd like to have it switched it off, like above. Is it possible to make this behaviour dependent on a parameter, so it can be switched on or off by an end user without having to change code?

Thx,


Yes, this is an alternative.  You want the active route to work only in gps mode.

The other way is convenient because you don't need to switch modes when you activate the route.  So it is a tradeoff.  Not sure if using compass mode to dodge is best, normally you can use manual control.

As far as processing the waypoints in pypilot and using the buzzer, it's possible but not implemented.   I don't really see the reason since it is implemented in opencpn already.   Opencpn can play a sound.   Also, the autopilot_route_pi plugin for opencpn provides alternate processing of route following.   It also provides optional confirm dialog on waypoint arrival to do what you asked for, but rather than switching back to compass course, it holds the gps course.

If you want to do this logic in the actual autopilot, how do you want to acknowledge waypoint arrival?

Are you sure using waypoints and arrival radius is the best way to follow a route? Just because old systems used it doesn't make it best. I prefer route position bearing, where the heading is constantly recomputed toward a position forward along the route, so waypoints have no significance and the boat makes better turns.

I can see how different modes might be better in different situations, and I am also curious about a route following logic using wind steering mode, automatically trying to predict future position of the boat via tacks if needed.
  Reply
#9
(09-04-2019, 08:36 AM)seandepagnier Wrote: I don't really see the reason since it is implemented in opencpn already.   Opencpn can play a sound. 

Thx I had already looked for that, but I still can't find it. Where is it then? Watchdog exclusion zones would be a bit cumbersome...

(09-04-2019, 08:36 AM)seandepagnier Wrote: Also, the autopilot_route_pi plugin for opencpn provides alternate processing of route following.   It also provides optional confirm dialog on waypoint arrival to do what you asked for, but rather than switching back to compass course, it holds the gps course.

Ahhh! I'll check that out then; I had seen it in GitHub but not on the OpenCPN plugin download page, so I had gathered it was work-in-progress and not for general use yet. Should I compile it from github?

(09-04-2019, 08:36 AM)seandepagnier Wrote: Are you sure using waypoints and arrival radius is the best way to follow a route?   Just because old systems used it doesn't make it best.   I prefer route position bearing, where the heading is constantly recomputed toward a position forward along the route, so waypoints have no significance and the boat makes better turns.

Indeed I had seen on one of the videos how you specified something like a turning radius, but had not been able to find it in any pypilot user interface. I guess this advanced 'route position bearing' is in this autopilot_route_pi?  Glad to find out that using those medieval APB messages are not the only way to interface with pypilot!

Whatever it is, I hope it makes up for drift across the track: if there's current perpendicular to the canal, I want it to counter that. Some dredged canals have hard verges. command += 300*xte; is definitely not optimal for this and will not keep me on the line. There must be some I (integration) parameter in the algorithm.
  Reply
#10
You can compile from github yes.

Increasing the I gain will reduce the cross track error, but also increases instability if too high.

I don't think command+=300*xte is the reason you cannot stay on track
You might also need to tweak the xte gain as well as the I gain.

Also try alternative algorithms besides xte, or even implement and adaptive one if needed.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)