LI3DS / api-li3ds

LI³DS Rest API
GNU General Public License v3.0
0 stars 3 forks source link

Displaying trajectory lines in QGIS #56

Closed elemoine closed 7 years ago

elemoine commented 7 years ago

With https://github.com/LI3DS/api-li3ds/pull/55 merged I am trying to verify the trajectory transfo (ins<->world). For this I created this PostGIS table:

create table traj_eric as
select row_number() over () id
     , st_setsrid(st_makeline(st_makepoint(point_a[1], point_a[2], point_a[3]),
                              st_makepoint(point_b[1], point_b[2], point_b[3])), 2154) line
  from (
        select li3ds.transform(array[0, 0, 0], 2, pc_get(pc_pointn(points, 50), 'time')) point_a
             , li3ds.transform(array[2, 0, 0], 2, pc_get(pc_pointn(points, 50), 'time')) point_b
        from "LANDINS_20170516_075157_PP_view"
       ) t;

This query creates lines with just two vertices. The line is (0 0 0,2 0 0) in INS coordinates, and it is transformed into the world referential for display.

The issue is that I only get vertical lines in QGIS. I am trying to debug this, with no luck for the moment.

trajectory-lines

I need another pair of eyes on this.

elemoine commented 7 years ago

I reverted #55 on my local setup and the trajectory looks like this:

trajectory-lines-2

It's not correct either but at least the heading angle changes along the trajectory. This suggests to me that the new way of calculating the quaternion is wrong.

elemoine commented 7 years ago

https://github.com/LI3DS/api-li3ds/pull/57 fixes a bug where theta1 and theta3 were exchanged. It also removes the heading correction. With both changes the trajectory looks like this:

sbet-trajectory-2

That looks much better!

If I keep the heading correction I get this:

trajectory-lines-3

So I am going to merge #57 and drop the heading correction for now, until we understand why it does not work.

elemoine commented 7 years ago

Reopening… Let's discuss why the heading correction causes issues.

mbredif commented 7 years ago

You are currently imaging the X axis of the INS using "(0 0 0,2 0 0) in INS coordinates". can you try transforming and imaging the Y and Z axes as well with different colors to ease the debugging ?

elemoine commented 7 years ago

I will do that tomorrow. I will add the heading correction again and will display (2 0 0), (0 2 0) and (0 0 2) with different colors.

elemoine commented 7 years ago

@mbredif

With the heading correction:

qgis 2 18 12_002

line_y is the one tangent to the trajectory. line_x is orthogonal (or close to orthogonal) to the trajectory.

Without the heading correction:

qgis 2 18 12 - li3ds-test_003

It's the opposite. line_x is tangent to the trajectory, and line_y is orthogonal to the trajectory.

And contrary to "with the heading correction", line_x and line_y are really tangent and orthogonal to the trajectory, respectively. With the heading correction, there's a small angle.

The SQL query to create the table:

create table trajectory_axis as
select row_number()
  over () id
     , st_setsrid(st_makeline(st_makepoint(point_0[1], point_0[2], point_0[3]), st_makepoint(point_x[1], point_x[2], point_x[3])), 2154) line_x
     , st_setsrid(st_makeline(st_makepoint(point_0[1], point_0[2], point_0[3]), st_makepoint(point_y[1], point_y[2], point_y[3])), 2154) line_y
     , st_setsrid(st_makeline(st_makepoint(point_0[1], point_0[2], point_0[3]), st_makepoint(point_z[1], point_z[2], point_z[3])), 2154) line_z
  from (
        select li3ds.Transform(array[0, 0, 0], 2, pc_get(pc_pointn(points, 50), 'time')) point_0
             , li3ds.transform(array[2, 0, 0], 2, pc_get(pc_pointn(points, 50), 'time')) point_x
             , li3ds.transform(array[0, 2, 0], 2, pc_get(pc_pointn(points, 50), 'time')) point_y
             , li3ds.transform(array[0, 0, 2], 2, pc_get(pc_pointn(points, 50), 'time')) point_z
  from "LANDINS_20170516_075157_PP_view"
       ) t;
elemoine commented 7 years ago

Now using the angles provided by Julien N-Haridon.

Without the heading correction:

qgis 2 18 12 - li3ds-test_004

line_x is still tangent to the trajectory, and line_y is still orthogonal to the trajectory, as previously without the heading correction. But line_y goes in the other direction!

With the heading correction:

qgis 2 18 12 - li3ds-test_005

line_y is tangent to the trajectory, and line_x is orthogonal to the trajectory, as previously with the heading correction. But again, line_x goes in the other direction.

So with Julien's angles we get different results, but it looks like there's still something wrong with the heading correction.

@mbredif, thoughts?

mbredif commented 7 years ago

Sorry, I lost track of which branches are doing/not doing heading correction. Can you point me to both ?

elemoine commented 7 years ago

Maybe I just need to convert the heading correction into radians???

radians(0.72537437089 * (pc_get(point, 'x') - 0.0523598775598))
mbredif commented 7 years ago

if so, my guess is 0.72537437089 * (radians(pc_get(point, 'x')) - 0.0523598775598)

elemoine commented 7 years ago

Yep, that was my final conclusion too. I'll test this.