Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 
65 #define POS_ECEF_I 0
66 #define POS_NED_I 1
67 #define POS_ENU_I 2
68 #define POS_LLA_I 3
69 #define POS_UTM_I 4
70 #define POS_ECEF_F 5
71 #define POS_NED_F 6
72 #define POS_ENU_F 7
73 #define POS_LLA_F 8
74 #define POS_UTM_F 9
75 #define POS_LOCAL_COORD ((1<<POS_NED_I)|(1<<POS_NED_F)|(1<<POS_ENU_I)|(1<<POS_ENU_F))
76 #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))
77 
83 #define SPEED_ECEF_I 0
84 #define SPEED_NED_I 1
85 #define SPEED_ENU_I 2
86 #define SPEED_HNORM_I 3
87 #define SPEED_HDIR_I 4
88 #define SPEED_ECEF_F 5
89 #define SPEED_NED_F 6
90 #define SPEED_ENU_F 7
91 #define SPEED_HNORM_F 8
92 #define SPEED_HDIR_F 9
93 #define SPEED_LOCAL_COORD ((1<<SPEED_NED_I)|(1<<SPEED_ENU_I)|(1<<SPEED_NED_F)|(1<<SPEED_ENU_F))
94 
100 #define ACCEL_ECEF_I 0
101 #define ACCEL_NED_I 1
102 #define ACCEL_ECEF_F 2
103 #define ACCEL_NED_F 3
104 
110 #define RATE_I 0
111 #define RATE_F 1
112 
118 #define WINDSPEED_I 0
119 #define AIRSPEED_I 1
120 #define WINDSPEED_F 2
121 #define AIRSPEED_F 3
122 #define AOA_F 4
123 #define SIDESLIP_F 5
124 
130 struct State {
131 
141 
147 
154 
163 
168 
175 
182 
189 
194  float alt_agl_f;
195 
202 
208 
217 
220 
229 
232 
239 
257 
263 
269 
275 
281 
288 
294 
299 
305 
311 
328 
334 
340 
346 
358 
359 
368 
374 
391 
397 
403 
409 
414  float airspeed_f;
415 
421 
426  float sideslip_f;
427 
430 };
431 
432 extern struct State state;
433 
434 extern void stateInit(void);
435 
439 static inline void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
441 {
442  state.ned_origin_i = *ltp_def;
443  /* convert to float */
448 
449  /* clear bits for all local frame representations */
452  ClearBit(state.accel_status, ACCEL_NED_I);
453  ClearBit(state.accel_status, ACCEL_NED_F);
454 
457 }
458 
460 static inline void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
461 {
462  state.utm_origin_f = *utm_def;
464 
465  /* clear bits for all local frame representations */
468  ClearBit(state.accel_status, ACCEL_NED_I);
469  ClearBit(state.accel_status, ACCEL_NED_F);
470 }
471 /*******************************************************************************
472  * *
473  * Set and Get functions for the POSITION representations *
474  * *
475  ******************************************************************************/
476 
477 /************* declaration of transformation functions ************/
478 extern void stateCalcPositionEcef_i(void);
479 extern void stateCalcPositionNed_i(void);
480 extern void stateCalcPositionEnu_i(void);
481 extern void stateCalcPositionLla_i(void);
482 extern void stateCalcPositionUtm_f(void);
483 extern void stateCalcPositionEcef_f(void);
484 extern void stateCalcPositionNed_f(void);
485 extern void stateCalcPositionEnu_f(void);
486 extern void stateCalcPositionLla_f(void);
487 
488 /*********************** validity test functions ******************/
489 
491 static inline bool_t stateIsLocalCoordinateValid(void)
492 {
494  && (state.pos_status & (POS_LOCAL_COORD)));
495 }
496 
498 static inline bool_t stateIsGlobalCoordinateValid(void)
499 {
501 }
502 
503 /************************ Set functions ****************************/
504 
506 static inline void stateSetPositionEcef_i(struct EcefCoor_i *ecef_pos)
507 {
508  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
509  /* clear bits for all position representations and only set the new one */
510  state.pos_status = (1 << POS_ECEF_I);
511 }
512 
514 static inline void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
515 {
516  VECT3_COPY(state.ned_pos_i, *ned_pos);
517  /* clear bits for all position representations and only set the new one */
518  state.pos_status = (1 << POS_NED_I);
519 }
520 
522 static inline void stateSetPositionEnu_i(struct EnuCoor_i *enu_pos)
523 {
524  VECT3_COPY(state.enu_pos_i, *enu_pos);
525  /* clear bits for all position representations and only set the new one */
526  state.pos_status = (1 << POS_ENU_I);
527 }
528 
530 static inline void stateSetPositionLla_i(struct LlaCoor_i *lla_pos)
531 {
532  LLA_COPY(state.lla_pos_i, *lla_pos);
533  /* clear bits for all position representations and only set the new one */
534  state.pos_status = (1 << POS_LLA_I);
535 }
536 
538 static inline void stateSetPosition_i(
539  struct EcefCoor_i *ecef_pos,
540  struct NedCoor_i *ned_pos,
541  struct EnuCoor_i *enu_pos,
542  struct LlaCoor_i *lla_pos)
543 {
544  /* clear all status bit */
545  state.pos_status = 0;
546  if (ecef_pos != NULL) {
547  VECT3_COPY(state.ecef_pos_i, *ecef_pos);
548  state.pos_status |= (1 << POS_ECEF_I);
549  }
550  if (ned_pos != NULL) {
551  VECT3_COPY(state.ned_pos_i, *ned_pos);
552  state.pos_status |= (1 << POS_NED_I);
553  }
554  if (enu_pos != NULL) {
555  VECT3_COPY(state.enu_pos_i, *enu_pos);
556  state.pos_status |= (1 << POS_ENU_I);
557  }
558  if (lla_pos != NULL) {
559  LLA_COPY(state.lla_pos_i, *lla_pos);
560  state.pos_status |= (1 << POS_LLA_I);
561  }
562 }
563 
565 static inline void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
566 {
567  state.utm_pos_f = *utm_pos;
568  /* clear bits for all position representations and only set the new one */
569  state.pos_status = (1 << POS_UTM_F);
570 }
571 
573 static inline void stateSetPositionEcef_f(struct EcefCoor_f *ecef_pos)
574 {
575  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
576  /* clear bits for all position representations and only set the new one */
577  state.pos_status = (1 << POS_ECEF_F);
578 }
579 
581 static inline void stateSetPositionNed_f(struct NedCoor_f *ned_pos)
582 {
583  VECT3_COPY(state.ned_pos_f, *ned_pos);
584  /* clear bits for all position representations and only set the new one */
585  state.pos_status = (1 << POS_NED_F);
586 }
587 
589 static inline void stateSetPositionEnu_f(struct EnuCoor_f *enu_pos)
590 {
591  VECT3_COPY(state.enu_pos_f, *enu_pos);
592  /* clear bits for all position representations and only set the new one */
593  state.pos_status = (1 << POS_ENU_F);
594 }
595 
597 static inline void stateSetPositionLla_f(struct LlaCoor_f *lla_pos)
598 {
599  LLA_COPY(state.lla_pos_f, *lla_pos);
600  /* clear bits for all position representations and only set the new one */
601  state.pos_status = (1 << POS_LLA_F);
602 }
603 
605 static inline void stateSetPosition_f(
606  struct EcefCoor_f *ecef_pos,
607  struct NedCoor_f *ned_pos,
608  struct EnuCoor_f *enu_pos,
609  struct LlaCoor_f *lla_pos,
610  struct UtmCoor_f *utm_pos)
611 {
612  /* clear all status bit */
613  state.pos_status = 0;
614  if (ecef_pos != NULL) {
615  VECT3_COPY(state.ecef_pos_f, *ecef_pos);
616  state.pos_status |= (1 << POS_ECEF_F);
617  }
618  if (ned_pos != NULL) {
619  VECT3_COPY(state.ned_pos_f, *ned_pos);
620  state.pos_status |= (1 << POS_NED_F);
621  }
622  if (enu_pos != NULL) {
623  VECT3_COPY(state.enu_pos_f, *enu_pos);
624  state.pos_status |= (1 << POS_ENU_F);
625  }
626  if (lla_pos != NULL) {
627  LLA_COPY(state.lla_pos_f, *lla_pos);
628  state.pos_status |= (1 << POS_LLA_F);
629  }
630  if (utm_pos != NULL) {
631  state.utm_pos_f = *utm_pos;
632  state.pos_status |= (1 << POS_UTM_F);
633  }
634 }
635 
636 /************************ Get functions ****************************/
637 
639 static inline struct EcefCoor_i *stateGetPositionEcef_i(void)
640 {
641  if (!bit_is_set(state.pos_status, POS_ECEF_I)) {
643  }
644  return &state.ecef_pos_i;
645 }
646 
648 static inline struct NedCoor_i *stateGetPositionNed_i(void)
649 {
650  if (!bit_is_set(state.pos_status, POS_NED_I)) {
652  }
653  return &state.ned_pos_i;
654 }
655 
657 static inline struct EnuCoor_i *stateGetPositionEnu_i(void)
658 {
659  if (!bit_is_set(state.pos_status, POS_ENU_I)) {
661  }
662  return &state.enu_pos_i;
663 }
664 
666 static inline struct LlaCoor_i *stateGetPositionLla_i(void)
667 {
668  if (!bit_is_set(state.pos_status, POS_LLA_I)) {
670  }
671  return &state.lla_pos_i;
672 }
673 
675 static inline struct UtmCoor_f *stateGetPositionUtm_f(void)
676 {
677  if (!bit_is_set(state.pos_status, POS_UTM_F)) {
679  }
680  return &state.utm_pos_f;
681 }
682 
684 static inline struct EcefCoor_f *stateGetPositionEcef_f(void)
685 {
686  if (!bit_is_set(state.pos_status, POS_ECEF_F)) {
688  }
689  return &state.ecef_pos_f;
690 }
691 
693 static inline struct NedCoor_f *stateGetPositionNed_f(void)
694 {
695  if (!bit_is_set(state.pos_status, POS_NED_F)) {
697  }
698  return &state.ned_pos_f;
699 }
700 
702 static inline struct EnuCoor_f *stateGetPositionEnu_f(void)
703 {
704  if (!bit_is_set(state.pos_status, POS_ENU_F)) {
706  }
707  return &state.enu_pos_f;
708 }
709 
711 static inline struct LlaCoor_f *stateGetPositionLla_f(void)
712 {
713  if (!bit_is_set(state.pos_status, POS_LLA_F)) {
715  }
716  return &state.lla_pos_f;
717 }
718 
723 /******************************************************************************
724  * *
725  * Set and Get functions for the SPEED representations *
726  * *
727  *****************************************************************************/
731 /************* declaration of transformation functions ************/
732 extern void stateCalcSpeedNed_i(void);
733 extern void stateCalcSpeedEnu_i(void);
734 extern void stateCalcSpeedEcef_i(void);
735 extern void stateCalcHorizontalSpeedNorm_i(void);
736 extern void stateCalcHorizontalSpeedDir_i(void);
737 extern void stateCalcSpeedNed_f(void);
738 extern void stateCalcSpeedEnu_f(void);
739 extern void stateCalcSpeedEcef_f(void);
740 extern void stateCalcHorizontalSpeedNorm_f(void);
741 extern void stateCalcHorizontalSpeedDir_f(void);
742 
743 /************************ Set functions ****************************/
744 
746 static inline void stateSetSpeedNed_i(struct NedCoor_i *ned_speed)
747 {
748  VECT3_COPY(state.ned_speed_i, *ned_speed);
749  /* clear bits for all speed representations and only set the new one */
750  state.speed_status = (1 << SPEED_NED_I);
751 }
752 
754 static inline void stateSetSpeedEnu_i(struct EnuCoor_i *enu_speed)
755 {
756  VECT3_COPY(state.enu_speed_i, *enu_speed);
757  /* clear bits for all speed representations and only set the new one */
758  state.speed_status = (1 << SPEED_ENU_I);
759 }
760 
762 static inline void stateSetSpeedEcef_i(struct EcefCoor_i *ecef_speed)
763 {
764  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
765  /* clear bits for all speed representations and only set the new one */
767 }
768 
770 static inline void stateSetSpeed_i(
771  struct EcefCoor_i *ecef_speed,
772  struct NedCoor_i *ned_speed,
773  struct EnuCoor_i *enu_speed)
774 {
775  /* clear all status bit */
776  state.speed_status = 0;
777  if (ecef_speed != NULL) {
778  VECT3_COPY(state.ecef_speed_i, *ecef_speed);
779  state.speed_status |= (1 << SPEED_ECEF_I);
780  }
781  if (ned_speed != NULL) {
782  VECT3_COPY(state.ned_speed_i, *ned_speed);
783  state.speed_status |= (1 << SPEED_NED_I);
784  }
785  if (enu_speed != NULL) {
786  VECT3_COPY(state.enu_speed_i, *enu_speed);
787  state.speed_status |= (1 << SPEED_ENU_I);
788  }
789 }
790 
792 static inline void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
793 {
794  VECT3_COPY(state.ned_speed_f, *ned_speed);
795  /* clear bits for all speed representations and only set the new one */
796  state.speed_status = (1 << SPEED_NED_F);
797 }
798 
800 static inline void stateSetSpeedEnu_f(struct EnuCoor_f *enu_speed)
801 {
802  VECT3_COPY(state.enu_speed_f, *enu_speed);
803  /* clear bits for all speed representations and only set the new one */
804  state.speed_status = (1 << SPEED_ENU_F);
805 }
806 
808 static inline void stateSetSpeedEcef_f(struct EcefCoor_f *ecef_speed)
809 {
810  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
811  /* clear bits for all speed representations and only set the new one */
813 }
814 
816 static inline void stateSetSpeed_f(
817  struct EcefCoor_f *ecef_speed,
818  struct NedCoor_f *ned_speed,
819  struct EnuCoor_f *enu_speed)
820 {
821  /* clear all status bit */
822  state.speed_status = 0;
823  if (ecef_speed != NULL) {
824  VECT3_COPY(state.ecef_speed_f, *ecef_speed);
825  state.speed_status |= (1 << SPEED_ECEF_F);
826  }
827  if (ned_speed != NULL) {
828  VECT3_COPY(state.ned_speed_f, *ned_speed);
829  state.speed_status |= (1 << SPEED_NED_F);
830  }
831  if (enu_speed != NULL) {
832  VECT3_COPY(state.enu_speed_f, *enu_speed);
833  state.speed_status |= (1 << SPEED_ENU_F);
834  }
835 }
836 
837 /************************ Get functions ****************************/
838 
840 static inline struct NedCoor_i *stateGetSpeedNed_i(void)
841 {
842  if (!bit_is_set(state.speed_status, SPEED_NED_I)) {
844  }
845  return &state.ned_speed_i;
846 }
847 
849 static inline struct EnuCoor_i *stateGetSpeedEnu_i(void)
850 {
851  if (!bit_is_set(state.speed_status, SPEED_ENU_I)) {
853  }
854  return &state.enu_speed_i;
855 }
856 
858 static inline struct EcefCoor_i *stateGetSpeedEcef_i(void)
859 {
860  if (!bit_is_set(state.speed_status, SPEED_ECEF_I)) {
862  }
863  return &state.ecef_speed_i;
864 }
865 
868 {
869  if (!bit_is_set(state.speed_status, SPEED_HNORM_I)) {
871  }
872  return state.h_speed_norm_i;
873 }
874 
877 {
878  if (!bit_is_set(state.speed_status, SPEED_HDIR_I)) {
880  }
881  return state.h_speed_dir_i;
882 }
883 
885 static inline struct NedCoor_f *stateGetSpeedNed_f(void)
886 {
887  if (!bit_is_set(state.speed_status, SPEED_NED_F)) {
889  }
890  return &state.ned_speed_f;
891 }
892 
894 static inline struct EnuCoor_f *stateGetSpeedEnu_f(void)
895 {
896  if (!bit_is_set(state.speed_status, SPEED_ENU_F)) {
898  }
899  return &state.enu_speed_f;
900 }
901 
903 static inline struct EcefCoor_f *stateGetSpeedEcef_f(void)
904 {
905  if (!bit_is_set(state.speed_status, SPEED_ECEF_F)) {
907  }
908  return &state.ecef_speed_f;
909 }
910 
912 static inline float stateGetHorizontalSpeedNorm_f(void)
913 {
914  if (!bit_is_set(state.speed_status, SPEED_HNORM_F)) {
916  }
917  return state.h_speed_norm_f;
918 }
919 
921 static inline float stateGetHorizontalSpeedDir_f(void)
922 {
923  if (!bit_is_set(state.speed_status, SPEED_HDIR_F)) {
925  }
926  return state.h_speed_dir_f;
927 }
932 /******************************************************************************
933  * *
934  * Set and Get functions for the ACCELERATION representations *
935  * *
936  *****************************************************************************/
940 /************* declaration of transformation functions ************/
941 extern void stateCalcAccelNed_i(void);
942 extern void stateCalcAccelEcef_i(void);
943 extern void stateCalcAccelNed_f(void);
944 extern void stateCalcAccelEcef_f(void);
945 
946 /*********************** validity test functions ******************/
947 
949 static inline bool_t stateIsAccelValid(void)
950 {
951  return (state.accel_status);
952 }
953 
954 /************************ Set functions ****************************/
955 
957 static inline void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
958 {
959  VECT3_COPY(state.ned_accel_i, *ned_accel);
960  /* clear bits for all accel representations and only set the new one */
961  state.accel_status = (1 << ACCEL_NED_I);
962 }
963 
965 static inline void stateSetAccelEcef_i(struct EcefCoor_i *ecef_accel)
966 {
967  VECT3_COPY(state.ecef_accel_i, *ecef_accel);
968  /* clear bits for all accel representations and only set the new one */
970 }
971 
973 static inline void stateSetAccelNed_f(struct NedCoor_f *ned_accel)
974 {
975  VECT3_COPY(state.ned_accel_f, *ned_accel);
976  /* clear bits for all accel representations and only set the new one */
977  state.accel_status = (1 << ACCEL_NED_F);
978 }
979 
981 static inline void stateSetAccelEcef_f(struct EcefCoor_f *ecef_accel)
982 {
983  VECT3_COPY(state.ecef_accel_f, *ecef_accel);
984  /* clear bits for all accel representations and only set the new one */
986 }
987 
988 /************************ Get functions ****************************/
989 
991 static inline struct NedCoor_i *stateGetAccelNed_i(void)
992 {
993  if (!bit_is_set(state.accel_status, ACCEL_NED_I)) {
995  }
996  return &state.ned_accel_i;
997 }
998 
1000 static inline struct EcefCoor_i *stateGetAccelEcef_i(void)
1001 {
1002  if (!bit_is_set(state.accel_status, ACCEL_ECEF_I)) {
1004  }
1005  return &state.ecef_accel_i;
1006 }
1007 
1009 static inline struct NedCoor_f *stateGetAccelNed_f(void)
1010 {
1011  if (!bit_is_set(state.accel_status, ACCEL_NED_F)) {
1013  }
1014  return &state.ned_accel_f;
1015 }
1016 
1018 static inline struct EcefCoor_f *stateGetAccelEcef_f(void)
1019 {
1020  if (!bit_is_set(state.accel_status, ACCEL_ECEF_F)) {
1022  }
1023  return &state.ecef_accel_f;
1024 }
1027 /******************************************************************************
1028 * *
1029 * Set and Get functions for the ATTITUDE representations *
1030 * (Calls the functions in math/pprz_orientation_conversion) *
1031 * *
1032 *****************************************************************************/
1035 /*********************** validity test functions ******************/
1036 
1038 static inline bool_t stateIsAttitudeValid(void)
1039 {
1041 }
1042 
1043 /************************ Set functions ****************************/
1044 
1046 static inline void stateSetNedToBodyQuat_i(struct Int32Quat *ned_to_body_quat)
1047 {
1049 }
1050 
1052 static inline void stateSetNedToBodyRMat_i(struct Int32RMat *ned_to_body_rmat)
1053 {
1055 }
1056 
1058 static inline void stateSetNedToBodyEulers_i(struct Int32Eulers *ned_to_body_eulers)
1059 {
1061 }
1062 
1064 static inline void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
1065 {
1067 }
1068 
1070 static inline void stateSetNedToBodyRMat_f(struct FloatRMat *ned_to_body_rmat)
1071 {
1073 }
1074 
1076 static inline void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
1077 {
1079 }
1080 
1081 /************************ Get functions ****************************/
1082 
1084 static inline struct Int32Quat *stateGetNedToBodyQuat_i(void)
1085 {
1087 }
1088 
1090 static inline struct Int32RMat *stateGetNedToBodyRMat_i(void)
1091 {
1093 }
1094 
1096 static inline struct Int32Eulers *stateGetNedToBodyEulers_i(void)
1097 {
1099 }
1100 
1102 static inline struct FloatQuat *stateGetNedToBodyQuat_f(void)
1103 {
1105 }
1106 
1108 static inline struct FloatRMat *stateGetNedToBodyRMat_f(void)
1109 {
1111 }
1112 
1114 static inline struct FloatEulers *stateGetNedToBodyEulers_f(void)
1115 {
1117 }
1121 /******************************************************************************
1122  * *
1123  * Set and Get functions for the ANGULAR RATE representations *
1124  * *
1125  *****************************************************************************/
1129 /************* declaration of transformation functions ************/
1130 extern void stateCalcBodyRates_i(void);
1131 extern void stateCalcBodyRates_f(void);
1132 
1133 /*********************** validity test functions ******************/
1134 
1136 static inline bool_t stateIsRateValid(void)
1137 {
1138  return (state.rate_status);
1139 }
1140 
1141 /************************ Set functions ****************************/
1142 
1144 static inline void stateSetBodyRates_i(struct Int32Rates *body_rate)
1145 {
1146  RATES_COPY(state.body_rates_i, *body_rate);
1147  /* clear bits for all attitude representations and only set the new one */
1148  state.rate_status = (1 << RATE_I);
1149 }
1150 
1152 static inline void stateSetBodyRates_f(struct FloatRates *body_rate)
1153 {
1154  RATES_COPY(state.body_rates_f, *body_rate);
1155  /* clear bits for all attitude representations and only set the new one */
1156  state.rate_status = (1 << RATE_F);
1157 }
1158 
1159 /************************ Get functions ****************************/
1160 
1162 static inline struct Int32Rates *stateGetBodyRates_i(void)
1163 {
1164  if (!bit_is_set(state.rate_status, RATE_I)) {
1166  }
1167  return &state.body_rates_i;
1168 }
1169 
1171 static inline struct FloatRates *stateGetBodyRates_f(void)
1172 {
1173  if (!bit_is_set(state.rate_status, RATE_F)) {
1175  }
1176  return &state.body_rates_f;
1177 }
1178 
1183 /******************************************************************************
1184  * *
1185  * Set and Get functions for the WIND- AND AIRSPEED representations *
1186  * *
1187  *****************************************************************************/
1191 /************* declaration of transformation functions ************/
1192 extern void stateCalcHorizontalWindspeed_i(void);
1193 extern void stateCalcAirspeed_i(void);
1194 extern void stateCalcHorizontalWindspeed_f(void);
1195 extern void stateCalcAirspeed_f(void);
1196 
1197 
1198 /************************ validity test function *******************/
1199 
1201 static inline bool_t stateIsWindspeedValid(void)
1202 {
1203  return (state.wind_air_status &= ~((1 << WINDSPEED_I) | (1 << WINDSPEED_F)));
1204 }
1205 
1207 static inline bool_t stateIsAirspeedValid(void)
1208 {
1209  return (state.wind_air_status &= ~((1 << AIRSPEED_I) | (1 << AIRSPEED_F)));
1210 }
1211 
1213 static inline bool_t stateIsAngleOfAttackValid(void)
1214 {
1215  return (state.wind_air_status &= ~(1 << AOA_F));
1216 }
1217 
1219 static inline bool_t stateIsSideslipValid(void)
1220 {
1221  return (state.wind_air_status &= ~(1 << SIDESLIP_F));
1222 }
1223 
1224 /************************ Set functions ****************************/
1225 
1227 static inline void stateSetHorizontalWindspeed_i(struct Int32Vect2 *h_windspeed)
1228 {
1229  VECT2_COPY(state.h_windspeed_i, *h_windspeed);
1230  /* clear bits for all windspeed representations and only set the new one */
1231  ClearBit(state.wind_air_status, WINDSPEED_F);
1233 }
1234 
1236 static inline void stateSetAirspeed_i(int32_t airspeed)
1237 {
1238  state.airspeed_i = airspeed;
1239  /* clear bits for all airspeed representations and only set the new one */
1240  ClearBit(state.wind_air_status, AIRSPEED_F);
1241  SetBit(state.wind_air_status, AIRSPEED_I);
1242 }
1243 
1245 static inline void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
1246 {
1247  VECT2_COPY(state.h_windspeed_f, *h_windspeed);
1248  /* clear bits for all windspeed representations and only set the new one */
1249  ClearBit(state.wind_air_status, WINDSPEED_I);
1251 }
1252 
1254 static inline void stateSetAirspeed_f(float airspeed)
1255 {
1256  state.airspeed_f = airspeed;
1257  /* clear bits for all airspeed representations and only set the new one */
1258  ClearBit(state.wind_air_status, AIRSPEED_I);
1259  SetBit(state.wind_air_status, AIRSPEED_F);
1260 }
1261 
1263 static inline void stateSetAngleOfAttack_f(float aoa)
1264 {
1265  state.angle_of_attack_f = aoa;
1266  /* clear bits for all AOA representations and only set the new one */
1268  SetBit(state.wind_air_status, AOA_F);
1269 }
1270 
1272 static inline void stateSetSideslip_f(float sideslip)
1273 {
1274  state.sideslip_f = sideslip;
1275  /* clear bits for all sideslip representations and only set the new one */
1277  SetBit(state.wind_air_status, SIDESLIP_F);
1278 }
1279 
1280 /************************ Get functions ****************************/
1281 
1283 static inline struct Int32Vect2 *stateGetHorizontalWindspeed_i(void)
1284 {
1285  if (!bit_is_set(state.wind_air_status, WINDSPEED_I)) {
1287  }
1288  return &state.h_windspeed_i;
1289 }
1290 
1292 static inline int32_t stateGetAirspeed_i(void)
1293 {
1294  if (!bit_is_set(state.wind_air_status, AIRSPEED_I)) {
1296  }
1297  return state.airspeed_i;
1298 }
1299 
1301 static inline struct FloatVect2 *stateGetHorizontalWindspeed_f(void)
1302 {
1303  if (!bit_is_set(state.wind_air_status, WINDSPEED_F)) {
1305  }
1306  return &state.h_windspeed_f;
1307 }
1308 
1310 static inline float stateGetAirspeed_f(void)
1311 {
1312  if (!bit_is_set(state.wind_air_status, AIRSPEED_F)) {
1314  }
1315  return state.airspeed_f;
1316 }
1317 
1319 static inline float stateGetAngleOfAttack_f(void)
1320 {
1322 // if (!bit_is_set(state.wind_air_status, AOA_F))
1323 // stateCalcAOA_f();
1324  return state.angle_of_attack_f;
1325 }
1326 
1328 static inline float stateGetSideslip_f(void)
1329 {
1331 // if (!bit_is_set(state.wind_air_status, SIDESLIP_F))
1332 // stateCalcSideslip_f();
1333  return state.sideslip_f;
1334 }
1335 
1341 #endif /* STATE_H */
static void stateSetPositionEcef_f(struct EcefCoor_f *ecef_pos)
Set position from ECEF coordinates (float).
Definition: state.h:573
static void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
Set position from local NED coordinates (int).
Definition: state.h:514
#define POS_ENU_F
Definition: state.h:72
unsigned short uint16_t
Definition: types.h:16
struct EnuCoor_i enu_speed_i
Velocity in East North Up coordinates.
Definition: state.h:274
angular rates
#define ACCEL_ECEF_I
Definition: state.h:100
static void stateSetNedToBodyRMat_f(struct FloatRMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (float).
Definition: state.h:1070
static int32_t stateGetHorizontalSpeedDir_i(void)
Get dir of horizontal ground speed (int).
Definition: state.h:876
static void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (float).
Definition: state.h:1076
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
static bool_t stateIsRateValid(void)
Test if rates are valid.
Definition: state.h:1136
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
#define POS_LLA_I
Definition: state.h:68
#define RATE_F
Definition: state.h:111
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
Definition: state.h:912
definition of the local (flat earth) coordinate system
void stateCalcAccelNed_i(void)
Definition: state.c:950
definition of the local (flat earth) coordinate system
#define AIRSPEED_F
Definition: state.h:121
#define WINDSPEED_I
Definition: state.h:118
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1114
struct FloatVect2 h_windspeed_f
Horizontal windspeed.
Definition: state.h:408
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:816
static struct EcefCoor_i * stateGetPositionEcef_i(void)
Get position in ECEF coordinates (int).
Definition: state.h:639
float h_speed_dir_f
Direction of horizontal ground speed.
Definition: state.h:316
void stateCalcHorizontalWindspeed_i(void)
Definition: state.c:1106
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
Definition: state.h:1090
float airspeed_f
Norm of relative air speed.
Definition: state.h:414
void stateCalcAirspeed_i(void)
Definition: state.c:1120
vector in EarthCenteredEarthFixed coordinates
vector in EarthCenteredEarthFixed coordinates
static bool_t stateIsAttitudeValid(void)
Test if attitudes are valid.
Definition: state.h:1038
static void stateSetAccelEcef_f(struct EcefCoor_f *ecef_accel)
Set acceleration in ECEF coordinates (float).
Definition: state.h:981
struct EcefCoor_i ecef_pos_i
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:146
struct FloatRates body_rates_f
Angular rates in body frame.
Definition: state.h:379
struct Int32RMat ltp_of_ecef
Rotation matrix.
static void stateSetHorizontalWindspeed_i(struct Int32Vect2 *h_windspeed)
Set horizontal windspeed (int).
Definition: state.h:1227
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
Definition: state.h:216
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:90
#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:1018
void stateCalcSpeedEnu_f(void)
Definition: state.c:816
struct LlaCoor_i lla_pos_i
Position in Latitude, Longitude and Altitude.
Definition: state.h:153
#define POS_UTM_F
Definition: state.h:74
static void stateSetSpeedEcef_f(struct EcefCoor_f *ecef_speed)
Set ground speed in ECEF coordinates (float).
Definition: state.h:808
struct LlaCoor_f lla_pos_f
Position in Latitude, Longitude and Altitude.
Definition: state.h:201
struct EcefCoor_f ecef_pos_f
Position in EarthCenteredEarthFixed coordinates.
Definition: state.h:207
float h_speed_norm_f
Norm of horizontal ground speed.
Definition: state.h:310
#define SPEED_NED_I
Definition: state.h:84
struct EcefCoor_i ecef_accel_i
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:339
bool_t ned_initialized_f
True if local float coordinate frame is initialsed.
Definition: state.h:219
struct NedCoor_i ned_speed_i
Velocity in North East Down coordinates.
Definition: state.h:268
#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:367
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
Definition: state.h:1064
static float stateGetAirspeed_f(void)
Get airspeed (float).
Definition: state.h:1310
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
Definition: state.h:711
static void stateSetPositionEcef_i(struct EcefCoor_i *ecef_pos)
Set position from ECEF coordinates (int).
Definition: state.h:506
#define POS_NED_F
Definition: state.h:71
void stateCalcPositionEcef_f(void)
Definition: state.c:349
struct Int32Vect2 h_windspeed_i
Horizontal windspeed in north/east.
Definition: state.h:396
void stateCalcBodyRates_i(void)
Definition: state.c:1069
int32_t h_speed_dir_i
Direction of horizontal ground speed.
Definition: state.h:287
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:538
position in UTM coordinates Units: meters
static bool_t stateIsSideslipValid(void)
test if sideslip is available.
Definition: state.h:1219
#define POS_NED_I
Definition: state.h:66
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:746
void stateCalcHorizontalSpeedNorm_i(void)
Definition: state.c:693
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition: state.h:702
static struct EcefCoor_f * stateGetPositionEcef_f(void)
Get position in ECEF coordinates (float).
Definition: state.h:684
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
Definition: state.h:1084
static bool_t stateIsWindspeedValid(void)
test if wind speed is available.
Definition: state.h:1201
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:903
void stateCalcSpeedNed_f(void)
Definition: state.c:767
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:858
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
Definition: state.h:1102
static bool_t stateIsGlobalCoordinateValid(void)
Test if global coordinates are valid.
Definition: state.h:498
euler angles
static void stateSetSpeedEnu_i(struct EnuCoor_i *enu_speed)
Set ground speed in local ENU coordinates (int).
Definition: state.h:754
Roation quaternion.
static bool_t stateIsAirspeedValid(void)
test if air speed is available.
Definition: state.h:1207
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
Definition: state.h:1108
#define POS_GLOBAL_COORD
Definition: state.h:76
static void stateSetAngleOfAttack_f(float aoa)
Set angle of attack in radians (float).
Definition: state.h:1263
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:565
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
Definition: state.h:957
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:238
vector in Latitude, Longitude and Altitude
struct NedCoor_i ned_accel_i
Acceleration in North East Down coordinates.
Definition: state.h:333
static struct Int32Vect2 * stateGetHorizontalWindspeed_i(void)
Get horizontal windspeed (int).
Definition: state.h:1283
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
Definition: state.h:840
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
Definition: state.h:792
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:618
#define TRUE
Definition: std.h:4
#define ACCEL_ECEF_F
Definition: state.h:102
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1162
uint16_t speed_status
Holds the status bits for all ground speed representations.
Definition: state.h:256
#define SPEED_HNORM_I
Definition: state.h:86
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).
#define SIDESLIP_F
Definition: state.h:123
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
Definition: state.h:885
float hmsl
Height above mean sea level in meters.
void stateCalcHorizontalSpeedNorm_f(void)
Definition: state.c:889
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:605
#define SPEED_HDIR_I
Definition: state.h:87
static void stateSetPositionLla_i(struct LlaCoor_i *lla_pos)
Set position from LLA coordinates (int).
Definition: state.h:530
#define AIRSPEED_I
Definition: state.h:119
static void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
Definition: state.h:440
void stateCalcPositionEnu_i(void)
Definition: state.c:175
static void stateSetPositionEnu_f(struct EnuCoor_f *enu_pos)
Set position from local ENU coordinates (float).
Definition: state.h:589
#define SPEED_ECEF_I
Definition: state.h:83
euler angles
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
Definition: state.h:1009
static bool_t stateIsLocalCoordinateValid(void)
Test if local coordinates are valid.
Definition: state.h:491
static int32_t stateGetAirspeed_i(void)
Get airspeed (int).
Definition: state.h:1292
unsigned long uint32_t
Definition: types.h:18
float sideslip_f
Sideslip angle Unit: rad.
Definition: state.h:426
void stateCalcPositionLla_i(void)
Calculate LLA (int) from any other available representation.
Definition: state.c:260
uint8_t accel_status
Holds the status bits for all acceleration representations.
Definition: state.h:327
struct LlaCoor_i lla
Reference point in lla.
static void stateSetAirspeed_i(int32_t airspeed)
Set airspeed (int).
Definition: state.h:1236
static uint32_t stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition: state.h:867
void stateCalcSpeedEcef_i(void)
Definition: state.c:669
void stateCalcPositionUtm_f(void)
Definition: state.c:313
void stateCalcPositionNed_f(void)
Definition: state.c:379
void stateCalcHorizontalSpeedDir_i(void)
Definition: state.c:738
Paparazzi fixed point math for geodetic calculations.
struct EnuCoor_f enu_speed_f
Velocity in East North Up coordinates.
Definition: state.h:304
static bool_t stateIsAccelValid(void)
Test if accelerations are valid.
Definition: state.h:949
void stateCalcAccelEcef_f(void)
Definition: state.c:1036
static void stateSetBodyRates_i(struct Int32Rates *body_rate)
Set vehicle body angular rate (int).
Definition: state.h:1144
static float stateGetAngleOfAttack_f(void)
Get angle of attack (float).
Definition: state.h:1319
static void stateSetPositionNed_f(struct NedCoor_f *ned_pos)
Set position from local NED coordinates (float).
Definition: state.h:581
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
Definition: state.h:228
void stateCalcAccelNed_f(void)
Definition: state.c:1005
void stateCalcBodyRates_f(void)
Definition: state.c:1082
#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:1171
signed long int32_t
Definition: types.h:19
float alt_agl_f
Altitude above ground level.
Definition: state.h:194
static void stateSetNedToBodyQuat_i(struct Int32Quat *ned_to_body_quat)
Set vehicle body attitude from quaternion (int).
Definition: state.h:1046
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:1058
#define ACCEL_NED_F
Definition: state.h:103
#define POS_ECEF_I
Definition: state.h:65
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:162
void stateCalcAccelEcef_i(void)
Definition: state.c:981
int32_t airspeed_i
Norm of relative wind speed.
Definition: state.h:402
#define SPEED_ENU_I
Definition: state.h:85
#define WINDSPEED_F
Definition: state.h:120
void stateCalcSpeedEcef_f(void)
Definition: state.c:865
#define POS_LLA_F
Definition: state.h:73
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
Definition: state.h:921
bool_t utm_initialized_f
True if utm origin (float) coordinate frame is initialsed.
Definition: state.h:231
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition: state.h:675
vector in East North Up coordinates
unsigned char uint8_t
Definition: types.h:14
Structure holding vehicle state data.
Definition: state.h:130
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:373
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:770
static void stateSetAccelEcef_i(struct EcefCoor_i *ecef_accel)
Set acceleration in ECEF coordinates (int).
Definition: state.h:965
void stateCalcPositionEnu_f(void)
Definition: state.c:445
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition: state.h:894
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition: state.h:849
uint8_t wind_air_status
Holds the status bits for all wind- and airspeed representations.
Definition: state.h:390
static void stateSetPositionLla_f(struct LlaCoor_f *lla_pos)
Set position from LLA coordinates (float).
Definition: state.h:597
static float stateGetSideslip_f(void)
Get sideslip (float).
Definition: state.h:1328
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
Definition: state.h:1301
void stateCalcHorizontalSpeedDir_f(void)
Definition: state.c:914
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:345
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
Definition: state.h:1254
static bool_t orienationCheckValid(struct OrientationReps *orientation)
Test if orientations are valid.
#define SPEED_NED_F
Definition: state.h:89
rotation matrix
struct UtmCoor_f utm_pos_f
Position in UTM coordinates.
Definition: state.h:188
uint32_t h_speed_norm_i
Norm of horizontal ground speed.
Definition: state.h:280
struct EcefCoor_f ecef_speed_f
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:293
#define SPEED_LOCAL_COORD
Definition: state.h:93
struct EcefCoor_i ecef_speed_i
Velocity in EarthCenteredEarthFixed coordinates.
Definition: state.h:262
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:96
static void stateSetSpeedEcef_i(struct EcefCoor_i *ecef_speed)
Set ground speed in ECEF coordinates (int).
Definition: state.h:762
#define M_OF_MM(_mm)
void stateCalcAirspeed_f(void)
Definition: state.c:1147
void stateCalcSpeedNed_i(void)
Definition: state.c:569
struct NedCoor_f ned_speed_f
speed in North East Down coordinates
Definition: state.h:298
struct EnuCoor_i enu_pos_i
Position in East North Up coordinates.
Definition: state.h:181
float angle_of_attack_f
Angle of attack Unit: rad.
Definition: state.h:420
#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:140
#define SPEED_HDIR_F
Definition: state.h:92
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
Definition: state.h:648
bool_t ned_initialized_i
true if local int coordinate frame is initialsed
Definition: state.h:167
#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:800
#define AOA_F
Definition: state.h:122
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition: state.h:657
void stateCalcPositionEcef_i(void)
Definition: state.c:65
#define POS_LOCAL_COORD
Definition: state.h:75
Generic orientation representation and conversions.
static void stateSetSideslip_f(float sideslip)
Set sideslip angle in radians (float).
Definition: state.h:1272
struct EnuCoor_f enu_pos_f
Position in East North Up coordinates.
Definition: state.h:245
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
Definition: state.h:1096
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
Definition: state.h:1152
void stateCalcPositionLla_f(void)
Definition: state.c:517
struct EcefCoor_f ecef_accel_f
Acceleration in EarthCenteredEarthFixed coordinates.
Definition: state.h:351
static void stateSetPositionEnu_i(struct EnuCoor_i *enu_pos)
Set position from local ENU coordinates (int).
Definition: state.h:522
struct OrientationReps ned_to_body_orientation
Definition: state.h:357
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
Definition: state.h:693
static void stateSetNedToBodyRMat_i(struct Int32RMat *ned_to_body_rmat)
Set vehicle body attitude from rotation matrix (int).
Definition: state.h:1052
#define POS_ECEF_F
Definition: state.h:70
static void stateSetAccelNed_f(struct NedCoor_f *ned_accel)
Set acceleration in NED coordinates (float).
Definition: state.h:973
static struct EcefCoor_i * stateGetAccelEcef_i(void)
Get acceleration in ECEF coordinates (int).
Definition: state.h:1000
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
Definition: state.h:460
#define SPEED_ECEF_F
Definition: state.h:88
#define RATE_I
Definition: state.h:110
Rotation quaternion.
#define ACCEL_NED_I
Definition: state.h:101
struct LlaCoor_f lla
origin of local frame in LLA
#define POS_ENU_I
Definition: state.h:67
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:666
struct NedCoor_i ned_pos_i
Position in North East Down coordinates.
Definition: state.h:174
#define SPEED_HNORM_F
Definition: state.h:91
struct State state
Definition: state.c:36
static struct NedCoor_i * stateGetAccelNed_i(void)
Get acceleration in NED coordinates (int).
Definition: state.h:991
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
static bool_t stateIsAngleOfAttackValid(void)
test if angle of attack is available.
Definition: state.h:1213
Paparazzi fixed point algebra.
void stateCalcHorizontalWindspeed_f(void)
Definition: state.c:1133
static void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
Set horizontal windspeed (float).
Definition: state.h:1245
static void orientationSetEulers_f(struct OrientationReps *orientation, struct FloatEulers *eulers)
Set vehicle body attitude from euler angles (float).