I'm writing a path-following application for my robot for 2D navigation and the path is contained in a DWG file. Let's say, for example, that the DWG file contains a 2x2 meters square.
I would like to open the DWG file, find out the lines and get some coordinates to use as waypoints for my robot.
At the moment, it would be perfect for me to find out a way to just read the coordinates from the DWG file. I saw that there are some open-source libraries that allow to handle DWG files, like libredwg or libDWG, but i can't understand if they can be used for my purpose.
Can you help me, please?
EDIT: I found that libopencad can be used for my application, I tested the sample application and it outputs something like this:
Layers count: 1
1. Layer 0 contains 8 geometries
|---------Line---------|
Start Position: 62.5852 -36.5942 0
End Position: -62.5852 -36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -36.5942 0
End Position: 62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 36.5942 0
End Position: -62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: -62.5852 -36.5942 0
End Position: -62.5852 36.5942 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -76.4212 0
End Position: -62.5852 -76.4212 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -76.4212 0
End Position: 62.5852 -61.4214 0
Entity color: #ffffffff
|---------Line---------|
Start Position: 62.5852 -61.4214 0
End Position: -62.5852 -61.4214 0
Entity color: #ffffffff
|---------Line---------|
Start Position: -62.5852 -76.4212 0
End Position: -62.5852 -61.4214 0
Entity color: #ffffffff
for a sample DWG file that contains two squares:
The problem is: how can I separate the coordinates of the first rectangle from the second one?