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.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pypilot programmed control (node-red?)
#1
I have signal k, pypilot (on tiny pilot hardware), and a Raymarine Axiom MFD. When the Axiom has a course plotted it puts navigation.courseGreatCircle.bearing.trackTrue, navigation.courseGreatCircle.nextPoint.bearingTrue, and navigation.courseGreatCircle.crossTrackError onto the NMEA network and signalk is picking that up just fine. I’m wondering if there's a way to use those to inform pypilot to follow the course. I can’t imagine I'm the first to think of it in this group of genius hackers! But, if I'm the first to have this combo of hardware, and I need to figure it out, is there a way to control the pypilot (remembering it's a separate machine on the network) using Node-Red to read what it thinks is the current bearing and set its command bearing based on some math using the MFD’s info? 

I've been looking around on the forum and trying to find how I might be able to send commands to the pypilot such as "set the bearing command to 103.6º" and can't seem to figure it out. I've found a few things where it looks like NMEA commands are being sent but they seem to have other hardware involved. When I try to run a command line for pypilot on the signalK server, it doesn't find the command... do I need to install pypilot on the server even though it's running on the tinypilot hardware? What would be the best way to send such a command to pypilot if I have to build this all from scratch? I'm leaning toward Node-Red simply because I already have a dashboard I've created with it for various things and it'd be nice to consolidate. 

I’m currently heading down the ICW and being the interface between the Axiom and pypilot web site, so I've got a rough idea how the math might work, but haven't dug into how to stitch it together.

Thanks!
- Tony

Seafarer 30 
"Novaturient" 
(adj.) desiring or seeking powerful change in one’s life, behavior, or situation; the root of wanderlust 
(pronuntiation/”nO-va-‘tUr-E-ent)
Reply
#2
I think, in your case with those specific signalk keys available, your best option is to configure signalk to send RMC and APB messages to pypilot's TCP/20220 socket. To do this, you'd need signalk's 'signalk-to-nmea0183' server plugin from the built-in appstore, configure that plugin to generate RMC and APB messages, then add a Data Connection with NMEA0183 and TCP client settings pointing to pypilot's IP address and TCP/20220 listening socket, and set Output Events to nmea0183out. If pypilot receives those messages, it will enable the GPS mode which will follow a track/route.

The option that you seem to have heard about is related to the pypilot native, internal communication mechanism, that is accessible through some TCP socket and can be talked to through a python pypilot_client. With that, you could in theory get the whole thing working as well, but it's the long way home, not the royal way and it might break in the future, so I would definitely not recommend that.

Another option, that will not work, would be to use the native, zero-conf interface between pypilot and signalk. Pypilot requires steering.autopilot.target.headingTrue, which you don't seem to have in your signalk database.
Reply
#3
... or modify pypilot to natively handle commands received over signalk.

This shouldn't be too hard to implement (unless I'm missing something), and could also be a standard way for the future to implement remote controls (and displays) for pyplot.
Reply
#4
(2022-12-09, 12:04 AM)ironman Wrote: I think, in your case with those specific signalk keys available, your best option is to configure signalk to send RMC and APB messages to pypilot's TCP/20220 socket. To do this, you'd need signalk's 'signalk-to-nmea0183' server plugin from the built-in appstore, configure that plugin to generate RMC and APB messages, then add a Data Connection with NMEA0183 and TCP client settings pointing to pypilot's IP address and TCP/20220 listening socket, and set Output Events to nmea0183out. If pypilot receives those messages, it will enable the GPS mode which will follow a track/route.
ironman, thanks for this! It looks, in theory, like this will work. Pypilot is recognizing the GPS option now in its drop-down (previously it'd just flick back to compass). So, we'll see how it works tomorrow. That's a heck of a lot easier than writing my own routines, assuming it works sufficiently well. 

Cheers!
- Tony

Seafarer 30 
"Novaturient" 
(adj.) desiring or seeking powerful change in one’s life, behavior, or situation; the root of wanderlust 
(pronuntiation/”nO-va-‘tUr-E-ent)
Reply
#5
the 'apb' sensor in pypilot is used to follow routes and can receive this from nmea as well as signalk

It essentially adjusts the commanded heading and is translated (from signalk.py) as:
'apb': {('steering.autopilot.target.headingTrue', radians): 'track'},

So basically it may be translating the wrong key. You could try replacing it and see if it works.

I had some disagreements with the signalk designers about autopilot specifics, so there is limited integration. For more specific commands like setting a particular heading or manual control you could communicate directly with pypilot or invoke pypilot_client

As for sailing down the ICW, where are you? I am in st augustine.
Reply
#6
(2022-12-11, 05:06 PM)seandepagnier Wrote: the 'apb'  sensor in pypilot is used to follow routes and can receive this from nmea as well as signalk

It essentially adjusts the commanded heading and is translated (from signalk.py) as:
                'apb': {('steering.autopilot.target.headingTrue', radians): 'track'},

So basically it may be translating the wrong key.   You could try replacing it and see if it works.

I had some disagreements with the signalk designers about autopilot specifics, so there is limited integration.   For more specific commands like setting a particular heading or manual control you could communicate directly with pypilot or invoke pypilot_client

As for sailing down the ICW,   where are you?   I am in st augustine.

Shoot! I just left St. Augustine this morning and am at Fort Matanzas tonight. I wish I'd have checked this thread earlier!

I'd not had time to do much with this as I lost my shaft the day I'd hoped to test this, and have been running to try to catch up some and am just looking into it again today. The GPS function goes live on pypilot, now, and it seems to be getting numbers for the heading*, but it doesn't follow the course. When you say to try replacing the key, where do I go about that? 

* I say seems to be getting numbers because it's getting some numbers but they don't appear to be the same numbers as the pypilot compass gives nor what the Raymarine unit gives... so I'm not sure exactly where it's coming from.
- Tony

Seafarer 30 
"Novaturient" 
(adj.) desiring or seeking powerful change in one’s life, behavior, or situation; the root of wanderlust 
(pronuntiation/”nO-va-‘tUr-E-ent)
Reply
#7
To be clear, you are sending steering.autopilot.target.headingTrue to pypilot? How exactly do you generate it since afaik opencpn cannot.

As for controlling pypilot in other ways, you can invoke pypilot_client, eg:
pypilot_client ap.heading_command=180

It would be possible to build node red support as you are essentially just pushing the string "ap.heading_command=180\n" down a socket.

I am still in st augustine.. you can always backtrack
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)