ClementPinard / SfmLearner-Pytorch

Pytorch version of SfmLearner from Tinghui Zhou et al.
MIT License
1.01k stars 224 forks source link

Question about using oxts data #137

Closed myalos closed 1 year ago

myalos commented 2 years ago

Thanks for great work!

if scale is None:
    scale = np.cos(lat * np.pi / 180.)

pose_matrix = pose_from_oxts_packet(metadata[:6], scale)
if origin is None:
    origin = pose_matrix
odo_pose = imu2cam @ np.linalg.inv(origin) @ pose_matrix @ np.linalg.inv(imu2cam)

I am curious about this part of the code which is not shown in the original sfmlearner. Could you tell me how this works(about math detail),or what book or reference should i read. Concretely

  1. what is the effect of the scale
  2. why ty = lat np.pi er / 180. different from the original implementation in https://github.com/utiasSTARS/pykitti
  3. the math detail about the transformation from (lat lon alt) to translation
  4. pose_matrix convert ? coordinate system to ? coordinate system,the effect of np.linalg.inv(origin) @ pose_matrix
ClementPinard commented 1 year ago

Hello,

sorry for answering so late, it went under my radar, don't know if the question is still relevant, but anyway here's a quick answer :

scale is here to convert GPS coordinates in XYZ data. This is actually what is done when converting spherical coordinates to cartesian : https://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates (see last formula)

As such, a change in longitude results in a much smaller translation when you are close to the poles.

See the difference between pyKITTI and this repo right here : https://github.com/ClementPinard/SfmLearner-Pytorch/blob/9640fbb2157be78e3eb195287ed76ac797282113/data/kitti_util.py#L70

(Line 70 vs line 71)

Why is it different from pyKITTI ? Because they use the mercantor projection, which takes care of scale directly.

See an Issue I made in pyKitti about this problem : https://github.com/utiasSTARS/pykitti/issues/24

Basically, I think the Sinusoidal projection is doing a good job and is immensively simpler than mercator. Additionnally, it keeps better track of distances between point when the latitude is changing. The thing it doesn't do is keep track ofr the angle, which we don't really care about, as we are focused on distance.

https://en.wikipedia.org/wiki/Sinusoidal_projection

I have yet to make an elaborate argumentation to defend my POV, but since germany is not that close to the pole, it doesn't really matter.