From d26aa71f2fdadf2b9890d4ea05d4c601e1127ee6 Mon Sep 17 00:00:00 2001 From: Faizan Date: Sat, 3 Dec 2022 16:11:17 +0530 Subject: [PATCH 1/3] changed structure in od_angular.h --- engine/OD/od_angular.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/engine/OD/od_angular.h b/engine/OD/od_angular.h index 0a365241d..6af4064ed 100644 --- a/engine/OD/od_angular.h +++ b/engine/OD/od_angular.h @@ -11,7 +11,9 @@ /******************************************************************************* * Definitions ******************************************************************************/ -typedef float angular_position_t; +typedef struct{ + float private; +} angular_position_t; /******************************************************************************* * Variables @@ -26,7 +28,7 @@ typedef float angular_position_t; // deg static inline float AngularOD_PositionTo_deg(angular_position_t self) { - return self; + return self.private; } static inline angular_position_t AngularOD_PositionFrom_deg(float deg) @@ -37,7 +39,7 @@ static inline angular_position_t AngularOD_PositionFrom_deg(float deg) // rev static inline float AngularOD_PositionTo_rev(angular_position_t self) { - return self / 360.0f; + return self.private / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rev(float rev) @@ -48,7 +50,7 @@ static inline angular_position_t AngularOD_PositionFrom_rev(float rev) // rad static inline float AngularOD_PositionTo_rad(angular_position_t self) { - return (self * 2.0f * 3.141592653589793f) / 360.0f; + return (self.private * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rad(float rad) @@ -60,16 +62,18 @@ static inline angular_position_t AngularOD_PositionFrom_rad(float rad) static inline void AngularOD_PositionToMsg(const angular_position_t *const self, msg_t *const msg) { msg->header.cmd = ANGULAR_POSITION; - memcpy(msg->data, self, sizeof(angular_position_t)); + memcpy(msg->data, self.private, sizeof(angular_position_t)); msg->header.size = sizeof(angular_position_t); } static inline void AngularOD_PositionFromMsg(angular_position_t *const self, const msg_t *const msg) { - memcpy(self, msg->data, msg->header.size); + memcpy(self.private, msg->data, msg->header.size); } - -typedef float angular_speed_t; +.private +typedef struct{ + float private; +} angular_speed_t; // angular_speed are stored in degree/s (deg/s) //******** Conversions *********** @@ -77,7 +81,7 @@ typedef float angular_speed_t; // deg_s static inline float AngularOD_SpeedTo_deg_s(angular_speed_t self) { - return self; + return self.private; } static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) @@ -88,7 +92,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) // rev_s static inline float AngularOD_SpeedTo_rev_s(angular_speed_t self) { - return self / 360.0f; + return self.private / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) @@ -99,7 +103,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) // rev_min static inline float AngularOD_SpeedTo_rev_min(angular_speed_t self) { - return self * 60.0f / 360.0f; + return self.private * 60.0f / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) @@ -110,7 +114,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) // rad_s static inline float AngularOD_SpeedTo_rad_s(angular_speed_t self) { - return (self * 2.0f * 3.141592653589793f) / 360.0f; + return (self.private * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s) @@ -122,13 +126,13 @@ static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s) static inline void AngularOD_SpeedToMsg(const angular_speed_t *const self, msg_t *const msg) { msg->header.cmd = ANGULAR_SPEED; - memcpy(msg->data, self, sizeof(angular_speed_t)); + memcpy(msg->data, self.private, sizeof(angular_speed_t)); msg->header.size = sizeof(angular_speed_t); } static inline void AngularOD_SpeedFromMsg(angular_speed_t *const self, const msg_t *const msg) { - memcpy(self, msg->data, msg->header.size); + memcpy(self.private, msg->data, msg->header.size); } #endif /* OD_OD_ANGULAR_H_ */ From d4bef812ccd6c04712b933beaae7e46e94b05b92 Mon Sep 17 00:00:00 2001 From: Faizan <101268983+Faizan711@users.noreply.github.com> Date: Mon, 5 Dec 2022 11:44:34 +0530 Subject: [PATCH 2/3] corrected self.private in od_angular.h I have changed self.private to self as mentioned and also corrected the line mistake mentioned. --- engine/OD/od_angular.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/engine/OD/od_angular.h b/engine/OD/od_angular.h index 6af4064ed..0d7e92fb0 100644 --- a/engine/OD/od_angular.h +++ b/engine/OD/od_angular.h @@ -28,7 +28,7 @@ typedef struct{ // deg static inline float AngularOD_PositionTo_deg(angular_position_t self) { - return self.private; + return self; } static inline angular_position_t AngularOD_PositionFrom_deg(float deg) @@ -39,7 +39,7 @@ static inline angular_position_t AngularOD_PositionFrom_deg(float deg) // rev static inline float AngularOD_PositionTo_rev(angular_position_t self) { - return self.private / 360.0f; + return self / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rev(float rev) @@ -50,7 +50,7 @@ static inline angular_position_t AngularOD_PositionFrom_rev(float rev) // rad static inline float AngularOD_PositionTo_rad(angular_position_t self) { - return (self.private * 2.0f * 3.141592653589793f) / 360.0f; + return (self * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rad(float rad) @@ -62,15 +62,15 @@ static inline angular_position_t AngularOD_PositionFrom_rad(float rad) static inline void AngularOD_PositionToMsg(const angular_position_t *const self, msg_t *const msg) { msg->header.cmd = ANGULAR_POSITION; - memcpy(msg->data, self.private, sizeof(angular_position_t)); + memcpy(msg->data, self, sizeof(angular_position_t)); msg->header.size = sizeof(angular_position_t); } static inline void AngularOD_PositionFromMsg(angular_position_t *const self, const msg_t *const msg) { - memcpy(self.private, msg->data, msg->header.size); + memcpy(self, msg->data, msg->header.size); } -.private + typedef struct{ float private; } angular_speed_t; @@ -81,7 +81,7 @@ typedef struct{ // deg_s static inline float AngularOD_SpeedTo_deg_s(angular_speed_t self) { - return self.private; + return self; } static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) @@ -92,7 +92,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) // rev_s static inline float AngularOD_SpeedTo_rev_s(angular_speed_t self) { - return self.private / 360.0f; + return self / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) @@ -103,7 +103,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) // rev_min static inline float AngularOD_SpeedTo_rev_min(angular_speed_t self) { - return self.private * 60.0f / 360.0f; + return self * 60.0f / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) @@ -114,7 +114,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) // rad_s static inline float AngularOD_SpeedTo_rad_s(angular_speed_t self) { - return (self.private * 2.0f * 3.141592653589793f) / 360.0f; + return (self * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s) @@ -126,13 +126,13 @@ static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s) static inline void AngularOD_SpeedToMsg(const angular_speed_t *const self, msg_t *const msg) { msg->header.cmd = ANGULAR_SPEED; - memcpy(msg->data, self.private, sizeof(angular_speed_t)); + memcpy(msg->data, self, sizeof(angular_speed_t)); msg->header.size = sizeof(angular_speed_t); } static inline void AngularOD_SpeedFromMsg(angular_speed_t *const self, const msg_t *const msg) { - memcpy(self.private, msg->data, msg->header.size); + memcpy(self, msg->data, msg->header.size); } #endif /* OD_OD_ANGULAR_H_ */ From 6d5f060fb8becacc56a00a18590bec1a22291007 Mon Sep 17 00:00:00 2001 From: Faizan <101268983+Faizan711@users.noreply.github.com> Date: Tue, 6 Dec 2022 09:48:55 +0530 Subject: [PATCH 3/3] update to od_angular.h changed "self.private" for float values and "self" for rest. --- engine/OD/od_angular.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/OD/od_angular.h b/engine/OD/od_angular.h index 0d7e92fb0..884de3157 100644 --- a/engine/OD/od_angular.h +++ b/engine/OD/od_angular.h @@ -28,7 +28,7 @@ typedef struct{ // deg static inline float AngularOD_PositionTo_deg(angular_position_t self) { - return self; + return self.private; } static inline angular_position_t AngularOD_PositionFrom_deg(float deg) @@ -39,7 +39,7 @@ static inline angular_position_t AngularOD_PositionFrom_deg(float deg) // rev static inline float AngularOD_PositionTo_rev(angular_position_t self) { - return self / 360.0f; + return self.private / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rev(float rev) @@ -50,7 +50,7 @@ static inline angular_position_t AngularOD_PositionFrom_rev(float rev) // rad static inline float AngularOD_PositionTo_rad(angular_position_t self) { - return (self * 2.0f * 3.141592653589793f) / 360.0f; + return (self.private * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_position_t AngularOD_PositionFrom_rad(float rad) @@ -81,7 +81,7 @@ typedef struct{ // deg_s static inline float AngularOD_SpeedTo_deg_s(angular_speed_t self) { - return self; + return self.private; } static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) @@ -92,7 +92,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg) // rev_s static inline float AngularOD_SpeedTo_rev_s(angular_speed_t self) { - return self / 360.0f; + return self.private / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) @@ -103,7 +103,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s) // rev_min static inline float AngularOD_SpeedTo_rev_min(angular_speed_t self) { - return self * 60.0f / 360.0f; + return self.private * 60.0f / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) @@ -114,7 +114,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min) // rad_s static inline float AngularOD_SpeedTo_rad_s(angular_speed_t self) { - return (self * 2.0f * 3.141592653589793f) / 360.0f; + return (self.private * 2.0f * 3.141592653589793f) / 360.0f; } static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s)