How to acquire the length of each links of a road network?
Question
How can I acquire the length of each link (not network length) of a road network?
I didn’t find the right quantities for this information from Ehoritzon.h, Sensor_Road.h. Then I tried to extract the information from the road-infofile.
For the segments ‘straight’, ‘turn’ or ‘clothoid’ the link length is easy to extract. But for segments ‘pointlist’ or ‘connect’ the length is not easy to extract e.g. because the parameter of pointlist in infofile is not a length, but an End direction vector.
So how can we acquire the length of each link?
Solution
The length of each link can be extracted by using the RoadAPI. The length of a link is part of the struct tRoadLinkInfo.
For further information, you can check the headerfile road.h and also the RoadAPI-documentation you can find in the installation folder>doc since CarMaker 8.
I have built a small example code to include in User.c > User_TestRun_Start_atEnd() that you can find below.
Additionally you also need to include the road.h at the top of User.c
I have tested the code in CarMaker 8.0.2
You can also check the screenshot from the SessionLog below:
In this example, the length of each link is simply written into the Session Log, but you can extend the code as you wish.
- Date: 12.09.2019
- Product: CarMaker
- Version: 8.0
- Component: C-Code Interface
- Language: English
Tags
RoadAPIrd5
C-Code