-
-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: v2 Course & Resources APIs #1477
Conversation
@tkurki @sbender9 Interested in your thoughts on the following.... As I see it there are currently two main sources of information to populate the SK data model:
This PR currently addresses the population and maintenance of SK paths related to resources and setting a course via 2. SK API. So the question is... what should happen, if anything, to course / destination information coming in via NMEA that is destined for SK paths set via the course API? as the incoming NMEA values may:
I would think that the values set via the API should prevail. |
A good point. I don't quite follow your reasoning - why would setting things via API be different from setting navigation destination via some other means? In the ideal world I should be able to set navigation mode and params, say We should think about and experiment with the different scenarios and how to tackle them. A setting for navigation priorities? Notifications about quarrelling inputs and a way to resolve them? One way forward would be to list some of these scenarios, on what we know how things work with 0183 and N2K, and how they could be resolved with minimal confusion & fuss. One way to resolve this issue would be altering the data model so that we can capture multiple navigation setups: the internal. The same issue rises with multiple MFDs on the bus. I wonder how that scenario works today? We got multiple values not quite right in v1. We should do better this time. |
As it stands this PR adds quite a bunch of deltas to the initial set that is sent upon ws connection. This is added even if the user has never used course api. I think we should instead be lazy: you should start seeing course API data only after you start using it. That should be perfectly possible, given that the course api state is persisted separately. |
...forgot to say that I can have a look at suppressing the course api data until activation. |
Another point that popped up when coming back to this branch after a while: I found it odd that for example POSTing and GETting waypoints use different data formats. I am starting to think they should both use the same Geojson format. Writing one and getting another is definitely not the principle of least surprise.... |
@wellenvogel AvNav is a pretty complete UI for the features in this branch: creating and modifying waypoints and routes & activating & stopping navigation as well as associated operations such as setting/advancing the next point. I would love to have your insight on these apis! The easiest to way to get an overview is probably running the docker branch from this image: |
The thinking here was to allow simple resource creation by providing minimal data (abstracted from the schema) e.g. create a waypoint by providing only lat/lon and the API takes care of the rest. PUT allows the use of GeoJSON to create or replace a record... so in this way both scenarios are covered providing some flexibility. |
Yeah, my point is that I think consistency in the data format for create and read operations outweigh the handiness of the more compact format. i can do the change on the server (once I fix the mysterious test failures) if you could do Freeboard afterwards? |
Make that |
Currently I'm busy with some project on my side. Functional question: |
To me routing or autorouting means that something can create a (safe) route from point a to point b. That is not in the scope of this PR nor in the plans. This PR should expose the APIs for a plugin to manipulate routes, so a plugin could do that. What is in scope is broadcasting changes in the navigation state: when you activate/deactivate navigation (to a point/waypoint or along a route) the server emits data like so https://github.com/SignalK/signalk-server/pull/1477/files#diff-1751c3e712c0afe5b944ef930a6ec6eafce600e8132886fe7f336c52a11468d4R735-R793 |
Ok, autorouting was not the point... |
Currently this is delegated to the Course Provider plugin which does the course calculations and raises a "notification" when perpendicular is passed. This can then be acted on accordingly. |
All resource adds, updates, deletes are emitted as deltas so changes to resources are available to clients by subscribing to |
@tkurki Since the refactor it appears that requests to add, update, delete resources are being met with a 403 Unauthorised response due to signalk-server/src/api/resources/index.ts Line 144 in 3b3c1af
This occurs even if security is not enabled. Could you please review. |
Without security POST, GET and PUT work for me from the Swagger UI with the server launched via the above mentioned docker method and locally built native node. |
The resource ids all have the In practise it adds some, mostly meaningless extra characters to the already pretty unwieldy uuid values. I'd be willing to go with the naked uuids as resource ids. I think this could be the time to do this, as we are setting fundamentals for v2 resource api. What do you think @panaaj ? |
It works for me OK when using docker but using the local code is where I have the issue (where it wasn't an issue before). |
I have no issues with moving to just a uuid. The impacts I foresee for existing implementations / applications are:
These would require apps to detect v2 api and make the necessary adjustments. |
Since we don’t do any validation (?) this mostly affects assigning new ids on POSTs and examples in the api specs I think. |
I have started work on removing the prefix in the API and also the |
@tkurki I have pushed updates to
|
src/api/course/index.ts
Outdated
}) | ||
|
||
values.push({ | ||
path: `${navGC}.nextPoint.value href`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look correct. Missing a period? Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Does the route have a name (in it's definition)? Line 466: src/api/course/index.ts
It seems to be working for me using Freeboard beta 4. How did you activate it... using Freeboard or curl? Here is the result I get {
"activeRoute": {
"href": "/resources/routes/6b23c37c-a13c-4cad-a774-562b4ce134ec",
"pointIndex": 0,
"pointTotal": 4,
"reverse": false,
"name": "rt3",
"waypoints": [{
"position": {
"latitude": -35.04392514341443,
"longitude": 138.31563470807106
}
}, {
"position": {
"latitude": -35.087453067356904,
"longitude": 138.3175511229639
}
}, {
"position": {
"latitude": -35.10155705655288,
"longitude": 138.3549528776733
}
}, {
"position": {
"latitude": -35.066672359569836,
"longitude": 138.37743908836438
}
}]
},
"nextPoint": {
"href": null,
"type": "RoutePoint",
"position": {
"latitude": -35.04392514341443,
"longitude": 138.31563470807106
},
"arrivalCircle": 4000
},
"previousPoint": {
"href": null,
"type": "VesselPosition",
"position": {
"longitude": 138.40021242628814,
"latitude": -35.04938213007765
}
},
"startTime": "2023-01-01T05:58:25.620Z",
"targetArrivalTime": "2022-08-07T15:32:03Z"
} |
Ooops, I did that in Swagger and |
Add initial v2 api with Course and Resources apis, including their OpenAPI descriptions. Add support for handling v1 and v2 deltas separately within the server. Add support for Resource Provider plugins.
This PR supercedes PR #1381 Course and Resources API as it is a merge of #1381 with the current main branch (v1.45.0).
Implements:
Course API emits v1
courseGreatCircle
andcourseRhumbline
deltas for backwards compatibility.Reference the following for tasks to address deprecating v1 paths at the desired time.