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
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 #include "math/pprz_algebra_int.h"
36 #include "math/pprz_geodetic_int.h"
39 
40 #include "std.h"
41 #include <string.h>
42 
67 #define POS_ECEF_I 0
68 #define POS_NED_I 1
69 #define POS_ENU_I 2
70 #define POS_LLA_I 3
71 #define POS_UTM_I 4
72 #define POS_ECEF_F 5
73 #define POS_NED_F 6
74 #define POS_ENU_F 7
75 #define POS_LLA_F 8
76 #define POS_UTM_F 9
77 #define POS_LOCAL_COORD ((1<<POS_NED_I)|(1<<POS_NED_F)|(1<<POS_ENU_I)|(1<<POS_ENU_F))
78 #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))
79 
85 #define SPEED_ECEF_I 0
86 #define SPEED_NED_I 1
87 #define SPEED_ENU_I 2
88 #define SPEED_HNORM_I 3
89 #define SPEED_HDIR_I 4
90 #define SPEED_ECEF_F 5
91 #define SPEED_NED_F 6
92 #define SPEED_ENU_F 7
93 #define SPEED_HNORM_F 8
94 #define SPEED_HDIR_F 9
95 #define SPEED_LOCAL_COORD ((1<<SPEED_NED_I)|(1<<SPEED_ENU_I)|(1<<SPEED_NED_F)|(1<<SPEED_ENU_F))
96 
102 #define ACCEL_ECEF_I 0
103 #define ACCEL_NED_I 1
104 #define ACCEL_ECEF_F 2
105 #define ACCEL_NED_F 3
106 
112 #define RATE_I 0
113 #define RATE_F 1
114 
120 #define WINDSPEED_I 0
121 #define DOWNWIND_I 1
122 #define AIRSPEED_I 2
123 #define WINDSPEED_F 3
124 #define DOWNWIND_F 4
125 #define AIRSPEED_F 5
126 #define AOA_F 6
127 #define SIDESLIP_F 7
128 
134 struct State {
135 
145 
151 
158 
167 
172 
179 
186 
193 
198  float alt_agl_f;
199 
206 
212 
221 
224 
234 
237 
244 
262 
268 
274 
280 
286 
293 
299 
304 
310 
316 
333 
339 
345 
351 
363 
364 
373 
379 
396 
401  union {
402  struct Int32Vect3 vect3;
403  struct Int32Vect2 vect2;
404  } windspeed_i;
405 
411 
416  union {
417  struct FloatVect3 vect3;
418  struct FloatVect2 vect2;
419  } windspeed_f;
420 
425  float airspeed_f;
426 
432 
437  float sideslip_f;
438 
441 };
442 
443 extern struct State state;
444 
445 extern void stateInit(void);
446 
450 static inline void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
452 {
454  /* convert to float */
459 
460  /* clear bits for all local frame representations */
463  ClearBit(state.accel_status, ACCEL_NED_I);
464  ClearBit(state.accel_status, ACCEL_NED_F);
465 
466  state.ned_initialized_i = true;
467  state.ned_initialized_f = true;
468 }
469 
471 static inline void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
472 {
473  state.utm_origin_f = *utm_def;
474  state.utm_initialized_f = true;
475 
476  /* clear bits for all local frame representations */
479  ClearBit(state.accel_status, ACCEL_NED_I);
480  ClearBit(state.accel_status, ACCEL_NED_F);
481 }
482 /*******************************************************************************
483  * *
484  * Set and Get functions for the POSITION representations *
485  * *
486  ******************************************************************************/
487 
488 /************* declaration of transformation functions ************/
489 extern void stateCalcPositionEcef_i(void);
490 extern void stateCalcPositionNed_i(void);
491 extern void stateCalcPositionEnu_i(void);
492 extern void stateCalcPositionLla_i(void);
493 extern void stateCalcPositionUtm_f(void);
494 extern void stateCalcPositionEcef_f(void);
495 extern void stateCalcPositionNed_f(void);
496 extern void stateCalcPositionEnu_f(void);
497 extern void stateCalcPositionLla_f(void);
498 
499 /*********************** validity test functions ******************/
500 
502 static inline bool stateIsLocalCoordinateValid(void)
503 {
505  && (state.pos_status & (POS_LOCAL_COORD)));
506 }
507 
509 static inline bool stateIsGlobalCoordinateValid(void)
510 {
512 }
513 
514 /************************ Set functions ****************************/
515 
517 static inline void stateSetPositionEcef_i(struct EcefCoor_i *ecef_pos)
518 {
519  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
520  /* clear bits for all position representations and only set the new one */
521  state.pos_status = (1 << POS_ECEF_I);
522 }
523 
525 static inline void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
526 {
527  VECT3_COPY(state.ned_pos_i, *ned_pos);
528  /* clear bits for all position representations and only set the new one */
529  state.pos_status = (1 << POS_NED_I);
530 }
531 
533 static inline void stateSetPositionEnu_i(struct EnuCoor_i *enu_pos)
534 {
535  VECT3_COPY(state.enu_pos_i, *enu_pos);
536  /* clear bits for all position representations and only set the new one */
537  state.pos_status = (1 << POS_ENU_I);
538 }
539 
541 static inline void stateSetPositionLla_i(struct LlaCoor_i *lla_pos)
542 {
543  LLA_COPY(state.lla_pos_i, *lla_pos);
544  /* clear bits for all position representations and only set the new one */
545  state.pos_status = (1 << POS_LLA_I);
546 }
547 
549 static inline void stateSetPosition_i(
550  struct EcefCoor_i *ecef_pos,
551  struct NedCoor_i *ned_pos,
552  struct EnuCoor_i *enu_pos,
553  struct LlaCoor_i *lla_pos)
554 {
555  /* clear all status bit */
556  state.pos_status = 0;
557  if (ecef_pos != NULL) {
558  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
559  state.pos_status |= (1 << POS_ECEF_I);
560  }
561  if (ned_pos != NULL) {
562  VECT3_COPY(state.ned_pos_i, *ned_pos);
563  state.pos_status |= (1 << POS_NED_I);
564  }
565  if (enu_pos != NULL) {
566  VECT3_COPY(state.enu_pos_i, *enu_pos);
567  state.pos_status |= (1 << POS_ENU_I);
568  }
569  if (lla_pos != NULL) {
570  LLA_COPY(state.lla_pos_i, *lla_pos);
571  state.pos_status |= (1 << POS_LLA_I);
572  }
573 }
574 
576 static inline void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
577 {
578  state.utm_pos_f = *utm_pos;
579  /* clear bits for all position representations and only set the new one */
580  state.pos_status = (1 << POS_UTM_F);
581 }
582 
584 static inline void stateSetPositionEcef_f(struct EcefCoor_f *ecef_pos)
585 {
586  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
587  /* clear bits for all position representations and only set the new one */
588  state.pos_status = (1 << POS_ECEF_F);
589 }
590 
592 static inline void stateSetPositionNed_f(struct NedCoor_f *ned_pos)
593 {
594  VECT3_COPY(state.ned_pos_f, *ned_pos);
595  /* clear bits for all position representations and only set the new one */
596  state.pos_status = (1 << POS_NED_F);
597 }
598 
600 static inline void stateSetPositionEnu_f(struct EnuCoor_f *enu_pos)
601 {
602  VECT3_COPY(state.enu_pos_f, *enu_pos);
603  /* clear bits for all position representations and only set the new one */
604  state.pos_status = (1 << POS_ENU_F);
605 }
606 
608 static inline void stateSetPositionLla_f(struct LlaCoor_f *lla_pos)
609 {
610  LLA_COPY(state.lla_pos_f, *lla_pos);
611  /* clear bits for all position representations and only set the new one */
612  state.pos_status = (1 << POS_LLA_F);
613 }
614 
616 static inline void stateSetPosition_f(
617  struct EcefCoor_f *ecef_pos,
618  struct NedCoor_f *ned_pos,
619  struct EnuCoor_f *enu_pos,
620  struct LlaCoor_f *lla_pos,
621  struct UtmCoor_f *utm_pos)
622 {
623  /* clear all status bit */
624  state.pos_status = 0;
625  if (ecef_pos != NULL) {
626  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
627  state.pos_status |= (1 << POS_ECEF_F);
628  }
629  if (ned_pos != NULL) {
630  VECT3_COPY(state.ned_pos_f, *ned_pos);
631  state.pos_status |= (1 << POS_NED_F);
632  }
633  if (enu_pos != NULL) {
634  VECT3_COPY(state.enu_pos_f, *enu_pos);
635  state.pos_status |= (1 << POS_ENU_F);
636  }
637  if (lla_pos != NULL) {
638  LLA_COPY(state.lla_pos_f, *lla_pos);
639  state.pos_status |= (1 << POS_LLA_F);
640  }
641  if (utm_pos != NULL) {
642  state.utm_pos_f = *utm_pos;
643  state.pos_status |= (1 << POS_UTM_F);
644  }
645 }
646 
647 /************************ Get functions ****************************/
648 
650 static inline struct EcefCoor_i *stateGetPositionEcef_i(void)
651 {
652  if (!bit_is_set(state.pos_status, POS_ECEF_I)) {
654  }
655  return &state.ecef_pos_i;
656 }
657 
659 static inline struct NedCoor_i *stateGetPositionNed_i(void)
660 {
661  if (!bit_is_set(state.pos_status, POS_NED_I)) {
663  }
664  return &state.ned_pos_i;
665 }
666 
668 static inline struct EnuCoor_i *stateGetPositionEnu_i(void)
669 {
670  if (!bit_is_set(state.pos_status, POS_ENU_I)) {
672  }
673  return &state.enu_pos_i;
674 }
675 
677 static inline struct LlaCoor_i *stateGetPositionLla_i(void)
678 {
679  if (!bit_is_set(state.pos_status, POS_LLA_I)) {
681  }
682  return &state.lla_pos_i;
683 }
684 
686 static inline struct UtmCoor_f *stateGetPositionUtm_f(void)
687 {
688  if (!bit_is_set(state.pos_status, POS_UTM_F)) {
690  }
691  return &state.utm_pos_f;
692 }
693 
695 static inline struct EcefCoor_f *stateGetPositionEcef_f(void)
696 {
697  if (!bit_is_set(state.pos_status, POS_ECEF_F)) {
699  }
700  return &state.ecef_pos_f;
701 }
702 
704 static inline struct NedCoor_f *stateGetPositionNed_f(void)
705 {
706  if (!bit_is_set(state.pos_status, POS_NED_F)) {
708  }
709  return &state.ned_pos_f;
710 }
711 
713 static inline struct EnuCoor_f *stateGetPositionEnu_f(void)
714 {
715  if (!bit_is_set(state.pos_status, POS_ENU_F)) {
717  }
718  return &state.enu_pos_f;
719 }
720 
722 static inline struct LlaCoor_f *stateGetPositionLla_f(void)
723 {
724  if (!bit_is_set(state.pos_status, POS_LLA_F)) {
726  }
727  return &state.lla_pos_f;
728 }
729 
734 /******************************************************************************
735  * *
736  * Set and Get functions for the SPEED representations *
737  * *
738  *****************************************************************************/
742 /************* declaration of transformation functions ************/
743 extern void stateCalcSpeedNed_i(void);
744 extern void stateCalcSpeedEnu_i(void);
745 extern void stateCalcSpeedEcef_i(void);
746 extern void stateCalcHorizontalSpeedNorm_i(void);
747 extern void stateCalcHorizontalSpeedDir_i(void);
748 extern void stateCalcSpeedNed_f(void);
749 extern void stateCalcSpeedEnu_f(void);
750 extern void stateCalcSpeedEcef_f(void);
751 extern void stateCalcHorizontalSpeedNorm_f(void);
752 extern void stateCalcHorizontalSpeedDir_f(void);
753 
754 /************************ Set functions ****************************/
755 
757 static inline void stateSetSpeedNed_i(struct NedCoor_i *ned_speed)
758 {
759  VECT3_COPY(state.ned_speed_i, *ned_speed);
760  /* clear bits for all speed representations and only set the new one */
761  state.speed_status = (1 << SPEED_NED_I);
762 }
763 
765 static inline void stateSetSpeedEnu_i(struct EnuCoor_i *enu_speed)
766 {
767  VECT3_COPY(state.enu_speed_i, *enu_speed);
768  /* clear bits for all speed representations and only set the new one */
769  state.speed_status = (1 << SPEED_ENU_I);
770 }
771 
773 static inline void stateSetSpeedEcef_i(struct EcefCoor_i *ecef_speed)
774 {
775  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
776  /* clear bits for all speed representations and only set the new one */
778 }
779 
781 static inline void stateSetSpeed_i(
782  struct EcefCoor_i *ecef_speed,
783  struct NedCoor_i *ned_speed,
784  struct EnuCoor_i *enu_speed)
785 {
786  /* clear all status bit */
787  state.speed_status = 0;
788  if (ecef_speed != NULL) {
789  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
790  state.speed_status |= (1 << SPEED_ECEF_I);
791  }
792  if (ned_speed != NULL) {
793  VECT3_COPY(state.ned_speed_i, *ned_speed);
794  state.speed_status |= (1 << SPEED_NED_I);
795  }
796  if (enu_speed != NULL) {
797  VECT3_COPY(state.enu_speed_i, *enu_speed);
798  state.speed_status |= (1 << SPEED_ENU_I);
799  }
800 }
801 
803 static inline void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
804 {
805  VECT3_COPY(state.ned_speed_f, *ned_speed);
806  /* clear bits for all speed representations and only set the new one */
807  state.speed_status = (1 << SPEED_NED_F);
808 }
809 
811 static inline void stateSetSpeedEnu_f(struct EnuCoor_f *enu_speed)
812 {
813  VECT3_COPY(state.enu_speed_f, *enu_speed);
814  /* clear bits for all speed representations and only set the new one */
815  state.speed_status = (1 << SPEED_ENU_F);
816 }
817 
819 static inline void stateSetSpeedEcef_f(struct EcefCoor_f *ecef_speed)
820 {
821  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
822  /* clear bits for all speed representations and only set the new one */
824 }
825 
827 static inline void stateSetSpeed_f(
828  struct EcefCoor_f *ecef_speed,
829  struct NedCoor_f *ned_speed,
830  struct EnuCoor_f *enu_speed)
831 {
832  /* clear all status bit */
833  state.speed_status = 0;
834  if (ecef_speed != NULL) {
835  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
836  state.speed_status |= (1 << SPEED_ECEF_F);
837  }
838  if (ned_speed != NULL) {
839  VECT3_COPY(state.ned_speed_f, *ned_speed);
840  state.speed_status |= (1 << SPEED_NED_F);
841  }
842  if (enu_speed != NULL) {
843  VECT3_COPY(state.enu_speed_f, *enu_speed);
844  state.speed_status |= (1 << SPEED_ENU_F);
845  }
846 }
847 
848 /************************ Get functions ****************************/
849 
851 static inline struct NedCoor_i *stateGetSpeedNed_i(void)
852 {
853  if (!bit_is_set(state.speed_status, SPEED_NED_I)) {
855  }
856  return &state.ned_speed_i;
857 }
858 
860 static inline struct EnuCoor_i *stateGetSpeedEnu_i(void)
861 {
862  if (!bit_is_set(state.speed_status, SPEED_ENU_I)) {
864  }
865  return &state.enu_speed_i;
866 }
867 
869 static inline struct EcefCoor_i *stateGetSpeedEcef_i(void)
870 {
871  if (!bit_is_set(state.speed_status, SPEED_ECEF_I)) {
873  }
874  return &state.ecef_speed_i;
875 }
876 
879 {
880  if (!bit_is_set(state.speed_status, SPEED_HNORM_I)) {
882  }
883  return state.h_speed_norm_i;
884 }
885 
888 {
889  if (!bit_is_set(state.speed_status, SPEED_HDIR_I)) {
891  }
892  return state.h_speed_dir_i;
893 }
894 
896 static inline struct NedCoor_f *stateGetSpeedNed_f(void)
897 {
898  if (!bit_is_set(state.speed_status, SPEED_NED_F)) {
900  }
901  return &state.ned_speed_f;
902 }
903 
905 static inline struct EnuCoor_f *stateGetSpeedEnu_f(void)
906 {
907  if (!bit_is_set(state.speed_status, SPEED_ENU_F)) {
909  }
910  return &state.enu_speed_f;
911 }
912 
914 static inline struct EcefCoor_f *stateGetSpeedEcef_f(void)
915 {
916  if (!bit_is_set(state.speed_status, SPEED_ECEF_F)) {
918  }
919  return &state.ecef_speed_f;
920 }
921 
923 static inline float stateGetHorizontalSpeedNorm_f(void)
924 {
925  if (!bit_is_set(state.speed_status, SPEED_HNORM_F)) {
927  }
928  return state.h_speed_norm_f;
929 }
930 
932 static inline float stateGetHorizontalSpeedDir_f(void)
933 {
934  if (!bit_is_set(state.speed_status, SPEED_HDIR_F)) {
936  }
937  return state.h_speed_dir_f;
938 }
943 /******************************************************************************
944  * *
945  * Set and Get functions for the ACCELERATION representations *
946  * *
947  *****************************************************************************/
951 /************* declaration of transformation functions ************/
952 extern void stateCalcAccelNed_i(void);
953 extern void stateCalcAccelEcef_i(void);
954 extern void stateCalcAccelNed_f(void);
955 extern void stateCalcAccelEcef_f(void);
956 
957 /*********************** validity test functions ******************/
958 
960 static inline bool stateIsAccelValid(void)
961 {
962  return (state.accel_status);
963 }
964 
965 /************************ Set functions ****************************/
966 
968 static inline void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
969 {
970  VECT3_COPY(state.ned_accel_i, *ned_accel);
971  /* clear bits for all accel representations and only set the new one */
972  state.accel_status = (1 << ACCEL_NED_I);
973 }
974 
976 static inline void stateSetAccelEcef_i(struct EcefCoor_i *ecef_accel)
977 {
978  VECT3_COPY(state.ecef_accel_i, *ecef_accel);
979  /* clear bits for all accel representations and only set the new one */
981 }
982 
984 static inline void stateSetAccelNed_f(struct NedCoor_f *ned_accel)
985 {
986  VECT3_COPY(state.ned_accel_f, *ned_accel);
987  /* clear bits for all accel representations and only set the new one */
988  state.accel_status = (1 << ACCEL_NED_F);
989 }
990 
992 static inline void stateSetAccelEcef_f(struct EcefCoor_f *ecef_accel)
993 {
994  VECT3_COPY(state.ecef_accel_f, *ecef_accel);
995  /* clear bits for all accel representations and only set the new one */
997 }
998 
999 /************************ Get functions ****************************/
1000 
1002 static inline struct NedCoor_i *stateGetAccelNed_i(void)
1003 {
1004  if (!bit_is_set(state.accel_status, ACCEL_NED_I)) {
1006  }
1007  return &state.ned_accel_i;
1008 }
1009 
1011 static inline struct EcefCoor_i *stateGetAccelEcef_i(void)
1012 {
1013  if (!bit_is_set(state.accel_status, ACCEL_ECEF_I)) {
1015  }
1016  return &state.ecef_accel_i;
1017 }
1018 
1020 static inline struct NedCoor_f *stateGetAccelNed_f(void)
1021 {
1022  if (!bit_is_set(state.accel_status, ACCEL_NED_F)) {
1024  }
1025  return &state.ned_accel_f;
1026 }
1027 
1029 static inline struct EcefCoor_f *stateGetAccelEcef_f(void)
1030 {
1031  if (!bit_is_set(state.accel_status, ACCEL_ECEF_F)) {
1033  }
1034  return &state.ecef_accel_f;
1035 }
1038 /******************************************************************************
1039 * *
1040 * Set and Get functions for the ATTITUDE representations *
1041 * (Calls the functions in math/pprz_orientation_conversion) *
1042 * *
1043 *****************************************************************************/
1046 /*********************** validity test functions ******************/
1047 
1049 static inline bool stateIsAttitudeValid(void)
1050 {
1052 }
1053 
1054 /************************ Set functions ****************************/
1055 
1057 static inline void stateSetNedToBodyQuat_i(struct Int32Quat *ned_to_body_quat)
1058 {
1060 }
1061 
1063 static inline void stateSetNedToBodyRMat_i(struct Int32RMat *ned_to_body_rmat)
1064 {
1066 }
1067 
1069 static inline void stateSetNedToBodyEulers_i(struct Int32Eulers *ned_to_body_eulers)
1070 {
1072 }
1073 
1075 static inline void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
1076 {
1078 }
1079 
1081 static inline void stateSetNedToBodyRMat_f(struct FloatRMat *ned_to_body_rmat)
1082 {
1084 }
1085 
1087 static inline void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
1088 {
1090 }
1091 
1092 /************************ Get functions ****************************/
1093 
1095 static inline struct Int32Quat *stateGetNedToBodyQuat_i(void)
1096 {
1098 }
1099 
1101 static inline struct Int32RMat *stateGetNedToBodyRMat_i(void)
1102 {
1104 }
1105 
1107 static inline struct Int32Eulers *stateGetNedToBodyEulers_i(void)
1108 {
1110 }
1111 
1113 static inline struct FloatQuat *stateGetNedToBodyQuat_f(void)
1114 {
1116 }
1117 
1119 static inline struct FloatRMat *stateGetNedToBodyRMat_f(void)
1120 {
1122 }
1123 
1125 static inline struct FloatEulers *stateGetNedToBodyEulers_f(void)
1126 {
1128 }
1132 /******************************************************************************
1133  * *
1134  * Set and Get functions for the ANGULAR RATE representations *
1135  * *
1136  *****************************************************************************/
1140 /************* declaration of transformation functions ************/
1141 extern void stateCalcBodyRates_i(void);
1142 extern void stateCalcBodyRates_f(void);
1143 
1144 /*********************** validity test functions ******************/
1145 
1147 static inline bool stateIsRateValid(void)
1148 {
1149  return (state.rate_status);
1150 }
1151 
1152 /************************ Set functions ****************************/
1153 
1155 static inline void stateSetBodyRates_i(struct Int32Rates *body_rate)
1156 {
1157  RATES_COPY(state.body_rates_i, *body_rate);
1158  /* clear bits for all attitude representations and only set the new one */
1159  state.rate_status = (1 << RATE_I);
1160 }
1161 
1163 static inline void stateSetBodyRates_f(struct FloatRates *body_rate)
1164 {
1165  RATES_COPY(state.body_rates_f, *body_rate);
1166  /* clear bits for all attitude representations and only set the new one */
1167  state.rate_status = (1 << RATE_F);
1168 }
1169 
1170 /************************ Get functions ****************************/
1171 
1173 static inline struct Int32Rates *stateGetBodyRates_i(void)
1174 {
1175  if (!bit_is_set(state.rate_status, RATE_I)) {
1177  }
1178  return &state.body_rates_i;
1179 }
1180 
1182 static inline struct FloatRates *stateGetBodyRates_f(void)
1183 {
1184  if (!bit_is_set(state.rate_status, RATE_F)) {
1186  }
1187  return &state.body_rates_f;
1188 }
1189 
1194 /******************************************************************************
1195  * *
1196  * Set and Get functions for the WIND- AND AIRSPEED representations *
1197  * *
1198  *****************************************************************************/
1202 /************* declaration of transformation functions ************/
1203 extern void stateCalcHorizontalWindspeed_i(void);
1204 extern void stateCalcVerticalWindspeed_i(void);
1205 extern void stateCalcAirspeed_i(void);
1206 extern void stateCalcHorizontalWindspeed_f(void);
1207 extern void stateCalcVerticalWindspeed_f(void);
1208 extern void stateCalcAirspeed_f(void);
1209 
1210 
1211 /************************ validity test function *******************/
1212 
1214 static inline bool stateIsWindspeedValid(void)
1215 {
1216  return (state.wind_air_status &= ~((1 << WINDSPEED_I) | (1 << WINDSPEED_F)));
1217 }
1218 
1220 static inline bool stateIsVerticalWindspeedValid(void)
1221 {
1222  return (state.wind_air_status &= ~((1 << DOWNWIND_I) | (1 << DOWNWIND_F)));
1223 }
1224 
1226 static inline bool stateIsAirspeedValid(void)
1227 {
1228  return (state.wind_air_status &= ~((1 << AIRSPEED_I) | (1 << AIRSPEED_F)));
1229 }
1230 
1232 static inline bool stateIsAngleOfAttackValid(void)
1233 {
1234  return (state.wind_air_status &= ~(1 << AOA_F));
1235 }
1236 
1238 static inline bool stateIsSideslipValid(void)
1239 {
1240  return (state.wind_air_status &= ~(1 << SIDESLIP_F));
1241 }
1242 
1243 /************************ Set functions ****************************/
1244 
1246 static inline void stateSetHorizontalWindspeed_i(struct Int32Vect2 *h_windspeed)
1247 {
1248  VECT2_COPY(state.windspeed_i.vect2, *h_windspeed);
1249  /* clear bits for all horizontal windspeed representations and only set the new one */
1250  ClearBit(state.wind_air_status, WINDSPEED_F);
1252 }
1253 
1255 static inline void stateSetVerticalWindspeed_i(int32_t v_windspeed)
1256 {
1257  state.windspeed_i.vect3.z = v_windspeed;
1258  /* clear bits for all vertical windspeed representations and only set the new one */
1259  ClearBit(state.wind_air_status, DOWNWIND_F);
1260  SetBit(state.wind_air_status, DOWNWIND_I);
1261 }
1262 
1264 static inline void stateSetAirspeed_i(int32_t airspeed)
1265 {
1266  state.airspeed_i = airspeed;
1267  /* clear bits for all airspeed representations and only set the new one */
1268  ClearBit(state.wind_air_status, AIRSPEED_F);
1269  SetBit(state.wind_air_status, AIRSPEED_I);
1270 }
1271 
1273 static inline void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
1274 {
1275  VECT2_COPY(state.windspeed_f.vect2, *h_windspeed);
1276  /* clear bits for all horizontal windspeed representations and only set the new one */
1277  ClearBit(state.wind_air_status, WINDSPEED_I);
1279 }
1280 
1282 static inline void stateSetVerticalWindspeed_f(float v_windspeed)
1283 {
1284  state.windspeed_f.vect3.z = v_windspeed;
1285  /* clear bits for all vertical windspeed representations and only set the new one */
1286  ClearBit(state.wind_air_status, DOWNWIND_I);
1287  SetBit(state.wind_air_status, DOWNWIND_F);
1288 }
1289 
1291 static inline void stateSetAirspeed_f(float airspeed)
1292 {
1293  state.airspeed_f = airspeed;
1294  /* clear bits for all airspeed representations and only set the new one */
1295  ClearBit(state.wind_air_status, AIRSPEED_I);
1296  SetBit(state.wind_air_status, AIRSPEED_F);
1297 }
1298 
1300 static inline void stateSetAngleOfAttack_f(float aoa)
1301 {
1302  state.angle_of_attack_f = aoa;
1303  /* clear bits for all AOA representations and only set the new one */
1305  SetBit(state.wind_air_status, AOA_F);
1306 }
1307 
1309 static inline void stateSetSideslip_f(float sideslip)
1310 {
1311  state.sideslip_f = sideslip;
1312  /* clear bits for all sideslip representations and only set the new one */
1314  SetBit(state.wind_air_status, SIDESLIP_F);
1315 }
1316 
1317 /************************ Get functions ****************************/
1318 
1320 static inline struct Int32Vect2 *stateGetHorizontalWindspeed_i(void)
1321 {
1322  if (!bit_is_set(state.wind_air_status, WINDSPEED_I)) {
1324  }
1325  return &state.windspeed_i.vect2;
1326 }
1327 
1329 static inline float stateGetVerticalWindspeed_i(void)
1330 {
1331  if (!bit_is_set(state.wind_air_status, DOWNWIND_I)) {
1333  }
1334  return state.windspeed_i.vect3.z;
1335 }
1336 
1338 static inline struct Int32Vect3 *stateGetWindspeed_i(void)
1339 {
1340  if (!bit_is_set(state.wind_air_status, WINDSPEED_I)) {
1342  }
1343  if (!bit_is_set(state.wind_air_status, DOWNWIND_I)) {
1345  }
1346  return &state.windspeed_i.vect3;
1347 }
1348 
1350 static inline int32_t stateGetAirspeed_i(void)
1351 {
1352  if (!bit_is_set(state.wind_air_status, AIRSPEED_I)) {
1354  }
1355  return state.airspeed_i;
1356 }
1357 
1359 static inline struct FloatVect2 *stateGetHorizontalWindspeed_f(void)
1360 {
1361  if (!bit_is_set(state.wind_air_status, WINDSPEED_F)) {
1363  }
1364  return &state.windspeed_f.vect2;
1365 }
1366 
1368 static inline float stateGetVerticalWindspeed_f(void)
1369 {
1370  if (!bit_is_set(state.wind_air_status, DOWNWIND_F)) {
1372  }
1373  return state.windspeed_f.vect3.z;
1374 }
1375 
1377 static inline struct FloatVect3 *stateGetWindspeed_f(void)
1378 {
1379  if (!bit_is_set(state.wind_air_status, WINDSPEED_F)) {
1381  }
1382  if (!bit_is_set(state.wind_air_status, DOWNWIND_F)) {
1384  }
1385  return &state.windspeed_f.vect3;
1386 }
1387 
1389 static inline float stateGetAirspeed_f(void)
1390 {
1391  if (!bit_is_set(state.wind_air_status, AIRSPEED_F)) {
1393  }
1394  return state.airspeed_f;
1395 }
1396 
1398 static inline float stateGetAngleOfAttack_f(void)
1399 {
1401 // if (!bit_is_set(state.wind_air_status, AOA_F))
1402 // stateCalcAOA_f();
1403  return state.angle_of_attack_f;
1404 }
1405 
1407 static inline float stateGetSideslip_f(void)
1408 {
1410 // if (!bit_is_set(state.wind_air_status, SIDESLIP_F))
1411 // stateCalcSideslip_f();
1412  return state.sideslip_f;
1413 }
1414 
1420 #endif /* STATE_H */
static void stateSetPositionEcef_f(struct EcefCoor_f *ecef_pos)
Set position from ECEF coordinates (float).
Definition: state.h:584
static void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
Set position from local NED coordinates (int).
Definition: state.h:525
#define POS_ENU_F
Definition: state.h:74
unsigned short uint16_t
Definition: types.h:16
struct EnuCoor_i enu_speed_i
Velocity in East North Up coordinates.
Definition: state.h:279
angular rates
#define ACCEL_ECEF_I
Definition: state.h:102
bool utm_initialized_f
True if utm origin (float) coordinate frame is initialsed.
Definition: state.h:236
static void stateSetNedToBodyRMat_f(struct FloatRMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (float).
Definition: state.h:1081
static int32_t stateGetHorizontalSpeedDir_i(void)
Get dir of horizontal ground speed (int).
Definition: state.h:887
void stateCalcVerticalWindspeed_i(void)
Definition: state.c:1137
static void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (float).
Definition: state.h:1087
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
#define POS_LLA_I
Definition: state.h:70
#define RATE_F
Definition: state.h:113
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition: state.h:923
definition of the local (flat earth) coordinate system
void stateCalcAccelNed_i(void)
Definition: state.c:953
definition of the local (flat earth) coordinate system
#define AIRSPEED_F
Definition: state.h:125
#define WINDSPEED_I
Definition: state.h:120
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1125
static void stateSetSpeed_f(struct EcefCoor_f *ecef_speed, struct NedCoor_f *ned_speed, struct EnuCoor_f *enu_speed)
Set multiple speed coordinates (float).
Definition: state.h:827
static bool stateIsLocalCoordinateValid(void)
Test if local coordinates are valid.
Definition: state.h:502
static struct EcefCoor_i * stateGetPositionEcef_i(void)
Get position in ECEF coordinates (int).
Definition: state.h:650
float h_speed_dir_f
Direction of horizontal ground speed.
Definition: state.h:321
void stateCalcHorizontalWindspeed_i(void)
Definition: state.c:1123
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
Definition: state.h:1101
float airspeed_f
Norm of relative air speed.
Definition: state.h:425
void stateCalcAirspeed_i(void)
Definition: state.c:1150
vector in EarthCenteredEarthFixed coordinates
vector in EarthCenteredEarthFixed coordinates
static void stateSetAccelEcef_f(struct EcefCoor_f *ecef_accel)
Set acceleration in ECEF coordinates (float).
Definition: state.h:992
struct EcefCoor_i ecef_pos_i
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:150
struct FloatRates body_rates_f
Angular rates in body frame.
Definition: state.h:384
struct Int32RMat ltp_of_ecef
Rotation matrix.
static void stateSetHorizontalWindspeed_i(struct Int32Vect2 *h_windspeed)
Set horizontal windspeed (int).
Definition: state.h:1246
static float stateGetVerticalWindspeed_f(void)
Get vertical windspeed (float).
Definition: state.h:1368
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
Definition: state.h:220
vector in East North Up coordinates Units: meters
static struct Int32Eulers * orientationGetEulers_i(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (int).
#define SPEED_ENU_F
Definition: state.h:92
#define HIGH_RES_RMAT_FLOAT_OF_BFP(_ef, _ei)
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
#define VECT3_COPY(_a, _b)
Definition: pprz_algebra.h:139
static struct EcefCoor_f * stateGetAccelEcef_f(void)
Get acceleration in ECEF coordinates (float).
Definition: state.h:1029
void stateCalcSpeedEnu_f(void)
Definition: state.c:819
bool ned_initialized_f
True if local float coordinate frame is initialsed.
Definition: state.h:223
struct LlaCoor_i lla_pos_i
Position in Latitude, Longitude and Altitude.
Definition: state.h:157
#define POS_UTM_F
Definition: state.h:76
static void stateSetSpeedEcef_f(struct EcefCoor_f *ecef_speed)
Set ground speed in ECEF coordinates (float).
Definition: state.h:819
struct LlaCoor_f lla_pos_f
Position in Latitude, Longitude and Altitude.
Definition: state.h:205
struct EcefCoor_f ecef_pos_f
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:211
float h_speed_norm_f
Norm of horizontal ground speed.
Definition: state.h:315
#define SPEED_NED_I
Definition: state.h:86
struct EcefCoor_i ecef_accel_i
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:344
struct NedCoor_i ned_speed_i
Velocity in North East Down coordinates.
Definition: state.h:273
#define VECT2_COPY(_a, _b)
Definition: pprz_algebra.h:67
uint8_t rate_status
Holds the status bits for all angular rate representations.
Definition: state.h:372
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
Definition: state.h:1075
static float stateGetAirspeed_f(void)
Get airspeed (float).
Definition: state.h:1389
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
Definition: state.h:722
static void stateSetPositionEcef_i(struct EcefCoor_i *ecef_pos)
Set position from ECEF coordinates (int).
Definition: state.h:517
static bool orienationCheckValid(struct OrientationReps *orientation)
Test if orientations are valid.
#define POS_NED_F
Definition: state.h:73
void stateCalcPositionEcef_f(void)
Definition: state.c:352
void stateCalcBodyRates_i(void)
Definition: state.c:1086
int32_t h_speed_dir_i
Direction of horizontal ground speed.
Definition: state.h:292
static struct FloatVect3 * stateGetWindspeed_f(void)
Get windspeed (float).
Definition: state.h:1377
static bool stateIsAirspeedValid(void)
test if air speed is available.
Definition: state.h:1226
static void stateSetPosition_i(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:549
position in UTM coordinates Units: meters
#define POS_NED_I
Definition: state.h:68
vector in Latitude, Longitude and Altitude
static void stateSetSpeedNed_i(struct NedCoor_i *ned_speed)
Set ground speed in local NED coordinates (int).
Definition: state.h:757
void stateCalcHorizontalSpeedNorm_i(void)
Definition: state.c:696
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition: state.h:713
static bool stateIsWindspeedValid(void)
test if wind speed is available.
Definition: state.h:1214
static struct EcefCoor_f * stateGetPositionEcef_f(void)
Get position in ECEF coordinates (float).
Definition: state.h:695
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
Definition: state.h:1095
static void orientationSetQuat_i(struct OrientationReps *orientation, struct Int32Quat *quat)
Set vehicle body attitude from quaternion (int).
static struct EcefCoor_f * stateGetSpeedEcef_f(void)
Get ground speed in ECEF coordinates (float).
Definition: state.h:914
void stateCalcSpeedNed_f(void)
Definition: state.c:770
struct EcefCoor_i ecef
Reference point in ecef.
int32_t hmsl
Height above mean sea level in mm.
static struct EcefCoor_i * stateGetSpeedEcef_i(void)
Get ground speed in ECEF coordinates (int).
Definition: state.h:869
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
Definition: state.h:1113
euler angles
static void stateSetSpeedEnu_i(struct EnuCoor_i *enu_speed)
Set ground speed in local ENU coordinates (int).
Definition: state.h:765
Roation quaternion.
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
Definition: state.h:1119
#define POS_GLOBAL_COORD
Definition: state.h:78
static void stateSetAngleOfAttack_f(float aoa)
Set angle of attack in radians (float).
Definition: state.h:1300
struct EcefCoor_f ecef
origin of local frame in ECEF
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
Definition: state.h:576
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
Definition: state.h:968
Paparazzi floating point math for geodetic calculations.
void stateInit(void)
Definition: state.c:43
struct NedCoor_f ned_pos_f
Position in North East Down coordinates.
Definition: state.h:243
vector in Latitude, Longitude and Altitude
struct NedCoor_i ned_accel_i
Acceleration in North East Down coordinates.
Definition: state.h:338
static struct Int32Vect2 * stateGetHorizontalWindspeed_i(void)
Get horizontal windspeed (int).
Definition: state.h:1320
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
Definition: state.h:851
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
Definition: state.h:803
static void orientationSetEulers_i(struct OrientationReps *orientation, struct Int32Eulers *eulers)
Set vehicle body attitude from euler angles (int).
void stateCalcSpeedEnu_i(void)
Definition: state.c:621
#define ACCEL_ECEF_F
Definition: state.h:104
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1173
uint16_t speed_status
Holds the status bits for all ground speed representations.
Definition: state.h:261
static bool stateIsAttitudeValid(void)
Test if attitudes are valid.
Definition: state.h:1049
static bool stateIsRateValid(void)
Test if rates are valid.
Definition: state.h:1147
#define SPEED_HNORM_I
Definition: state.h:88
vector in North East Down coordinates Units: meters
Paparazzi floating point algebra.
static void orientationSetRMat_i(struct OrientationReps *orientation, struct Int32RMat *rmat)
Set vehicle body attitude from rotation matrix (int).
union State::@321 windspeed_i
Horizontal windspeed in north/east/down.
#define SIDESLIP_F
Definition: state.h:127
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
Definition: state.h:896
static bool stateIsSideslipValid(void)
test if sideslip is available.
Definition: state.h:1238
float hmsl
Height above mean sea level in meters.
void stateCalcHorizontalSpeedNorm_f(void)
Definition: state.c:892
static void stateSetPosition_f(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:616
#define SPEED_HDIR_I
Definition: state.h:89
static void stateSetPositionLla_i(struct LlaCoor_i *lla_pos)
Set position from LLA coordinates (int).
Definition: state.h:541
#define AIRSPEED_I
Definition: state.h:122
static void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
Definition: state.h:451
void stateCalcPositionEnu_i(void)
Definition: state.c:178
static void stateSetPositionEnu_f(struct EnuCoor_f *enu_pos)
Set position from local ENU coordinates (float).
Definition: state.h:600
#define SPEED_ECEF_I
Definition: state.h:85
euler angles
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
Definition: state.h:1020
static int32_t stateGetAirspeed_i(void)
Get airspeed (int).
Definition: state.h:1350
unsigned long uint32_t
Definition: types.h:18
float sideslip_f
Sideslip angle Unit: rad.
Definition: state.h:437
void stateCalcPositionLla_i(void)
Calculate LLA (int) from any other available representation.
Definition: state.c:263
uint8_t accel_status
Holds the status bits for all acceleration representations.
Definition: state.h:332
struct LlaCoor_i lla
Reference point in lla.
static void stateSetAirspeed_i(int32_t airspeed)
Set airspeed (int).
Definition: state.h:1264
static uint32_t stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition: state.h:878
void stateCalcSpeedEcef_i(void)
Definition: state.c:672
void stateCalcPositionUtm_f(void)
Definition: state.c:316
void stateCalcPositionNed_f(void)
Definition: state.c:382
void stateCalcHorizontalSpeedDir_i(void)
Definition: state.c:741
Paparazzi fixed point math for geodetic calculations.
struct EnuCoor_f enu_speed_f
Velocity in East North Up coordinates.
Definition: state.h:309
void stateCalcAccelEcef_f(void)
Definition: state.c:1047
static void stateSetBodyRates_i(struct Int32Rates *body_rate)
Set vehicle body angular rate (int).
Definition: state.h:1155
static float stateGetAngleOfAttack_f(void)
Get angle of attack (float).
Definition: state.h:1398
static void stateSetVerticalWindspeed_i(int32_t v_windspeed)
Set vertical windspeed (int).
Definition: state.h:1255
static void stateSetPositionNed_f(struct NedCoor_f *ned_pos)
Set position from local NED coordinates (float).
Definition: state.h:592
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
Definition: state.h:233
void stateCalcAccelNed_f(void)
Definition: state.c:1015
void stateCalcBodyRates_f(void)
Definition: state.c:1099
#define LLA_COPY(_pos1, _pos2)
Definition: pprz_geodetic.h:53
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
Definition: state.h:1182
#define DOWNWIND_I
Definition: state.h:121
signed long int32_t
Definition: types.h:19
bool ned_initialized_i
true if local int coordinate frame is initialsed
Definition: state.h:171
float alt_agl_f
Altitude above ground level.
Definition: state.h:198
static void stateSetNedToBodyQuat_i(struct Int32Quat *ned_to_body_quat)
Set vehicle body attitude from quaternion (int).
Definition: state.h:1057
struct FloatRMat ltp_of_ecef
rotation from ECEF to local frame
static void stateSetNedToBodyEulers_i(struct Int32Eulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (int).
Definition: state.h:1069
#define ACCEL_NED_F
Definition: state.h:105
#define POS_ECEF_I
Definition: state.h:67
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:166
void stateCalcAccelEcef_i(void)
Definition: state.c:985
int32_t airspeed_i
Norm of relative wind speed.
Definition: state.h:410
#define SPEED_ENU_I
Definition: state.h:87
static bool stateIsAngleOfAttackValid(void)
test if angle of attack is available.
Definition: state.h:1232
#define WINDSPEED_F
Definition: state.h:123
void stateCalcSpeedEcef_f(void)
Definition: state.c:868
#define POS_LLA_F
Definition: state.h:75
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
Definition: state.h:932
static bool stateIsGlobalCoordinateValid(void)
Test if global coordinates are valid.
Definition: state.h:509
static void stateSetVerticalWindspeed_f(float v_windspeed)
Set vertical windspeed (float).
Definition: state.h:1282
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition: state.h:686
static bool stateIsAccelValid(void)
Test if accelerations are valid.
Definition: state.h:960
vector in East North Up coordinates
unsigned char uint8_t
Definition: types.h:14
Structure holding vehicle state data.
Definition: state.h:134
static struct Int32Quat * orientationGetQuat_i(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (int).
vector in North East Down coordinates
struct Int32Rates body_rates_i
Angular rates in body frame.
Definition: state.h:378
static void stateSetSpeed_i(struct EcefCoor_i *ecef_speed, struct NedCoor_i *ned_speed, struct EnuCoor_i *enu_speed)
Set multiple speed coordinates (int).
Definition: state.h:781
static void stateSetAccelEcef_i(struct EcefCoor_i *ecef_accel)
Set acceleration in ECEF coordinates (int).
Definition: state.h:976
void stateCalcPositionEnu_f(void)
Definition: state.c:448
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition: state.h:905
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition: state.h:860
uint8_t wind_air_status
Holds the status bits for all wind- and airspeed representations.
Definition: state.h:395
static void stateSetPositionLla_f(struct LlaCoor_f *lla_pos)
Set position from LLA coordinates (float).
Definition: state.h:608
static float stateGetSideslip_f(void)
Get sideslip (float).
Definition: state.h:1407
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
Definition: state.h:1359
void stateCalcHorizontalSpeedDir_f(void)
Definition: state.c:917
static struct FloatEulers * orientationGetEulers_f(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (float).
struct NedCoor_f ned_accel_f
Acceleration in North East Down coordinates.
Definition: state.h:350
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
Definition: state.h:1291
#define SPEED_NED_F
Definition: state.h:91
rotation matrix
struct UtmCoor_f utm_pos_f
Position in UTM coordinates.
Definition: state.h:192
uint32_t h_speed_norm_i
Norm of horizontal ground speed.
Definition: state.h:285
struct EcefCoor_f ecef_speed_f
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:298
#define SPEED_LOCAL_COORD
Definition: state.h:95
struct EcefCoor_i ecef_speed_i
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:267
static void orientationSetRMat_f(struct OrientationReps *orientation, struct FloatRMat *rmat)
Set vehicle body attitude from rotation matrix (float).
rotation matrix
void stateCalcPositionNed_i(void)
Definition: state.c:99
static void stateSetSpeedEcef_i(struct EcefCoor_i *ecef_speed)
Set ground speed in ECEF coordinates (int).
Definition: state.h:773
#define M_OF_MM(_mm)
void stateCalcAirspeed_f(void)
Definition: state.c:1190
union State::@322 windspeed_f
Horizontal windspeed.
void stateCalcSpeedNed_i(void)
Definition: state.c:572
struct NedCoor_f ned_speed_f
speed in North East Down coordinates
Definition: state.h:303
struct EnuCoor_i enu_pos_i
Position in East North Up coordinates.
Definition: state.h:185
float angle_of_attack_f
Angle of attack Unit: rad.
Definition: state.h:431
#define RATES_COPY(_a, _b)
Definition: pprz_algebra.h:336
uint16_t pos_status
Holds the status bits for all position representations.
Definition: state.h:144
#define SPEED_HDIR_F
Definition: state.h:94
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
Definition: state.h:659
#define ECEF_FLOAT_OF_BFP(_o, _i)
static void stateSetSpeedEnu_f(struct EnuCoor_f *enu_speed)
Set ground speed in local ENU coordinates (float).
Definition: state.h:811
#define AOA_F
Definition: state.h:126
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition: state.h:668
static float stateGetVerticalWindspeed_i(void)
Get vertical windspeed (int).
Definition: state.h:1329
static struct Int32Vect3 * stateGetWindspeed_i(void)
Get windspeed (int).
Definition: state.h:1338
static bool stateIsVerticalWindspeedValid(void)
test if vertical wind speed is available.
Definition: state.h:1220
void stateCalcPositionEcef_i(void)
Definition: state.c:68
#define POS_LOCAL_COORD
Definition: state.h:77
Generic orientation representation and conversions.
static void stateSetSideslip_f(float sideslip)
Set sideslip angle in radians (float).
Definition: state.h:1309
struct EnuCoor_f enu_pos_f
Position in East North Up coordinates.
Definition: state.h:250
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
Definition: state.h:1107
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
Definition: state.h:1163
void stateCalcPositionLla_f(void)
Definition: state.c:520
struct EcefCoor_f ecef_accel_f
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:356
static void stateSetPositionEnu_i(struct EnuCoor_i *enu_pos)
Set position from local ENU coordinates (int).
Definition: state.h:533
struct OrientationReps ned_to_body_orientation
Definition: state.h:362
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
Definition: state.h:704
static void stateSetNedToBodyRMat_i(struct Int32RMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (int).
Definition: state.h:1063
#define POS_ECEF_F
Definition: state.h:72
static void stateSetAccelNed_f(struct NedCoor_f *ned_accel)
Set acceleration in NED coordinates (float).
Definition: state.h:984
static struct EcefCoor_i * stateGetAccelEcef_i(void)
Get acceleration in ECEF coordinates (int).
Definition: state.h:1011
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
Definition: state.h:471
#define SPEED_ECEF_F
Definition: state.h:90
#define RATE_I
Definition: state.h:112
Rotation quaternion.
#define ACCEL_NED_I
Definition: state.h:103
struct LlaCoor_f lla
origin of local frame in LLA
#define POS_ENU_I
Definition: state.h:69
angular rates
#define LLA_FLOAT_OF_BFP(_o, _i)
static struct LlaCoor_i * stateGetPositionLla_i(void)
Get position in LLA coordinates (int).
Definition: state.h:677
struct NedCoor_i ned_pos_i
Position in North East Down coordinates.
Definition: state.h:178
void stateCalcVerticalWindspeed_f(void)
Definition: state.c:1177
#define SPEED_HNORM_F
Definition: state.h:93
struct State state
Definition: state.c:36
static struct NedCoor_i * stateGetAccelNed_i(void)
Get acceleration in NED coordinates (int).
Definition: state.h:1002
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
Paparazzi fixed point algebra.
void stateCalcHorizontalWindspeed_f(void)
Definition: state.c:1163
#define DOWNWIND_F
Definition: state.h:124
static void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
Set horizontal windspeed (float).
Definition: state.h:1273
static void orientationSetEulers_f(struct OrientationReps *orientation, struct FloatEulers *eulers)
Set vehicle body attitude from euler angles (float).