How Can I Get the Color of a Road Marking?
Question
In the Scenario Editor, there is the possibility of changing the color of a road marking. For instance, one can change the color to yellow to indicate construction site lanes. Using the Line Sensor, there is a quantity available called < preQ >.ColorCode but the output is not like expected. How can I get the RGB color code of the configured color during the simulation?
Solution
For clarification, the quantity < preQ >.ColorCode does indeed not represent the color of the road marking. This ColorCode rather represents a user defined ID which can be specified for each road marking in the Scenario Editor. Like this it would be much easier to identify specific road markings e.g. yellow lines with User ID = 1, if this was configured during the scenario creation.
Since this is not suitable for huge road networks and digitized road formats like OpenDRIVE, you can read the RGB value of each road marking via the IPGRoad API in c-code. Here is a code snippet, which can be included in the User.c file:
tRoadMaterial material;
memset(&material, 0, sizeof(tRoadMaterial));
RoadObjectGetMaterial(Env.Road, DetectedLine.id, 0, &material);
Log("RGB Color is %s\n", material.file);
Please Note:
- The headers road.h and roadbuilder.h must be included in the User.c file
- The DetectedLine.id has to be the global ID of the road marking (Scenario Editor: value in parentheses of each element in the Object List)
- This code snippet can also be used to get the name of the material, if this was specified instead of a color
Output of RoadObjectGetMaterial() is the RGB code as a string and looks for yellow like this: 1.0000,1.0000,0.0000
According to the definition in the Scenario Editor a value 1.0 means 255. Depending on what exactly you need for further processing, you would have to split the string, convert the data type, and may convert it to a range of 0 to 255.
For further information, please have a look in the CarMaker documentation under Help > Additional Documents >IPGRoad Infofile Description and IPGRoad API Reference. Of course you can even look into the header files road.h and roadbuilder.h in the CarMaker installation directory.
- Date: 03.05.2021
- Product: CarMaker
- Version: 10.0
- Component: C-Code Interface
- Language: English
Tags
RoadLine Sensor
Scenario Editor