Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
state.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2012 Felix Ruess <felix.ruess@gmail.com>
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  */
20 
31 #ifndef STATE_H
32 #define STATE_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include "math/pprz_algebra_int.h"
40 #include "math/pprz_geodetic_int.h"
43 
44 #include "std.h"
45 #include <string.h>
46 
71 #define POS_ECEF_I 0
72 #define POS_NED_I 1
73 #define POS_ENU_I 2
74 #define POS_LLA_I 3
75 #define POS_UTM_I 4
76 #define POS_ECEF_F 5
77 #define POS_NED_F 6
78 #define POS_ENU_F 7
79 #define POS_LLA_F 8
80 #define POS_UTM_F 9
81 #define POS_LOCAL_COORD ((1<<POS_NED_I)|(1<<POS_NED_F)|(1<<POS_ENU_I)|(1<<POS_ENU_F))
82 #define POS_GLOBAL_COORD ((1<<POS_ECEF_I)|(1<<POS_ECEF_F)|(1<<POS_LLA_I)|(1<<POS_LLA_F)|(1<<POS_UTM_I)|(1<<POS_UTM_F))
89 #define SPEED_ECEF_I 0
90 #define SPEED_NED_I 1
91 #define SPEED_ENU_I 2
92 #define SPEED_HNORM_I 3
93 #define SPEED_HDIR_I 4
94 #define SPEED_ECEF_F 5
95 #define SPEED_NED_F 6
96 #define SPEED_ENU_F 7
97 #define SPEED_HNORM_F 8
98 #define SPEED_HDIR_F 9
99 #define SPEED_LOCAL_COORD ((1<<SPEED_NED_I)|(1<<SPEED_ENU_I)|(1<<SPEED_NED_F)|(1<<SPEED_ENU_F))
106 #define ACCEL_ECEF_I 0
107 #define ACCEL_NED_I 1
108 #define ACCEL_ECEF_F 2
109 #define ACCEL_NED_F 3
116 #define RATE_I 0
117 #define RATE_F 1
124 #define WINDSPEED_I 0
125 #define DOWNWIND_I 1
126 #define AIRSPEED_I 2
127 #define WINDSPEED_F 3
128 #define DOWNWIND_F 4
129 #define AIRSPEED_F 5
130 #define AOA_F 6
131 #define SIDESLIP_F 7
138 #define STATE_INPUT_DISABLE 0
139 #define STATE_INPUT_ANY 0xFFFF
140 #define STATE_INPUT_ORIGIN 1
141 #define STATE_INPUT_POS 2
142 #define STATE_INPUT_SPEED 3
143 #define STATE_INPUT_ACCEL 4
144 #define STATE_INPUT_ATTITUDE 5
145 #define STATE_INPUT_RATES 6
146 #define STATE_INPUT_WIND_AIR 7
152 struct State {
153 
161 
168 
173 
178  struct EcefCoor_i ecef_pos_i;
179 
185  struct LlaCoor_i lla_pos_i;
186 
194  struct LtpDef_i ned_origin_i;
195 
200 
206  struct NedCoor_i ned_pos_i;
207 
213  struct EnuCoor_i enu_pos_i;
214 
220  struct UtmCoor_f utm_pos_f;
221 
226  float alt_agl_f;
227 
233  struct LlaCoor_f lla_pos_f;
234 
239  struct EcefCoor_f ecef_pos_f;
240 
248  struct LtpDef_f ned_origin_f;
249 
252 
261  struct UtmCoor_f utm_origin_f;
262 
265 
271  struct NedCoor_f ned_pos_f;
272 
278  struct EnuCoor_f enu_pos_f;
290 
295 
300  struct EcefCoor_i ecef_speed_i;
301 
306  struct NedCoor_i ned_speed_i;
307 
312  struct EnuCoor_i enu_speed_i;
313 
319 
326 
331  struct EcefCoor_f ecef_speed_f;
332 
336  struct NedCoor_f ned_speed_f;
337 
342  struct EnuCoor_f enu_speed_f;
343 
349 
366 
371 
376  struct Int32Vect3 body_accel_i;
377 
382  struct NedCoor_i ned_accel_i;
383 
388  struct EcefCoor_i ecef_accel_i;
389 
394  struct NedCoor_f ned_accel_f;
395 
400  struct EcefCoor_f ecef_accel_f;
407 
412 
413 
422 
427 
432  struct Int32Rates body_rates_i;
433 
438  struct FloatRates body_rates_f;
450 
455 
460  union {
461  struct Int32Vect3 vect3;
462  struct Int32Vect2 vect2;
464 
470 
475  union {
476  struct FloatVect3 vect3;
477  struct FloatVect2 vect2;
479 
484  float airspeed_f;
485 
491 
496  float sideslip_f;
497 
500 };
501 
502 extern struct State state;
503 
504 extern void stateInit(void);
505 
510 extern void stateSetInputFilter(uint8_t type, uint16_t id);
511 
513 #define STATE_CHECK_INPUT_AND_RETURN(flag, id) if (flag==STATE_INPUT_DISABLE || !(flag==STATE_INPUT_ANY || flag==id)) { return; }
514 
519 static inline void stateSetLocalOrigin_i(uint16_t id, struct LtpDef_i *ltp_def)
520 {
522 
524  /* convert to float */
529 
530  /* clear bits for all local frame representations */
533  ClearBit(state.accel_status, ACCEL_NED_I);
534  ClearBit(state.accel_status, ACCEL_NED_F);
535 
536  state.ned_initialized_i = true;
537  state.ned_initialized_f = true;
538 }
539 
541 static inline void stateSetLocalUtmOrigin_f(uint16_t id, struct UtmCoor_f *utm_def)
542 {
544 
545  state.utm_origin_f = *utm_def;
546  state.utm_initialized_f = true;
547 
548  /* clear bits for all local frame representations */
551  ClearBit(state.accel_status, ACCEL_NED_I);
552  ClearBit(state.accel_status, ACCEL_NED_F);
553 }
554 
556 static inline struct LtpDef_i *stateGetNedOrigin_i(void)
557 {
558  if (state.ned_initialized_i) {
559  return &state.ned_origin_i;
560  } else {
561  return NULL;
562  }
563 }
564 
566 static inline struct LtpDef_f *stateGetNedOrigin_f(void)
567 {
568  if (state.ned_initialized_f) {
569  return &state.ned_origin_f;
570  } else {
571  return NULL;
572  }
573 }
574 
576 static inline struct UtmCoor_f *stateGetUtmOrigin_f(void)
577 {
578  if (state.utm_initialized_f) {
579  return &state.utm_origin_f;
580  } else {
581  return NULL;
582  }
583 }
584 
585 /************* declaration of origin accessor function ************/
586 extern struct LlaCoor_i stateGetLlaOrigin_i(void);
587 extern struct LlaCoor_f stateGetLlaOrigin_f(void);
588 extern struct EcefCoor_i stateGetEcefOrigin_i(void);
589 extern struct EcefCoor_f stateGetEcefOrigin_f(void);
590 extern int32_t stateGetHmslOrigin_i(void);
591 extern float stateGetHmslOrigin_f(void);
592 
593 /*******************************************************************************
594  * *
595  * Set and Get functions for the POSITION representations *
596  * *
597  ******************************************************************************/
598 
599 /************* declaration of transformation functions ************/
600 extern void stateCalcPositionEcef_i(void);
601 extern void stateCalcPositionNed_i(void);
602 extern void stateCalcPositionEnu_i(void);
603 extern void stateCalcPositionLla_i(void);
604 extern void stateCalcPositionUtm_f(void);
605 extern void stateCalcPositionEcef_f(void);
606 extern void stateCalcPositionNed_f(void);
607 extern void stateCalcPositionEnu_f(void);
608 extern void stateCalcPositionLla_f(void);
609 
610 /*********************** validity test functions ******************/
611 
613 static inline bool stateIsLocalCoordinateValid(void)
614 {
616  && (state.pos_status & (POS_LOCAL_COORD)));
617 }
618 
620 static inline bool stateIsGlobalCoordinateValid(void)
621 {
623 }
624 
625 /************************ Set functions ****************************/
626 
628 static inline void stateSetPositionEcef_i(uint16_t id, struct EcefCoor_i *ecef_pos)
629 {
631 
632  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
633  /* clear bits for all position representations and only set the new one */
634  state.pos_status = (1 << POS_ECEF_I);
635 }
636 
638 static inline void stateSetPositionNed_i(uint16_t id, struct NedCoor_i *ned_pos)
639 {
641 
642  VECT3_COPY(state.ned_pos_i, *ned_pos);
643  /* clear bits for all position representations and only set the new one */
644  state.pos_status = (1 << POS_NED_I);
645 }
646 
648 static inline void stateSetPositionEnu_i(uint16_t id, struct EnuCoor_i *enu_pos)
649 {
651 
652  VECT3_COPY(state.enu_pos_i, *enu_pos);
653  /* clear bits for all position representations and only set the new one */
654  state.pos_status = (1 << POS_ENU_I);
655 }
656 
658 static inline void stateSetPositionLla_i(uint16_t id, struct LlaCoor_i *lla_pos)
659 {
661 
662  LLA_COPY(state.lla_pos_i, *lla_pos);
663  /* clear bits for all position representations and only set the new one */
664  state.pos_status = (1 << POS_LLA_I);
665 }
666 
668 static inline void stateSetPosition_i(
669  uint16_t id,
670  struct EcefCoor_i *ecef_pos,
671  struct NedCoor_i *ned_pos,
672  struct EnuCoor_i *enu_pos,
673  struct LlaCoor_i *lla_pos)
674 {
676 
677  /* clear all status bit */
678  state.pos_status = 0;
679  if (ecef_pos != NULL) {
680  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
681  state.pos_status |= (1 << POS_ECEF_I);
682  }
683  if (ned_pos != NULL) {
684  VECT3_COPY(state.ned_pos_i, *ned_pos);
685  state.pos_status |= (1 << POS_NED_I);
686  }
687  if (enu_pos != NULL) {
688  VECT3_COPY(state.enu_pos_i, *enu_pos);
689  state.pos_status |= (1 << POS_ENU_I);
690  }
691  if (lla_pos != NULL) {
692  LLA_COPY(state.lla_pos_i, *lla_pos);
693  state.pos_status |= (1 << POS_LLA_I);
694  }
695 }
696 
698 static inline void stateSetPositionUtm_f(uint16_t id, struct UtmCoor_f *utm_pos)
699 {
701 
702  state.utm_pos_f = *utm_pos;
703  /* clear bits for all position representations and only set the new one */
704  state.pos_status = (1 << POS_UTM_F);
705 }
706 
708 static inline void stateSetPositionEcef_f(uint16_t id, struct EcefCoor_f *ecef_pos)
709 {
711 
712  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
713  /* clear bits for all position representations and only set the new one */
714  state.pos_status = (1 << POS_ECEF_F);
715 }
716 
718 static inline void stateSetPositionNed_f(uint16_t id, struct NedCoor_f *ned_pos)
719 {
721 
722  VECT3_COPY(state.ned_pos_f, *ned_pos);
723  /* clear bits for all position representations and only set the new one */
724  state.pos_status = (1 << POS_NED_F);
725 }
726 
728 static inline void stateSetPositionEnu_f(uint16_t id, struct EnuCoor_f *enu_pos)
729 {
731 
732  VECT3_COPY(state.enu_pos_f, *enu_pos);
733  /* clear bits for all position representations and only set the new one */
734  state.pos_status = (1 << POS_ENU_F);
735 }
736 
738 static inline void stateSetPositionLla_f(uint16_t id, struct LlaCoor_f *lla_pos)
739 {
741 
742  LLA_COPY(state.lla_pos_f, *lla_pos);
743  /* clear bits for all position representations and only set the new one */
744  state.pos_status = (1 << POS_LLA_F);
745 }
746 
748 static inline void stateSetPosition_f(
749  uint16_t id,
750  struct EcefCoor_f *ecef_pos,
751  struct NedCoor_f *ned_pos,
752  struct EnuCoor_f *enu_pos,
753  struct LlaCoor_f *lla_pos,
754  struct UtmCoor_f *utm_pos)
755 {
757 
758  /* clear all status bit */
759  state.pos_status = 0;
760  if (ecef_pos != NULL) {
761  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
762  state.pos_status |= (1 << POS_ECEF_F);
763  }
764  if (ned_pos != NULL) {
765  VECT3_COPY(state.ned_pos_f, *ned_pos);
766  state.pos_status |= (1 << POS_NED_F);
767  }
768  if (enu_pos != NULL) {
769  VECT3_COPY(state.enu_pos_f, *enu_pos);
770  state.pos_status |= (1 << POS_ENU_F);
771  }
772  if (lla_pos != NULL) {
773  LLA_COPY(state.lla_pos_f, *lla_pos);
774  state.pos_status |= (1 << POS_LLA_F);
775  }
776  if (utm_pos != NULL) {
777  state.utm_pos_f = *utm_pos;
778  state.pos_status |= (1 << POS_UTM_F);
779  }
780 }
781 
782 /************************ Get functions ****************************/
783 
785 static inline struct EcefCoor_i *stateGetPositionEcef_i(void)
786 {
787  if (!bit_is_set(state.pos_status, POS_ECEF_I)) {
789  }
790  return &state.ecef_pos_i;
791 }
792 
794 static inline struct NedCoor_i *stateGetPositionNed_i(void)
795 {
796  if (!bit_is_set(state.pos_status, POS_NED_I)) {
798  }
799  return &state.ned_pos_i;
800 }
801 
803 static inline struct EnuCoor_i *stateGetPositionEnu_i(void)
804 {
805  if (!bit_is_set(state.pos_status, POS_ENU_I)) {
807  }
808  return &state.enu_pos_i;
809 }
810 
812 static inline struct LlaCoor_i *stateGetPositionLla_i(void)
813 {
814  if (!bit_is_set(state.pos_status, POS_LLA_I)) {
816  }
817  return &state.lla_pos_i;
818 }
819 
821 static inline struct UtmCoor_f *stateGetPositionUtm_f(void)
822 {
823  if (!bit_is_set(state.pos_status, POS_UTM_F)) {
825  }
826  return &state.utm_pos_f;
827 }
828 
830 static inline struct EcefCoor_f *stateGetPositionEcef_f(void)
831 {
832  if (!bit_is_set(state.pos_status, POS_ECEF_F)) {
834  }
835  return &state.ecef_pos_f;
836 }
837 
839 static inline struct NedCoor_f *stateGetPositionNed_f(void)
840 {
841  if (!bit_is_set(state.pos_status, POS_NED_F)) {
843  }
844  return &state.ned_pos_f;
845 }
846 
848 static inline struct EnuCoor_f *stateGetPositionEnu_f(void)
849 {
850  if (!bit_is_set(state.pos_status, POS_ENU_F)) {
852  }
853  return &state.enu_pos_f;
854 }
855 
857 static inline struct LlaCoor_f *stateGetPositionLla_f(void)
858 {
859  if (!bit_is_set(state.pos_status, POS_LLA_F)) {
861  }
862  return &state.lla_pos_f;
863 }
864 
869 /******************************************************************************
870  * *
871  * Set and Get functions for the SPEED representations *
872  * *
873  *****************************************************************************/
877 /************* declaration of transformation functions ************/
878 extern void stateCalcSpeedNed_i(void);
879 extern void stateCalcSpeedEnu_i(void);
880 extern void stateCalcSpeedEcef_i(void);
881 extern void stateCalcHorizontalSpeedNorm_i(void);
882 extern void stateCalcHorizontalSpeedDir_i(void);
883 extern void stateCalcSpeedNed_f(void);
884 extern void stateCalcSpeedEnu_f(void);
885 extern void stateCalcSpeedEcef_f(void);
886 extern void stateCalcHorizontalSpeedNorm_f(void);
887 extern void stateCalcHorizontalSpeedDir_f(void);
888 
889 /************************ Set functions ****************************/
890 
892 static inline void stateSetSpeedNed_i(uint16_t id, struct NedCoor_i *ned_speed)
893 {
895 
896  VECT3_COPY(state.ned_speed_i, *ned_speed);
897  /* clear bits for all speed representations and only set the new one */
898  state.speed_status = (1 << SPEED_NED_I);
899 }
900 
902 static inline void stateSetSpeedEnu_i(uint16_t id, struct EnuCoor_i *enu_speed)
903 {
905 
906  VECT3_COPY(state.enu_speed_i, *enu_speed);
907  /* clear bits for all speed representations and only set the new one */
908  state.speed_status = (1 << SPEED_ENU_I);
909 }
910 
912 static inline void stateSetSpeedEcef_i(uint16_t id, struct EcefCoor_i *ecef_speed)
913 {
915 
916  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
917  /* clear bits for all speed representations and only set the new one */
919 }
920 
922 static inline void stateSetSpeed_i(
923  uint16_t id,
924  struct EcefCoor_i *ecef_speed,
925  struct NedCoor_i *ned_speed,
926  struct EnuCoor_i *enu_speed)
927 {
929 
930  /* clear all status bit */
931  state.speed_status = 0;
932  if (ecef_speed != NULL) {
933  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
934  state.speed_status |= (1 << SPEED_ECEF_I);
935  }
936  if (ned_speed != NULL) {
937  VECT3_COPY(state.ned_speed_i, *ned_speed);
938  state.speed_status |= (1 << SPEED_NED_I);
939  }
940  if (enu_speed != NULL) {
941  VECT3_COPY(state.enu_speed_i, *enu_speed);
942  state.speed_status |= (1 << SPEED_ENU_I);
943  }
944 }
945 
947 static inline void stateSetSpeedNed_f(uint16_t id, struct NedCoor_f *ned_speed)
948 {
950 
951  VECT3_COPY(state.ned_speed_f, *ned_speed);
952  /* clear bits for all speed representations and only set the new one */
953  state.speed_status = (1 << SPEED_NED_F);
954 }
955 
957 static inline void stateSetSpeedEnu_f(uint16_t id, struct EnuCoor_f *enu_speed)
958 {
960 
961  VECT3_COPY(state.enu_speed_f, *enu_speed);
962  /* clear bits for all speed representations and only set the new one */
963  state.speed_status = (1 << SPEED_ENU_F);
964 }
965 
967 static inline void stateSetSpeedEcef_f(uint16_t id, struct EcefCoor_f *ecef_speed)
968 {
970 
971  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
972  /* clear bits for all speed representations and only set the new one */
974 }
975 
977 static inline void stateSetSpeed_f(
978  uint16_t id,
979  struct EcefCoor_f *ecef_speed,
980  struct NedCoor_f *ned_speed,
981  struct EnuCoor_f *enu_speed)
982 {
984 
985  /* clear all status bit */
986  state.speed_status = 0;
987  if (ecef_speed != NULL) {
988  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
989  state.speed_status |= (1 << SPEED_ECEF_F);
990  }
991  if (ned_speed != NULL) {
992  VECT3_COPY(state.ned_speed_f, *ned_speed);
993  state.speed_status |= (1 << SPEED_NED_F);
994  }
995  if (enu_speed != NULL) {
996  VECT3_COPY(state.enu_speed_f, *enu_speed);
997  state.speed_status |= (1 << SPEED_ENU_F);
998  }
999 }
1000 
1001 /************************ Get functions ****************************/
1002 
1004 static inline struct NedCoor_i *stateGetSpeedNed_i(void)
1005 {
1006  if (!bit_is_set(state.speed_status, SPEED_NED_I)) {
1008  }
1009  return &state.ned_speed_i;
1010 }
1011 
1013 static inline struct EnuCoor_i *stateGetSpeedEnu_i(void)
1014 {
1015  if (!bit_is_set(state.speed_status, SPEED_ENU_I)) {
1017  }
1018  return &state.enu_speed_i;
1019 }
1020 
1022 static inline struct EcefCoor_i *stateGetSpeedEcef_i(void)
1023 {
1024  if (!bit_is_set(state.speed_status, SPEED_ECEF_I)) {
1026  }
1027  return &state.ecef_speed_i;
1028 }
1029 
1032 {
1033  if (!bit_is_set(state.speed_status, SPEED_HNORM_I)) {
1035  }
1036  return state.h_speed_norm_i;
1037 }
1038 
1041 {
1042  if (!bit_is_set(state.speed_status, SPEED_HDIR_I)) {
1044  }
1045  return state.h_speed_dir_i;
1046 }
1047 
1049 static inline struct NedCoor_f *stateGetSpeedNed_f(void)
1050 {
1051  if (!bit_is_set(state.speed_status, SPEED_NED_F)) {
1053  }
1054  return &state.ned_speed_f;
1055 }
1056 
1058 static inline struct EnuCoor_f *stateGetSpeedEnu_f(void)
1059 {
1060  if (!bit_is_set(state.speed_status, SPEED_ENU_F)) {
1062  }
1063  return &state.enu_speed_f;
1064 }
1065 
1067 static inline struct EcefCoor_f *stateGetSpeedEcef_f(void)
1068 {
1069  if (!bit_is_set(state.speed_status, SPEED_ECEF_F)) {
1071  }
1072  return &state.ecef_speed_f;
1073 }
1074 
1076 static inline float stateGetHorizontalSpeedNorm_f(void)
1077 {
1078  if (!bit_is_set(state.speed_status, SPEED_HNORM_F)) {
1080  }
1081  return state.h_speed_norm_f;
1082 }
1083 
1085 static inline float stateGetHorizontalSpeedDir_f(void)
1086 {
1087  if (!bit_is_set(state.speed_status, SPEED_HDIR_F)) {
1089  }
1090  return state.h_speed_dir_f;
1091 }
1092 
1094 static inline struct Int32Vect3 *stateGetAccelBody_i(void)
1095 {
1096  return &state.body_accel_i;
1097 }
1102 /******************************************************************************
1103  * *
1104  * Set and Get functions for the ACCELERATION representations *
1105  * *
1106  *****************************************************************************/
1110 /************* declaration of transformation functions ************/
1111 extern void stateCalcAccelNed_i(void);
1112 extern void stateCalcAccelEcef_i(void);
1113 extern void stateCalcAccelNed_f(void);
1114 extern void stateCalcAccelEcef_f(void);
1115 
1116 /*********************** validity test functions ******************/
1117 
1119 static inline bool stateIsAccelValid(void)
1120 {
1121  return (state.accel_status);
1122 }
1123 
1124 /************************ Set functions ****************************/
1125 
1127 static inline void stateSetAccelNed_i(uint16_t id, struct NedCoor_i *ned_accel)
1128 {
1130 
1131  VECT3_COPY(state.ned_accel_i, *ned_accel);
1132  /* clear bits for all accel representations and only set the new one */
1133  state.accel_status = (1 << ACCEL_NED_I);
1134 }
1135 
1137 static inline void stateSetAccelEcef_i(uint16_t id, struct EcefCoor_i *ecef_accel)
1138 {
1140 
1141  VECT3_COPY(state.ecef_accel_i, *ecef_accel);
1142  /* clear bits for all accel representations and only set the new one */
1143  state.accel_status = (1 << ACCEL_ECEF_I);
1144 }
1145 
1147 static inline void stateSetAccelNed_f(uint16_t id, struct NedCoor_f *ned_accel)
1148 {
1150 
1151  VECT3_COPY(state.ned_accel_f, *ned_accel);
1152  /* clear bits for all accel representations and only set the new one */
1153  state.accel_status = (1 << ACCEL_NED_F);
1154 }
1155 
1157 static inline void stateSetAccelEcef_f(uint16_t id, struct EcefCoor_f *ecef_accel)
1158 {
1160 
1161  VECT3_COPY(state.ecef_accel_f, *ecef_accel);
1162  /* clear bits for all accel representations and only set the new one */
1163  state.accel_status = (1 << ACCEL_ECEF_F);
1164 }
1165 
1167 static inline void stateSetAccelBody_i(uint16_t id, struct Int32Vect3 *body_accel)
1168 {
1170 
1171  VECT3_COPY(state.body_accel_i, *body_accel);
1172 }
1173 
1174 /************************ Get functions ****************************/
1175 
1177 static inline struct NedCoor_i *stateGetAccelNed_i(void)
1178 {
1179  if (!bit_is_set(state.accel_status, ACCEL_NED_I)) {
1181  }
1182  return &state.ned_accel_i;
1183 }
1184 
1186 static inline struct EcefCoor_i *stateGetAccelEcef_i(void)
1187 {
1188  if (!bit_is_set(state.accel_status, ACCEL_ECEF_I)) {
1190  }
1191  return &state.ecef_accel_i;
1192 }
1193 
1195 static inline struct NedCoor_f *stateGetAccelNed_f(void)
1196 {
1197  if (!bit_is_set(state.accel_status, ACCEL_NED_F)) {
1199  }
1200  return &state.ned_accel_f;
1201 }
1202 
1204 static inline struct EcefCoor_f *stateGetAccelEcef_f(void)
1205 {
1206  if (!bit_is_set(state.accel_status, ACCEL_ECEF_F)) {
1208  }
1209  return &state.ecef_accel_f;
1210 }
1213 /******************************************************************************
1214 * *
1215 * Set and Get functions for the ATTITUDE representations *
1216 * (Calls the functions in math/pprz_orientation_conversion) *
1217 * *
1218 *****************************************************************************/
1221 /*********************** validity test functions ******************/
1222 
1224 static inline bool stateIsAttitudeValid(void)
1225 {
1227 }
1228 
1229 /************************ Set functions ****************************/
1230 
1232 static inline void stateSetNedToBodyQuat_i(uint16_t id, struct Int32Quat *ned_to_body_quat)
1233 {
1236 }
1237 
1239 static inline void stateSetNedToBodyRMat_i(uint16_t id, struct Int32RMat *ned_to_body_rmat)
1240 {
1243 }
1244 
1246 static inline void stateSetNedToBodyEulers_i(uint16_t id, struct Int32Eulers *ned_to_body_eulers)
1247 {
1250 }
1251 
1253 static inline void stateSetNedToBodyQuat_f(uint16_t id, struct FloatQuat *ned_to_body_quat)
1254 {
1257 }
1258 
1260 static inline void stateSetNedToBodyRMat_f(uint16_t id, struct FloatRMat *ned_to_body_rmat)
1261 {
1264 }
1265 
1267 static inline void stateSetNedToBodyEulers_f(uint16_t id, struct FloatEulers *ned_to_body_eulers)
1268 {
1271 }
1272 
1273 /************************ Get functions ****************************/
1274 
1276 static inline struct Int32Quat *stateGetNedToBodyQuat_i(void)
1277 {
1279 }
1280 
1282 static inline struct Int32RMat *stateGetNedToBodyRMat_i(void)
1283 {
1285 }
1286 
1288 static inline struct Int32Eulers *stateGetNedToBodyEulers_i(void)
1289 {
1291 }
1292 
1294 static inline struct FloatQuat *stateGetNedToBodyQuat_f(void)
1295 {
1297 }
1298 
1300 static inline struct FloatRMat *stateGetNedToBodyRMat_f(void)
1301 {
1303 }
1304 
1306 static inline struct FloatEulers *stateGetNedToBodyEulers_f(void)
1307 {
1309 }
1313 /******************************************************************************
1314  * *
1315  * Set and Get functions for the ANGULAR RATE representations *
1316  * *
1317  *****************************************************************************/
1321 /************* declaration of transformation functions ************/
1322 extern void stateCalcBodyRates_i(void);
1323 extern void stateCalcBodyRates_f(void);
1324 
1325 /*********************** validity test functions ******************/
1326 
1328 static inline bool stateIsRateValid(void)
1329 {
1330  return (state.rate_status);
1331 }
1332 
1333 /************************ Set functions ****************************/
1334 
1336 static inline void stateSetBodyRates_i(uint16_t id, struct Int32Rates *body_rate)
1337 {
1339 
1340  RATES_COPY(state.body_rates_i, *body_rate);
1341  /* clear bits for all attitude representations and only set the new one */
1342  state.rate_status = (1 << RATE_I);
1343 }
1344 
1346 static inline void stateSetBodyRates_f(uint16_t id, struct FloatRates *body_rate)
1347 {
1349 
1350  RATES_COPY(state.body_rates_f, *body_rate);
1351  /* clear bits for all attitude representations and only set the new one */
1352  state.rate_status = (1 << RATE_F);
1353 }
1354 
1355 /************************ Get functions ****************************/
1356 
1358 static inline struct Int32Rates *stateGetBodyRates_i(void)
1359 {
1360  if (!bit_is_set(state.rate_status, RATE_I)) {
1362  }
1363  return &state.body_rates_i;
1364 }
1365 
1367 static inline struct FloatRates *stateGetBodyRates_f(void)
1368 {
1369  if (!bit_is_set(state.rate_status, RATE_F)) {
1371  }
1372  return &state.body_rates_f;
1373 }
1374 
1379 /******************************************************************************
1380  * *
1381  * Set and Get functions for the WIND- AND AIRSPEED representations *
1382  * *
1383  *****************************************************************************/
1387 /************* declaration of transformation functions ************/
1388 extern void stateCalcHorizontalWindspeed_i(void);
1389 extern void stateCalcVerticalWindspeed_i(void);
1390 extern void stateCalcAirspeed_i(void);
1391 extern void stateCalcHorizontalWindspeed_f(void);
1392 extern void stateCalcVerticalWindspeed_f(void);
1393 extern void stateCalcAirspeed_f(void);
1394 
1395 
1396 /************************ validity test function *******************/
1397 
1399 static inline bool stateIsWindspeedValid(void)
1400 {
1401  return (state.wind_air_status &= ~((1 << WINDSPEED_I) | (1 << WINDSPEED_F)));
1402 }
1403 
1405 static inline bool stateIsVerticalWindspeedValid(void)
1406 {
1407  return (state.wind_air_status &= ~((1 << DOWNWIND_I) | (1 << DOWNWIND_F)));
1408 }
1409 
1411 static inline bool stateIsAirspeedValid(void)
1412 {
1413  return (state.wind_air_status &= ~((1 << AIRSPEED_I) | (1 << AIRSPEED_F)));
1414 }
1415 
1417 static inline bool stateIsAngleOfAttackValid(void)
1418 {
1419  return (state.wind_air_status &= ~(1 << AOA_F));
1420 }
1421 
1423 static inline bool stateIsSideslipValid(void)
1424 {
1425  return (state.wind_air_status &= ~(1 << SIDESLIP_F));
1426 }
1427 
1428 /************************ Set functions ****************************/
1429 
1431 static inline void stateSetHorizontalWindspeed_i(uint16_t id, struct Int32Vect2 *h_windspeed)
1432 {
1434 
1435  VECT2_COPY(state.windspeed_i.vect2, *h_windspeed);
1436  /* clear bits for all horizontal windspeed representations and only set the new one */
1437  ClearBit(state.wind_air_status, WINDSPEED_F);
1439 }
1440 
1442 static inline void stateSetVerticalWindspeed_i(uint16_t id, int32_t v_windspeed)
1443 {
1445 
1446  state.windspeed_i.vect3.z = v_windspeed;
1447  /* clear bits for all vertical windspeed representations and only set the new one */
1448  ClearBit(state.wind_air_status, DOWNWIND_F);
1449  SetBit(state.wind_air_status, DOWNWIND_I);
1450 }
1451 
1453 static inline void stateSetAirspeed_i(uint16_t id, int32_t airspeed)
1454 {
1456 
1457  state.airspeed_i = airspeed;
1458  /* clear bits for all airspeed representations and only set the new one */
1459  ClearBit(state.wind_air_status, AIRSPEED_F);
1460  SetBit(state.wind_air_status, AIRSPEED_I);
1461 }
1462 
1464 static inline void stateSetHorizontalWindspeed_f(uint16_t id, struct FloatVect2 *h_windspeed)
1465 {
1467 
1468  VECT2_COPY(state.windspeed_f.vect2, *h_windspeed);
1469  /* clear bits for all horizontal windspeed representations and only set the new one */
1470  ClearBit(state.wind_air_status, WINDSPEED_I);
1472 }
1473 
1475 static inline void stateSetVerticalWindspeed_f(uint16_t id, float v_windspeed)
1476 {
1478 
1479  state.windspeed_f.vect3.z = v_windspeed;
1480  /* clear bits for all vertical windspeed representations and only set the new one */
1481  ClearBit(state.wind_air_status, DOWNWIND_I);
1482  SetBit(state.wind_air_status, DOWNWIND_F);
1483 }
1484 
1486 static inline void stateSetAirspeed_f(uint16_t id, float airspeed)
1487 {
1489 
1490  state.airspeed_f = airspeed;
1491  /* clear bits for all airspeed representations and only set the new one */
1492  ClearBit(state.wind_air_status, AIRSPEED_I);
1493  SetBit(state.wind_air_status, AIRSPEED_F);
1494 }
1495 
1497 static inline void stateSetAngleOfAttack_f(uint16_t id, float aoa)
1498 {
1500 
1501  state.angle_of_attack_f = aoa;
1502  /* clear bits for all AOA representations and only set the new one */
1504  SetBit(state.wind_air_status, AOA_F);
1505 }
1506 
1508 static inline void stateSetSideslip_f(uint16_t id, float sideslip)
1509 {
1511 
1512  state.sideslip_f = sideslip;
1513  /* clear bits for all sideslip representations and only set the new one */
1515  SetBit(state.wind_air_status, SIDESLIP_F);
1516 }
1517 
1518 /************************ Get functions ****************************/
1519 
1521 static inline struct Int32Vect2 *stateGetHorizontalWindspeed_i(void)
1522 {
1523  if (!bit_is_set(state.wind_air_status, WINDSPEED_I)) {
1525  }
1526  return &state.windspeed_i.vect2;
1527 }
1528 
1530 static inline float stateGetVerticalWindspeed_i(void)
1531 {
1532  if (!bit_is_set(state.wind_air_status, DOWNWIND_I)) {
1534  }
1535  return state.windspeed_i.vect3.z;
1536 }
1537 
1539 static inline struct Int32Vect3 *stateGetWindspeed_i(void)
1540 {
1541  if (!bit_is_set(state.wind_air_status, WINDSPEED_I)) {
1543  }
1544  if (!bit_is_set(state.wind_air_status, DOWNWIND_I)) {
1546  }
1547  return &state.windspeed_i.vect3;
1548 }
1549 
1551 static inline int32_t stateGetAirspeed_i(void)
1552 {
1553  if (!bit_is_set(state.wind_air_status, AIRSPEED_I)) {
1555  }
1556  return state.airspeed_i;
1557 }
1558 
1560 static inline struct FloatVect2 *stateGetHorizontalWindspeed_f(void)
1561 {
1562  if (!bit_is_set(state.wind_air_status, WINDSPEED_F)) {
1564  }
1565  return &state.windspeed_f.vect2;
1566 }
1567 
1569 static inline float stateGetVerticalWindspeed_f(void)
1570 {
1571  if (!bit_is_set(state.wind_air_status, DOWNWIND_F)) {
1573  }
1574  return state.windspeed_f.vect3.z;
1575 }
1576 
1578 static inline struct FloatVect3 *stateGetWindspeed_f(void)
1579 {
1580  if (!bit_is_set(state.wind_air_status, WINDSPEED_F)) {
1582  }
1583  if (!bit_is_set(state.wind_air_status, DOWNWIND_F)) {
1585  }
1586  return &state.windspeed_f.vect3;
1587 }
1588 
1590 static inline float stateGetAirspeed_f(void)
1591 {
1592  if (!bit_is_set(state.wind_air_status, AIRSPEED_F)) {
1594  }
1595  return state.airspeed_f;
1596 }
1597 
1599 static inline float stateGetAngleOfAttack_f(void)
1600 {
1602 // if (!bit_is_set(state.wind_air_status, AOA_F))
1603 // stateCalcAOA_f();
1604  return state.angle_of_attack_f;
1605 }
1606 
1608 static inline float stateGetSideslip_f(void)
1609 {
1611 // if (!bit_is_set(state.wind_air_status, SIDESLIP_F))
1612 // stateCalcSideslip_f();
1613  return state.sideslip_f;
1614 }
1615 
1620 #ifdef __cplusplus
1621 } /* extern "C" */
1622 #endif
1623 
1624 
1625 #endif /* STATE_H */
euler angles
Roation quaternion.
rotation matrix
angular rates
#define RATES_COPY(_a, _b)
Definition: pprz_algebra.h:337
#define VECT2_COPY(_a, _b)
Definition: pprz_algebra.h:68
#define VECT3_COPY(_a, _b)
Definition: pprz_algebra.h:140
euler angles
Rotation quaternion.
rotation matrix
angular rates
#define LLA_COPY(_pos1, _pos2)
Definition: pprz_geodetic.h:58
struct Int32RMat ltp_of_ecef
Rotation matrix.
int32_t hmsl
Height above mean sea level in mm.
struct LlaCoor_i lla
Reference point in lla.
struct EcefCoor_i ecef
Reference point in ecef.
#define ECEF_FLOAT_OF_BFP(_o, _i)
#define HIGH_RES_RMAT_FLOAT_OF_BFP(_ef, _ei)
#define LLA_FLOAT_OF_BFP(_o, _i)
#define M_OF_MM(_mm)
vector in EarthCenteredEarthFixed coordinates
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
definition of the local (flat earth) coordinate system
vector in North East Down coordinates
static void orientationSetRMat_f(struct OrientationReps *orientation, struct FloatRMat *rmat)
Set vehicle body attitude from rotation matrix (float).
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
static bool orienationCheckValid(struct OrientationReps *orientation)
Test if orientations are valid.
static void orientationSetEulers_f(struct OrientationReps *orientation, struct FloatEulers *eulers)
Set vehicle body attitude from euler angles (float).
static struct Int32Quat * orientationGetQuat_i(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (int).
static void orientationSetQuat_i(struct OrientationReps *orientation, struct Int32Quat *quat)
Set vehicle body attitude from quaternion (int).
static void orientationSetEulers_i(struct OrientationReps *orientation, struct Int32Eulers *eulers)
Set vehicle body attitude from euler angles (int).
static struct FloatEulers * orientationGetEulers_f(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (float).
static void orientationSetRMat_i(struct OrientationReps *orientation, struct Int32RMat *rmat)
Set vehicle body attitude from rotation matrix (int).
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
static struct Int32Eulers * orientationGetEulers_i(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (int).
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
Definition: state.h:1195
#define ACCEL_ECEF_I
Definition: state.h:106
static void stateSetAccelNed_i(uint16_t id, struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
Definition: state.h:1127
struct EcefCoor_f ecef_accel_f
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:400
struct Int32Vect3 body_accel_i
Acceleration in Body coordinates.
Definition: state.h:376
struct NedCoor_i ned_accel_i
Acceleration in North East Down coordinates.
Definition: state.h:382
#define ACCEL_NED_F
Definition: state.h:109
static struct EcefCoor_f * stateGetAccelEcef_f(void)
Get acceleration in ECEF coordinates (float).
Definition: state.h:1204
uint8_t accel_status
Holds the status bits for all acceleration representations.
Definition: state.h:365
void stateCalcAccelNed_i(void)
Definition: state.c:1217
void stateCalcAccelEcef_i(void)
Definition: state.c:1250
struct EcefCoor_i ecef_accel_i
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:388
static void stateSetAccelEcef_f(uint16_t id, struct EcefCoor_f *ecef_accel)
Set acceleration in ECEF coordinates (float).
Definition: state.h:1157
static bool stateIsAccelValid(void)
Test if accelerations are valid.
Definition: state.h:1119
#define ACCEL_ECEF_F
Definition: state.h:108
void stateCalcAccelEcef_f(void)
Definition: state.c:1315
uint16_t accel_input_filter
Holds the input filter id for acceleration.
Definition: state.h:370
static void stateSetAccelNed_f(uint16_t id, struct NedCoor_f *ned_accel)
Set acceleration in NED coordinates (float).
Definition: state.h:1147
static void stateSetAccelEcef_i(uint16_t id, struct EcefCoor_i *ecef_accel)
Set acceleration in ECEF coordinates (int).
Definition: state.h:1137
static struct NedCoor_i * stateGetAccelNed_i(void)
Get acceleration in NED coordinates (int).
Definition: state.h:1177
static struct EcefCoor_i * stateGetAccelEcef_i(void)
Get acceleration in ECEF coordinates (int).
Definition: state.h:1186
struct NedCoor_f ned_accel_f
Acceleration in North East Down coordinates.
Definition: state.h:394
#define ACCEL_NED_I
Definition: state.h:107
static void stateSetAccelBody_i(uint16_t id, struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
Definition: state.h:1167
void stateCalcAccelNed_f(void)
Definition: state.c:1282
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
Definition: state.h:1276
static void stateSetNedToBodyQuat_f(uint16_t id, struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
Definition: state.h:1253
static void stateSetNedToBodyQuat_i(uint16_t id, struct Int32Quat *ned_to_body_quat)
Set vehicle body attitude from quaternion (int).
Definition: state.h:1232
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
Definition: state.h:1288
static bool stateIsAttitudeValid(void)
Test if attitudes are valid.
Definition: state.h:1224
static void stateSetNedToBodyEulers_f(uint16_t id, struct FloatEulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (float).
Definition: state.h:1267
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
Definition: state.h:1300
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
Definition: state.h:1282
static void stateSetNedToBodyEulers_i(uint16_t id, struct Int32Eulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (int).
Definition: state.h:1246
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1306
static void stateSetNedToBodyRMat_f(uint16_t id, struct FloatRMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (float).
Definition: state.h:1260
static void stateSetNedToBodyRMat_i(uint16_t id, struct Int32RMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (int).
Definition: state.h:1239
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
Definition: state.h:1294
uint16_t attitude_input_filter
Holds the input filter id for attitude.
Definition: state.h:411
struct OrientationReps ned_to_body_orientation
Definition: state.h:406
#define STATE_CHECK_INPUT_AND_RETURN(flag, id)
Helper macro to check input filter and return if not valid input id.
Definition: state.h:513
void stateSetInputFilter(uint8_t type, uint16_t flag)
set the input filter for a specified type of data.
Definition: state.c:85
struct State state
Definition: state.c:36
void stateInit(void)
Definition: state.c:57
Structure holding vehicle state data.
Definition: state.h:152
#define POS_LLA_F
Definition: state.h:79
struct NedCoor_i ned_pos_i
Position in North East Down coordinates.
Definition: state.h:206
#define POS_UTM_F
Definition: state.h:80
static void stateSetPositionLla_f(uint16_t id, struct LlaCoor_f *lla_pos)
Set position from LLA coordinates (float).
Definition: state.h:738
static struct UtmCoor_f * stateGetUtmOrigin_f(void)
Get the coordinate UTM frame origin (int)
Definition: state.h:576
static void stateSetPositionNed_f(uint16_t id, struct NedCoor_f *ned_pos)
Set position from local NED coordinates (float).
Definition: state.h:718
#define POS_LLA_I
Definition: state.h:74
struct NedCoor_f ned_pos_f
Position in North East Down coordinates.
Definition: state.h:271
#define POS_ENU_F
Definition: state.h:78
struct EnuCoor_f enu_pos_f
Position in East North Up coordinates.
Definition: state.h:278
#define POS_ECEF_F
Definition: state.h:76
struct UtmCoor_f utm_pos_f
Position in UTM coordinates.
Definition: state.h:220
static void stateSetLocalOrigin_i(uint16_t id, struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
Definition: state.h:519
void stateCalcPositionNed_f(void)
Definition: state.c:582
static void stateSetPositionEnu_i(uint16_t id, struct EnuCoor_i *enu_pos)
Set position from local ENU coordinates (int).
Definition: state.h:648
static void stateSetPosition_f(uint16_t id, struct EcefCoor_f *ecef_pos, struct NedCoor_f *ned_pos, struct EnuCoor_f *enu_pos, struct LlaCoor_f *lla_pos, struct UtmCoor_f *utm_pos)
Set multiple position coordinates (float).
Definition: state.h:748
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition: state.h:848
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
Definition: state.h:248
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:194
static struct LtpDef_f * stateGetNedOrigin_f(void)
Get the coordinate NED frame origin (float)
Definition: state.h:566
bool ned_initialized_f
True if local float coordinate frame is initialsed.
Definition: state.h:251
struct EcefCoor_f stateGetEcefOrigin_f(void)
Get the ECEF position of the frame origin (float)
Definition: state.c:175
uint16_t pos_status
Holds the status bits for all position representations.
Definition: state.h:167
struct LlaCoor_i lla_pos_i
Position in Latitude, Longitude and Altitude.
Definition: state.h:185
void stateCalcPositionUtm_f(void)
Definition: state.c:514
static void stateSetPositionEnu_f(uint16_t id, struct EnuCoor_f *enu_pos)
Set position from local ENU coordinates (float).
Definition: state.h:728
void stateCalcPositionEnu_f(void)
Definition: state.c:649
struct EcefCoor_f ecef_pos_f
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:239
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition: state.h:821
static void stateSetPositionUtm_f(uint16_t id, struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
Definition: state.h:698
static struct EcefCoor_i * stateGetPositionEcef_i(void)
Get position in ECEF coordinates (int).
Definition: state.h:785
bool utm_initialized_f
True if utm origin (float) coordinate frame is initialsed.
Definition: state.h:264
#define POS_ENU_I
Definition: state.h:73
uint16_t origin_input_filter
Holds the input filter id for state origin.
Definition: state.h:160
#define POS_ECEF_I
Definition: state.h:71
#define POS_GLOBAL_COORD
Definition: state.h:82
void stateCalcPositionEcef_f(void)
Definition: state.c:551
#define POS_LOCAL_COORD
Definition: state.h:81
struct EnuCoor_i enu_pos_i
Position in East North Up coordinates.
Definition: state.h:213
static struct LlaCoor_i * stateGetPositionLla_i(void)
Get position in LLA coordinates (int).
Definition: state.h:812
bool ned_initialized_i
true if local int coordinate frame is initialsed
Definition: state.h:199
static void stateSetPositionEcef_f(uint16_t id, struct EcefCoor_f *ecef_pos)
Set position from ECEF coordinates (float).
Definition: state.h:708
#define POS_NED_F
Definition: state.h:77
static bool stateIsGlobalCoordinateValid(void)
Test if global coordinates are valid.
Definition: state.h:620
float alt_agl_f
Altitude above ground level.
Definition: state.h:226
void stateCalcPositionLla_f(void)
Definition: state.c:722
static struct LtpDef_i * stateGetNedOrigin_i(void)
Get the coordinate NED frame origin (int)
Definition: state.h:556
int32_t stateGetHmslOrigin_i(void)
Get the HMSL of the frame origin (int)
Definition: state.c:190
static void stateSetLocalUtmOrigin_f(uint16_t id, struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
Definition: state.h:541
void stateCalcPositionEcef_i(void)
Definition: state.c:217
static void stateSetPositionEcef_i(uint16_t id, struct EcefCoor_i *ecef_pos)
Set position from ECEF coordinates (int).
Definition: state.h:628
float stateGetHmslOrigin_f(void)
Get the HMSL of the frame origin (float)
Definition: state.c:204
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
Definition: state.h:261
static struct EcefCoor_f * stateGetPositionEcef_f(void)
Get position in ECEF coordinates (float).
Definition: state.h:830
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
Definition: state.h:857
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
Definition: state.h:839
struct LlaCoor_i stateGetLlaOrigin_i(void)
Get the LLA position of the frame origin (int)
Definition: state.c:124
void stateCalcPositionNed_i(void)
Definition: state.c:249
void stateCalcPositionLla_i(void)
Calculate LLA (int) from any other available representation.
Definition: state.c:416
static bool stateIsLocalCoordinateValid(void)
Test if local coordinates are valid.
Definition: state.h:613
struct LlaCoor_f stateGetLlaOrigin_f(void)
Get the LLA position of the frame origin (float)
Definition: state.c:143
static void stateSetPositionLla_i(uint16_t id, struct LlaCoor_i *lla_pos)
Set position from LLA coordinates (int).
Definition: state.h:658
struct LlaCoor_f lla_pos_f
Position in Latitude, Longitude and Altitude.
Definition: state.h:233
static void stateSetPosition_i(uint16_t id, struct EcefCoor_i *ecef_pos, struct NedCoor_i *ned_pos, struct EnuCoor_i *enu_pos, struct LlaCoor_i *lla_pos)
Set multiple position coordinates (int).
Definition: state.h:668
uint16_t pos_input_filter
Holds the input filter id for position.
Definition: state.h:172
struct EcefCoor_i ecef_pos_i
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:178
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition: state.h:803
#define POS_NED_I
Definition: state.h:72
static void stateSetPositionNed_i(uint16_t id, struct NedCoor_i *ned_pos)
Set position from local NED coordinates (int).
Definition: state.h:638
struct EcefCoor_i stateGetEcefOrigin_i(void)
Get the ECEF position of the frame origin (int)
Definition: state.c:160
void stateCalcPositionEnu_i(void)
Definition: state.c:329
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
Definition: state.h:794
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
Definition: state.h:1367
uint16_t rates_input_filter
Holds the input filter id for rates.
Definition: state.h:426
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1358
static void stateSetBodyRates_i(uint16_t id, struct Int32Rates *body_rate)
Set vehicle body angular rate (int).
Definition: state.h:1336
void stateCalcBodyRates_f(void)
Definition: state.c:1371
#define RATE_F
Definition: state.h:117
struct FloatRates body_rates_f
Angular rates in body frame.
Definition: state.h:438
#define RATE_I
Definition: state.h:116
void stateCalcBodyRates_i(void)
Definition: state.c:1356
static void stateSetBodyRates_f(uint16_t id, struct FloatRates *body_rate)
Set vehicle body angular rate (float).
Definition: state.h:1346
struct Int32Rates body_rates_i
Angular rates in body frame.
Definition: state.h:432
uint8_t rate_status
Holds the status bits for all angular rate representations.
Definition: state.h:421
static bool stateIsRateValid(void)
Test if rates are valid.
Definition: state.h:1328
#define SPEED_ENU_F
Definition: state.h:96
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition: state.h:1076
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition: state.h:1013
static void stateSetSpeedEcef_f(uint16_t id, struct EcefCoor_f *ecef_speed)
Set ground speed in ECEF coordinates (float).
Definition: state.h:967
#define SPEED_ENU_I
Definition: state.h:91
static void stateSetSpeedNed_f(uint16_t id, struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
Definition: state.h:947
void stateCalcSpeedEnu_f(void)
Definition: state.c:1077
struct NedCoor_f ned_speed_f
speed in North East Down coordinates
Definition: state.h:336
static void stateSetSpeedNed_i(uint16_t id, struct NedCoor_i *ned_speed)
Set ground speed in local NED coordinates (int).
Definition: state.h:892
static void stateSetSpeedEcef_i(uint16_t id, struct EcefCoor_i *ecef_speed)
Set ground speed in ECEF coordinates (int).
Definition: state.h:912
#define SPEED_ECEF_F
Definition: state.h:94
void stateCalcSpeedNed_f(void)
Definition: state.c:1027
uint16_t speed_input_filter
Holds the input filter id for speed.
Definition: state.h:294
static void stateSetSpeed_f(uint16_t id, struct EcefCoor_f *ecef_speed, struct NedCoor_f *ned_speed, struct EnuCoor_f *enu_speed)
Set multiple speed coordinates (float).
Definition: state.h:977
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
Definition: state.h:1049
#define SPEED_ECEF_I
Definition: state.h:89
static void stateSetSpeedEnu_f(uint16_t id, struct EnuCoor_f *enu_speed)
Set ground speed in local ENU coordinates (float).
Definition: state.h:957
void stateCalcHorizontalSpeedDir_i(void)
Definition: state.c:996
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
Definition: state.h:1085
#define SPEED_NED_F
Definition: state.h:95
struct NedCoor_i ned_speed_i
Velocity in North East Down coordinates.
Definition: state.h:306
float h_speed_norm_f
Norm of horizontal ground speed.
Definition: state.h:348
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition: state.h:1058
int32_t h_speed_dir_i
Direction of horizontal ground speed.
Definition: state.h:325
float h_speed_dir_f
Direction of horizontal ground speed.
Definition: state.h:354
void stateCalcHorizontalSpeedNorm_f(void)
Definition: state.c:1152
void stateCalcHorizontalSpeedNorm_i(void)
Definition: state.c:950
#define SPEED_LOCAL_COORD
Definition: state.h:99
static int32_t stateGetHorizontalSpeedDir_i(void)
Get dir of horizontal ground speed (int).
Definition: state.h:1040
struct EcefCoor_f ecef_speed_f
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:331
void stateCalcSpeedEcef_f(void)
Definition: state.c:1127
#define SPEED_HDIR_I
Definition: state.h:93
void stateCalcSpeedEnu_i(void)
Definition: state.c:873
#define SPEED_HNORM_F
Definition: state.h:97
#define SPEED_NED_I
Definition: state.h:90
struct EcefCoor_i ecef_speed_i
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:300
static struct EcefCoor_i * stateGetSpeedEcef_i(void)
Get ground speed in ECEF coordinates (int).
Definition: state.h:1022
void stateCalcHorizontalSpeedDir_f(void)
Definition: state.c:1179
struct EnuCoor_i enu_speed_i
Velocity in East North Up coordinates.
Definition: state.h:312
uint16_t speed_status
Holds the status bits for all ground speed representations.
Definition: state.h:289
static struct EcefCoor_f * stateGetSpeedEcef_f(void)
Get ground speed in ECEF coordinates (float).
Definition: state.h:1067
static void stateSetSpeedEnu_i(uint16_t id, struct EnuCoor_i *enu_speed)
Set ground speed in local ENU coordinates (int).
Definition: state.h:902
static void stateSetSpeed_i(uint16_t id, struct EcefCoor_i *ecef_speed, struct NedCoor_i *ned_speed, struct EnuCoor_i *enu_speed)
Set multiple speed coordinates (int).
Definition: state.h:922
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
Definition: state.h:1004
void stateCalcSpeedNed_i(void)
Definition: state.c:823
#define SPEED_HNORM_I
Definition: state.h:92
static struct Int32Vect3 * stateGetAccelBody_i(void)
Get acceleration in Body coordinates (int).
Definition: state.h:1094
uint32_t h_speed_norm_i
Norm of horizontal ground speed.
Definition: state.h:318
static uint32_t stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition: state.h:1031
#define SPEED_HDIR_F
Definition: state.h:98
struct EnuCoor_f enu_speed_f
Velocity in East North Up coordinates.
Definition: state.h:342
void stateCalcSpeedEcef_i(void)
Definition: state.c:925
static bool stateIsSideslipValid(void)
test if sideslip is available.
Definition: state.h:1423
static void stateSetAngleOfAttack_f(uint16_t id, float aoa)
Set angle of attack in radians (float).
Definition: state.h:1497
#define WINDSPEED_I
Definition: state.h:124
static struct Int32Vect3 * stateGetWindspeed_i(void)
Get windspeed (int).
Definition: state.h:1539
static bool stateIsWindspeedValid(void)
test if wind speed is available.
Definition: state.h:1399
static void stateSetSideslip_f(uint16_t id, float sideslip)
Set sideslip angle in radians (float).
Definition: state.h:1508
int32_t airspeed_i
Norm of relative wind speed.
Definition: state.h:469
#define DOWNWIND_F
Definition: state.h:128
static struct Int32Vect2 * stateGetHorizontalWindspeed_i(void)
Get horizontal windspeed (int).
Definition: state.h:1521
static float stateGetSideslip_f(void)
Get sideslip (float).
Definition: state.h:1608
union State::@356 windspeed_f
Horizontal windspeed.
#define WINDSPEED_F
Definition: state.h:127
float airspeed_f
Norm of relative air speed.
Definition: state.h:484
static void stateSetVerticalWindspeed_f(uint16_t id, float v_windspeed)
Set vertical windspeed (float).
Definition: state.h:1475
static bool stateIsAirspeedValid(void)
test if air speed is available.
Definition: state.h:1411
uint8_t wind_air_status
Holds the status bits for all wind- and airspeed representations.
Definition: state.h:449
#define AIRSPEED_I
Definition: state.h:126
static void stateSetVerticalWindspeed_i(uint16_t id, int32_t v_windspeed)
Set vertical windspeed (int).
Definition: state.h:1442
#define SIDESLIP_F
Definition: state.h:131
static void stateSetAirspeed_i(uint16_t id, int32_t airspeed)
Set airspeed (int).
Definition: state.h:1453
void stateCalcAirspeed_i(void)
Definition: state.c:1428
static void stateSetHorizontalWindspeed_i(uint16_t id, struct Int32Vect2 *h_windspeed)
Set horizontal windspeed (int).
Definition: state.h:1431
void stateCalcVerticalWindspeed_i(void)
Definition: state.c:1413
static float stateGetAirspeed_f(void)
Get airspeed (float).
Definition: state.h:1590
static float stateGetVerticalWindspeed_i(void)
Get vertical windspeed (int).
Definition: state.h:1530
static float stateGetAngleOfAttack_f(void)
Get angle of attack (float).
Definition: state.h:1599
void stateCalcAirspeed_f(void)
Definition: state.c:1474
#define AIRSPEED_F
Definition: state.h:129
float sideslip_f
Sideslip angle Unit: rad.
Definition: state.h:496
uint16_t wind_air_input_filter
Holds the input filter id for air data.
Definition: state.h:454
void stateCalcHorizontalWindspeed_f(void)
Definition: state.c:1443
static float stateGetVerticalWindspeed_f(void)
Get vertical windspeed (float).
Definition: state.h:1569
static int32_t stateGetAirspeed_i(void)
Get airspeed (int).
Definition: state.h:1551
static void stateSetHorizontalWindspeed_f(uint16_t id, struct FloatVect2 *h_windspeed)
Set horizontal windspeed (float).
Definition: state.h:1464
void stateCalcHorizontalWindspeed_i(void)
Definition: state.c:1397
float angle_of_attack_f
Angle of attack Unit: rad.
Definition: state.h:490
union State::@355 windspeed_i
Horizontal windspeed in north/east/down.
#define AOA_F
Definition: state.h:130
static bool stateIsAngleOfAttackValid(void)
test if angle of attack is available.
Definition: state.h:1417
#define DOWNWIND_I
Definition: state.h:125
static void stateSetAirspeed_f(uint16_t id, float airspeed)
Set airspeed (float).
Definition: state.h:1486
void stateCalcVerticalWindspeed_f(void)
Definition: state.c:1459
static struct FloatVect3 * stateGetWindspeed_f(void)
Get windspeed (float).
Definition: state.h:1578
static bool stateIsVerticalWindspeedValid(void)
test if vertical wind speed is available.
Definition: state.h:1405
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
Definition: state.h:1560
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
Paparazzi floating point math for geodetic calculations.
float hmsl
Height above mean sea level in meters.
struct FloatRMat ltp_of_ecef
rotation from ECEF to local frame
struct EcefCoor_f ecef
origin of local frame in ECEF
struct LlaCoor_f lla
origin of local frame in LLA
vector in EarthCenteredEarthFixed coordinates
vector in East North Up coordinates Units: meters
vector in Latitude, Longitude and Altitude
definition of the local (flat earth) coordinate system
vector in North East Down coordinates Units: meters
position in UTM coordinates Units: meters
Paparazzi fixed point math for geodetic calculations.
Generic orientation representation and conversions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98