Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
state2camera.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) Roland
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
28 #include "subsystems/abi.h"
29 #include "state.h"
30 #include "mcu_periph/uart.h"
31 static int frame_number_sending = 0;
32 float lastKnownHeight = 0.0;
34 
35 #ifndef STATE2CAMERA_SEND_DATA_TYPE
36 #define STATE2CAMERA_SEND_DATA_TYPE 0
37 #endif
38 
40 {
41 #if STATE2CAMERA_SEND_DATA_TYPE == 0
42 
43  struct Int32RMat *ltp_to_body_mat = stateGetNedToBodyRMat_i();
44  static int32_t lengthArrayInformation = 11 * sizeof(int32_t);
45  uint8_t ar[lengthArrayInformation];
46  int32_t *pointer = (int32_t *) ar;
47  for (int indexRot = 0; indexRot < 9; indexRot++) {
48  pointer[indexRot] = ltp_to_body_mat->m[indexRot];
49  }
50  pointer[9] = (int32_t)(state.alt_agl_f * 100); //height above ground level in CM.
51  pointer[10] = frame_number_sending++;
52  stereoprot_sendArray(&((UART_LINK).device), ar, lengthArrayInformation, 1);
53 #endif
54 
55 #if STATE2CAMERA_SEND_DATA_TYPE == 1
56  static int16_t lengthArrayInformation = 6 * sizeof(int16_t);
57  uint8_t ar[lengthArrayInformation];
58  int16_t *pointer = (int16_t *) ar;
59  pointer[0] = (int16_t)(stateGetNedToBodyEulers_f()->theta*100);
60  pointer[1] = (int16_t)(stateGetNedToBodyEulers_f()->phi*100);
61  pointer[2] = (int16_t)(stateGetNedToBodyEulers_f()->psi*100);
62 
63  stereoprot_sendArray(&((UART_LINK).device), ar,lengthArrayInformation, 1);
64 
65 #endif
66 
67 }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
float phi
in radians
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1125
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
Definition: state.h:1101
int32_t m[3 *3]
Main include for ABI (AirBorneInterface).
float psi
in radians
standard protocol for TUDelft stereocamera data transfer
void stereoprot_sendArray(struct link_device *fd, uint8_t *b, uint8_t array_width, uint8_t array_height)
float theta
in radians
signed short int16_t
Definition: types.h:17
void write_serial_rot()
Definition: state2camera.c:39
signed long int32_t
Definition: types.h:19
float alt_agl_f
Altitude above ground level.
Definition: state.h:198
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
float lastKnownHeight
Definition: state2camera.c:32
int pleaseResetOdroid
Definition: state2camera.c:33
rotation matrix
static int frame_number_sending
Definition: state2camera.c:31
struct State state
Definition: state.c:36