maliput / maliput_integration

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unable to pass in negative values to mqliput_query #86

Closed liangfok closed 3 years ago

liangfok commented 3 years ago

I tried using maliput_query FindRoadPositions but the input (x, y, z) location contains a negative value. This resulted in the command line argument parser thinking the negative value was a flag:

$ maliput_query FindRoadPositions 1.48988388 -64.47806602 0.0 2  -maliput_backend=malidrive --xodr_file_path=Figure8.xodr 
ERROR: unknown command line flag '64.47806602'

How do I pass in a location with a negative value?

francocipollone commented 3 years ago

You are right. gflags understands that -64.47806602 is a flag because of the dash. I am checking how to workaround it.

francocipollone commented 3 years ago

~There is no way to scape to gflag parsing when using - as prefix.~ I tried calling gflags::AllowCommandLineReparsing(); to avoid throwing error when no matching glfag is found and let this argument be parsed afterwards however it seems that gflags doesn't throw in that occasion but it removes the "-64.478..." argument.

I think that we should standardize the use of flags and use only gflags instead of mixing gflags with argv[] raw use.

we probably can add a gflag called --query and so as we can do:

maliput_query  --maliput_backend=malidrive --xodr_file_path=Figure8.xodr --query="FindRoadPositions 1.48988388 -64.47806602 0.0 2 "

What do you think? CC:@agalbachicar

francocipollone commented 3 years ago

There is one workaround to it. (I'd tried with three hyphens, not two :cry: )

maliput_query --maliput_backend=malidrive --xodr_file_path=Figure8.xodr -- FindRoadPositions 1.48988388 -64.47806602 0.0 2

After the -- glfags won't parse the arguments. @liangfok


maliput_query --maliput_backend=malidrive --xodr_file_path=Figure8.xodr -- FindRoadPositions 1.48988388 -64.47806602 0.0 2
[INFO] Loading road network using malidrive backend implementation...
[INFO] RoadNetwork loaded successfully.
Geometry Loaded
FindRoadPositions(inertial_position:(x = 1.48988, y = -64.4781, z = 0), radius: 2)
              : Result: (road_pos:(lane: 1_0_-4, lane_pos: (s = 35.3, r = 3.885, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_-3, lane_pos: (s = 35.3, r = 2.5675, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_-2, lane_pos: (s = 35.3, r = 2, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_-1, lane_pos: (s = 35.3, r = 2.91315e-10, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_1, lane_pos: (s = 35.3, r = -3.5, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_2, lane_pos: (s = 35.3, r = -5.5, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_3, lane_pos: (s = 35.3, r = -6.0675, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)
              : Result: (road_pos:(lane: 1_0_4, lane_pos: (s = 35.3, r = -7.385, h = 0)), nearest_pos: (x = 1.48988, y = -64.4781, z = 0), distance: 4.26331e-14)

So we have two options:

liangfok commented 3 years ago

Nice! Option A unblocks me. Thank you.

Standardizing on gflags sounds reasonable, though I don't know all of the implications in terms of whether having gflags as a dependency will make it more difficult for others to integrate maliput_query into their development workspaces and workflows.