Posts: 50
Threads: 8
Joined: Jan 2024
Reputation:
0
2024-09-15, 07:25 PM
(This post was last modified: 2024-09-15, 07:35 PM by MarineW29.)
Hello, I am working on a project with a screen connected to an ESP32 to display different data from Signal K. Among these data, I need to display the state of pypilot and the heading target of pypilot.
I thought that Pypilot would share this data in SignalK with the paths "steering.autopilot.state" and "steering.autopilot.target.headingMagnetic" or something similar, but I don't see them.
However, I can see navigation.attitude and navigation.headingMagnetic from the pypilot source.
Is this a bug ? Or is it just not implemented ?
Would it be difficult to add them in SignalK ?
How does the Pypilot plugin for OpenCPN work to get this data?
Thanks!
Update :
- SignalK is working on OpenPlotter / Raspberry Pi 4 with wifi Hotspot
- Pypilot is working on Tinpyilot / Raspberry Pi Zero connected to OpenPlotter wifi Hotspot
Posts: 2,603
Threads: 22
Joined: Jun 2016
Reputation:
84
If you check in pypilot/pypilot/signalk.py you can quickly see which signalk keys are supported. So you can get the magnetic heading but not the target.
Normally the autopilot would be sent the target heading, but not broadcast it.
The pypilot plugin communicates directly with pypilot on port 23322. You can check pypilot/client.py for details, or the pypilot plugin source code, but to simplify it, you would need to send something like:
watch={"ap.heading": 1}
Would give you heading updates once per second. If you are using micropython on esp32, you can already run hat/upy_client.py but either way take a look. You might want to use UDP packets if latency becomes an issue.
Posts: 50
Threads: 8
Joined: Jan 2024
Reputation:
0
2024-09-16, 07:37 AM
(This post was last modified: 2024-09-16, 07:38 AM by MarineW29.)
Thanks a lot Sean. I'll look into that.
Is there any chance though, that the target heading and status (standby/auto/gps/wind...) will be sent to SignalK in the future, even if it's not broadcast?
It would be easier for me, because I have other data to retrieve there.
Posts: 2,603
Threads: 22
Joined: Jun 2016
Reputation:
84
It could certainly be made to do that and potentially as an option. It doesnt make much sense to send data to signalk that no program is using though.
The issue with signalk is the subscriptions are only 1 way. So ideally, your process would inform signalk server it wants to know the autopilot mode with a subscription, and then signalk server would tell pypilot that it needs to subscribe to the autopilot mode. This is not how signalk is implemented, instead it is assumed that pypilot would broadcast any type of data to signalk server even if none of it is used. This is the reason not to send the data, it is just more overhead and bandwidth.
Posts: 50
Threads: 8
Joined: Jan 2024
Reputation:
0
As I said, sending this information back to SignalK would allow a display to retrieve data from different sources connected to SignalK, including Pypilot, but also the GPS connected to OpenPlotter in my case, and why not other data.
As for the bandwidth overhead, we are talking about 2 data that move very little, so they would not need to be sent often.
But I may not be measuring all the implications.
Posts: 2,603
Threads: 22
Joined: Jun 2016
Reputation:
84
Are you mostly after the autopilot mode and commanded heading? If it is for keys that only change whenever the user changes the mode or heading, then it is not a problem to send (if signalk has granted pypilot a token)
Which exact keys for signalk?
The real reason it does not do this is most of the autopilot keys were unclear until this past year, and even still the signalk standard for autopilot is not yet fixed. So this is a big reason why the support is not implemented.
So I agree with you.. can we come up with a list of keys that pypilot could send to signalk but does not yet?
"steering.autopilot.state"
"steering.autopilot.target.headingMagnetic"
What else? It might only update headingMagnetic when in compass mode for example, and other keys when in other modes.
Posts: 2,603
Threads: 22
Joined: Jun 2016
Reputation:
84
I will work on this in a separate branch and let you know in a few days.
It is a little more work because until now signalk translated only with sensors, not directly to autopilot internals, so I need to add this system, and I also want to make these keys work bidirectional.
Posts: 50
Threads: 8
Joined: Jan 2024
Reputation:
0
Great !
Thanks a lot Sean