83 float local_psi = 0.0f;
89 float K[9] = {cam_intrinsics.focal_x, 0.0f, cam_intrinsics.center_x,
90 0.0f, cam_intrinsics.focal_y, cam_intrinsics.center_y,
95 struct FloatVect3 gate_vectors[4], vec_B, vec_E, p_vec, temp_vec;
117 printf(
"Undistortion not possible in PnPAHRS.c... why?\n");
118 return pos_drone_E_vec;
121 gate_vectors[i].
x = 1.0;
122 gate_vectors[i].
y = y_n;
123 gate_vectors[i].
z = -x_n;
132 printf(
"Determine world vector for corner %d\n", i);
133 printf(
"Distorted coordinates: (x,y) = (%d, %d)\n", x_corners[i], y_corners[i]);
134 printf(
"Normalized coordinates: (x_n, y_n) = (%f, %f)\n", x_n, y_n);
135 printf(
"Gate vector: (%f,%f,%f)\n", gate_vectors[i].x, gate_vectors[i].y, gate_vectors[i].z);
136 printf(
"Gate vector to Body: (%f,%f,%f)\n", vec_B.
x, vec_B.
y, vec_B.
z);
137 printf(
"Gate vector to World: (%f,%f,%f)\n", vec_E.
x, vec_E.
y, vec_E.
z);
154 #if CAMERA_ROTATED_90DEG_RIGHT
156 float temp = pos_drone_E_vec.
y;
157 pos_drone_E_vec.
y = -pos_drone_E_vec.
z;
158 pos_drone_E_vec.
z = -temp;
162 float y_threshold = 4;
163 if (pos_drone_E_vec.
y > y_threshold) { pos_drone_E_vec.
y = y_threshold; }
164 else if (pos_drone_E_vec.
y < -y_threshold) { pos_drone_E_vec.
y = -y_threshold; }
166 return pos_drone_E_vec;
struct FloatVect3 get_world_position_from_image_points(int *x_corners, int *y_corners, struct FloatVect3 *world_corners, int n_corners, struct camera_intrinsics_t cam_intrinsics, struct FloatEulers cam_body)
Get the world position of the camera, given image coordinates and corresponding world coordinates.
Functions for solving a perspective-n-point problem, using the AHRS to get the relevant angles.
struct FloatVect3 world_corners[4]
struct FloatEulers cam_body
void float_rmat_of_eulers_321(struct FloatRMat *rm, struct FloatEulers *e)
Rotation matrix from 321 Euler angles (float).
#define FLOAT_VECT3_ZERO(_v)
#define FLOAT_MAT33_DIAG(_m, _d00, _d11, _d22)
#define FLOAT_MAT33_ZERO(_m)
#define VECT3_SUM(_c, _a, _b)
#define VECT3_VECT3_TRANS_MUL(_mat, _v_a, _v_b)
#define VECT3_SDIV(_vo, _vi, _s)
#define MAT33_VECT3_MUL(_vout, _mat, _vin)
#define MAT33_MAT33_SUM(_mat1, _mat2, _mat3)
#define MAT33_INV(_minv, _m)
#define MAT33_TRANS(_mat1, _mat2)
#define MAT33_COPY(_mat1, _mat2)
#define MAT33_MAT33_DIFF(_mat1, _mat2, _mat3)
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
API to get/set the generic vehicle states.
bool distorted_pixels_to_normalized_coords(float x_pd, float y_pd, float *x_n, float *y_n, float k, const float *K)
Transform distorted pixel coordinates to normalized coordinates.