I faced a real challenge when digging into the code of BRouter and that had nothing to do with the complexity of the algorithms :-). Due to my problems with the code I decided to couple Brouter and the navigation processing as loosely as possible. I wanted to use and modify Brouter as little as possible.
Being mostly independent from BRouter is good for reusing the code it in another context but not for the overall performance.
The performance is okay in a single instance environment. I do not recommend using it for running a heavily used public routing server.
The code is only tested in a BRouter-Server context. I did not test it in any other way.
Like parts of BRouter the actual navigation hint processing is moved to a script.
For scripting the SISC Scheme interpreter in included. This should give all the power to scripting you could hope for.
In the current version a very simple hiking navigation script is included.
The main purpose of this code is working with my modified QLandkarteGT installation giving some navigation hits.
I did not bother modifying the maven configuration. I use Eclipse build in functionality for building the code. So, please try to live with that and do not throw dung at me for not updating the proper build environment.
I actually modified these Brouter-Source-Files only slightly:
brouter-core/ btools.router.OsmTrack
brouter-core/ btools.router.RoutingEngine
brouter-server/ btools.router.RouteServer
I added 4 classes in:
brouter-core/ btools.router.navi.
All the rest of the code is in the separate project navigator.
Attached you will find the source as well as the compiled version.
Have fun,
Ralf
PS: I'm here the first time and just realized not to be able to attach anything.
Here is the link: http://www.datafilehost.com/d/dca5097e
Thank you for the hint. I agree, collecting the nodes from the final path should suffice.
Regarding the potential performance issues. The scheme interpreter is initialized for each navigation processing from start. This could take >100 ms or so. I'm quite sure that could be improved, but did not bother for my purpose.
Hi Ralf,
Am Sonntag, 21. Juni 2015 20:00:32 UTC+2 schrieb Ralf:
> I added navigation functionality to BRouter modified QlandkarteGT slightliy to use the extra data now coming from Brouter.
interesting.
regarding this script-based approach for voice hints and the way to carry them in a gpx I will have a deeper look.
> I think you are also aware, that at least some Locus users (including me ;-) ) would love to have navigation hints support in Brouter. There is a discussion about it in the Locus forum, but nobody has a clue how to transfer the hints to the navigation app (via gpx?). Maybe Ralf's implementation could help to shed some light on this?
>
> regards,
> zossebart
>
Zossebart,
I can see no technical restriction why the code should not work in an app anvironment in principle. I did not test it yet and I doubt that it will just run out of the box. Most likely there is a necessity to enhance/modify the current interface, but not the core functionality.
In regard locus:
It depends on how locus expects the handover of navigation hints. The current implementation within Brouter writes the collected navigation hints as way points into the gpx stream. This part of the code is extremely simple and only a few lines long.
If another transformation to fit the needs of locus is required... well this should be an easy job.
The gpx format defines in essence a way to disciple positions (waypoints) (POI and such) position defining a track and positions defining a route.
Each of these positions can hold the same meta data, such as geo position, name, comment, type, description, time and such.
There is no defined attribute to place navigation hints (let me know if this is not correct). Therefore systems either use a proprietary extension or misuse one of the existing attributes to store and evaluate navigation hints.
To pass navigation hints to QLandkateGT I added waypoins and placed the navigation hint in the name attribute. I used the comment attribute to store the index of the related track step for this navigation hint. I added a few lines of code to the QLandkarteGT to use this information for its internal processing.
I'm using OruxMaps for hiking and OruxMaps has the capability to read the names of waypoints. With an additional little program I convert the QLandkarteGT gpx export, holding “my” navigation hints as positions defining a route to just plain waypoints.
If the navigation hints are just waypoints and the hint is the name of that waypoint OruxMaps is happy, and so am I :)
You see, all depends on how locus expects to get navigation hints. Providing them within the gpx-file is no thing. If the data exchange between BRouter and Lucos is not gpx but another format, things might be different.
I think we should wait for Arndt to answer this, but I can't imagine that the internal format is gpx, because it has lots of overhead.
Am Freitag, 10. Juli 2015 14:02:28 UTC+2 schrieb Zossebart:I think we should wait for Arndt to answer this, but I can't imagine that the internal format is gpx, because it has lots of overhead.
It is GPX. Here's the aidl-definition of the interface that Locus uses:
http://brouter.de/brouter/IBRouterService.aidl
OsmAnd still uses KML, but for just historical reasons. Meanwhile there's also GeoJSON (added by Norbert as a low-overhead format for BRouter-Web), but that's not yet supported by the aidl-interface.
I'm following the discussion with great interest, but, to be fair, I'm not going to implement into the Android app some quick-hack that's Locus-Only
, or german-only,
and I'm somewhat sceptical about adding a third-party scripting library to the android app. This Android App is all about memory queezing and keeping it slim, so beeing conservative on technologies is the only way to avoid regressions.
I wonder what would be a generic way of transferring navi instruction hints between applications. For portability, text strings in any language are clearly not the way to go (even if it's english). So maybe sort of a coded value (e.g. 0x1 == straight, 0x2 == left, 0x3 == right, 0x4 == u-turn, maybe with turn angles in degrees)? It's too bad that something like this doesn't seem to exist right now, or we don't know of it.
.. would it be possible to implement it in java inside the app, instead of using the script approach? Maybe that would't be as much of a problem performance-wise?
Do 3rd party online router services provide navigation hints ?
Or, are they created by target application like OSMAnd, based on
provided route ?
Given the variety of existing solutions, you might as well define your own one. Obviously, everyone does this ;-)
Or you could decide to re-use one of the existing solutions (probably the one most of the apps already support) and implement it into brouter (provided the licence allows this).
This is likely to be my topic for the next Karlsruhe hack-weekend at geofabrik in to weeks.
Yes I think the most promising approach is to not care on interface formats, but just on the model and the algorithm, that is, produce good data, choose a data-model with a small missmatch to the existing approaches, write that in comment-syntax into the xml and see wht happens.
This is likely to be my topic for the next Karlsruhe hack-weekend at geofabrik in to weeks.
... Therefore, I would prefer a format with the turn instructions packed into waypoints (<wpt>), like Locus or GPSIES does.
I hope we can make some progress in this field. I (and I think many more) would love to have turn instructions natively provided by Brouter!
I did not succeed to have Locus process these voice hints. But in my tests today, I did not succeed to create any reasonable voice hints in Locus, not even after switching to MapQuest, all I heard was confusing, so maybe I am doing something wrong.
</rtept>
<rtept lat="49.2094392" lon="10.0648713">
<desc>keep right</desc>
<extensions>
<turn>KR</turn>
<offset>103</offset>
</extensions>
</rtept>
Offset is the the number of the trackpoint with the same coordinates. Desc is shown in the navigation list but seems not to be spoken. Turn are the instructions, see https://github.com/osmandapp/Osmand/blob/master/OsmAnd-java/src/net/osmand/router/TurnType.java but you can't import C (go straight).
I guess I have finally got it, your ways seems correct to me now. :-)
Dne neděle 10. dubna 2016 14:46:45 UTC+2 abre...@googlemail.com napsal(a):@Poutnik: thanks for your feedback (private message?). For your remark on way-priorities: my approach generates voice hints for equal-priority junctions, so I guess having track=road=path all equal is o.k.?
Do you plan to implement also keep left / keep right ?
Like e.g. if there are 2 ways within +/- 15 degrees , possibly making confusion which one of them is the straight one.
Yes I think the most promising approach is to not care on interface formats, but just on the model and the algorithm, that is, produce good data, choose a data-model with a small missmatch to the existing approaches, write that in comment-syntax into the xml and see wht happens.
I'm not sure what you mean by "comment-syntax into the xml"? Does this mean that the navi instructions in the first implementation will end up not being useable by an app, but at least human-readable as comments in the gpx-file for verification?
.. unless turnInstructionMode info would be kept out of the profiles.
That comment syntax would contain the superset of information of the existing formats, to keep the model-mismatch small. E.g. it would contain the lon/lat of the wayspoint *and* the offset of the corresponsing track-point (lon/lat is ambigious for tracks crossing themselves?). And it would contain the complete junction geometry, including angles and priorities of all ways, just to make it easy to check the decision the algortithm makes.
Like this:
/* --turn-instructions-start
--turn TSLR at 25(8.608944/49.674370) next 630 follow 4(25)5 ignore (-15)4 (50)4
--turn-instructions-end */
makes sense?
Menion (Author of Locus) answered to my question on the interfacing problem ( see http://forum.locusmap.eu/index.php?topic=5066.msg42240#new )
He says, BRouter should'nt generate target specific syntax, but define it's own, and he's ready to evaluate whatever we deliver.
The lead's me back to the idea of using a comment-syntax that does not have any side-effects and does not break any imports. Such a comment syntax would be the default (generated by an out-of-the-box BRouter installation), with the possibilty to generate other formats by setting the turnInstructionMode parameter.
That comment syntax would contain the superset of information of the existing formats, to keep the model-mismatch small. E.g. it would contain the lon/lat of the wayspoint *and* the offset of the corresponsing track-point (lon/lat is ambigious for tracks crossing themselves?). And it would contain the complete junction geometry, including angles and priorities of all ways, just to make it easy to check the decision the algortithm makes.
Like this:
/* --turn-instructions-start
--turn TSLR at 25(8.608944/49.674370) next 630 follow 4(25)5 ignore (-15)4 (50)4
--turn-instructions-end */
makes sense?
Until now I did not find any software that refuses or fails with a track is using <sym>in trkpts.Even always supercritical Garmin software Mapsource, Basecamp => = not protesting ! 100% functional.The price to pay if using an ASSOCIATION sytem ? Very similar to the tcx system is:
And I need to put the transport type (foot/bike/car) somewhere. Could use the <trk><type> tag for that and put "ti:bike" in there? So that a parser has a marker that really the sym's are to interprete as turn-instructions.
Hi Arndt,<sym> in trkpt = KISS.<sym> in trkpt = Topografix gpx 1.0 and 1.1 norm does allow to do.Topografix advise. http://www.topografix.com/gpx_for_developers.aspTo keep the standard from fragmenting, we ask that you: Validate your GPX output.Use the GPX tags the way they were intended.Example:<sym>8197</sym> might be a convenient way for your application to store a Garmin waypoint symbol,but it defeats the purpose of a common format. Use <sym>Golf Course</sym> instead.
Hi Zossebart.What it sounds to me is please use a clear standard language text .A <sym> standard ? I do not see any in the Topografix norm.Probably the first who had some list with <sym> and Icons was Garmin.That list is preconfigured in a dropdown menu in many sofware's to choose from when editing.Using compatible software and (garmin) gps (should) understand and display the expected Icon.Garmin expression for "Left" sym is <Navaid, White/Red> Clear language ?If an Icon is not recognised (because not in the list) a Flag, or a dot is shown.By the way, in the Garmin tcx norm, Left is expressed by the PointType: <Left>So please use in <sym> a clear text that everyone understands even in simple notepad edit.Apps just need to pickup and understand that information transported in the <sym> text.Or best <sym> in English and <name><cmt><desc> free available for any (local) language.The demo list I prepared is no obligation only a suggestion.That list, a must for Brouter output ? No.., because that's up to Arndt to decide.
@all: I'd like to discuss the current behaviour when going straight (<15°) on a junction with equal-priorized ways. In this case, no voice hint is generated (intentional). I guess Arndt decided so in order to reduce unnecessary voice hints.
.........
Who is afraid of a too "talky" crazy phone gps on a bike ? I do.After the newest impressive "toy" is in use for a while, probably most of us ?Or how to present more available (future) information ?See attached pdf. Only a suggestion, a possibility..
@all: I'd like to discuss the current behaviour when going straight (<15°) on a junction with equal-priorized ways. In this case, no voice hint is generated (intentional). I guess Arndt decided so in order to reduce unnecessary voice hints.
I created some more testtracks in Locus yesterday and I found a situation where I might miss the right track because of a missing nav hint.
Am Montag, 25. April 2016 10:37:19 UTC+2 schrieb Zossebart:@all: I'd like to discuss the current behaviour when going straight (<15°) on a junction with equal-priorized ways. In this case, no voice hint is generated (intentional). I guess Arndt decided so in order to reduce unnecessary voice hints.
I created some more testtracks in Locus yesterday and I found a situation where I might miss the right track because of a missing nav hint.
well, yes, I did some work in exactly this direction. It includes using the keep-right/keep-left hint for such forges, and, even more important, a filter along the track summing up many turn into one hint. The keep-right/left logic also makes car instructions useful.
This is nasty stuff and full of heuristics, this is why it's not yet on a release quality level.
I got very valuable input from Volker, including a working Osmand format and logic to create real roundabout hints. I'm not done with the merge, but I want to provide you another patch-version so you can see the actual state:
http://brouter.de/brouter_bin/voice_patch3.zip
This also is a proposal for the interfacing problem: the profiles in that zip-file have turninstructionmode = 1 = auto, that means the format is choosen according to the waypoint-database in use.
For the call via the AIDL-interface I implementet a parameter "turnInstructionFormat" to select the format as part of the request. So that's a working solution for the interfacing problem: Locus and OsmAnd select their format and process the turn-instructions in their native formats.
I observed this for example at a zigzag where the middle part (between the two turns) was ca. 30m. I'm sure I wouldn't see this as "straight" in reality. Or is it difficult to "shorten" the filter, because then it wouldn't be possible to detect and announce roundabouts in just one instruction?
yes. The filter currently uses (hardcoded) 40m catching range. 40m seems to be the maximum e.g. for the length of the "oneway-triangles" that connect to roundabouts or other junctions. So to protect your zig-zag from being merged into a go-straight, it needs more then just reducing the catching range. It needs a better idea. But that makes knots in your brain, just as a warning...
Explicit hints for roundabouts are o.k. as well (with correct exit count...) but not enabled in this patch-version. This is because there's a nasty bug in Locus announcing them (Version 3.16.2.)
On Wednesday, April 27, 2016 at 7:42:09 PM UTC+2, abre...@googlemail.com wrote:Ok. Is this merging only needed for roundabout-handling, or do you plan to use it for other situations, too?
Because this algorithm only evaluates geometry and has no idea of the OSM tags associated with the ways (after all, it's intentional that only the profile-part works with the OSM-tags).
Explicit hints for roundabouts are o.k. as well (with correct exit count...) but not enabled in this patch-version. This is because there's a nasty bug in Locus announcing them (Version 3.16.2.)What's this bug exactly? Did you report it to the locus developers? Menion is fixing bugs really fast most of the time.
What about my questions about the interfacing? Should we start talking to the app developers about the changes needed, or is it too early?
sorry for yet another patch, but I think finally we can get the relase out.
I have noticed you have implemented new logical operators
like greater.
...
Are there more ?
The new one actually is "min". "greater" was around for longer, I should
become more consistent on that, i admit. If you have any more
on your wishlist, just tell me.
Just for consistency, I should add at least "lesser" and "xor" (exclusive or).