Skip to content

Commit cc25091

Browse files
authored
Merge pull request AVSLab#599 from AVSLab/refactor/refactor-prescribedTransMsg
Refactor/refactor prescribed trans msg
2 parents bd43b0b + 7f92b76 commit cc25091

File tree

8 files changed

+39
-42
lines changed

8 files changed

+39
-42
lines changed

docs/source/Support/bskReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Version |release|
4242
outside of the release cycle.
4343
- updated plotting of ``opNav`` example scenarios to work again with latest version of ``matplotlib``
4444
- fixed a slew of compiler warnings when compiling with Xcode 15
45+
- Refactored the :ref:`PrescribedTransMsgPayload` message by renaming the message to
46+
:ref:`LinearTranslationRigidBodyMsgPayload` and renaming the message variables from ``scalarPos`` and ``scalarVel`` to
47+
``rho`` and ``rhoDot``
4548

4649
Version 2.2.1 (Dec. 22, 2023)
4750
-----------------------------
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
ISC License
33
4-
Copyright (c) 2023, Autonomous Vehicle Systems Lab, University of Colorado at Boulder
4+
Copyright (c) 2024, Autonomous Vehicle Systems Lab, University of Colorado at Boulder
55
66
Permission to use, copy, modify, and/or distribute this software for any
77
purpose with or without fee is hereby granted, provided that the above
@@ -17,15 +17,15 @@
1717
1818
*/
1919

20-
#ifndef prescribedTransSimMsg_h
21-
#define prescribedTransSimMsg_h
20+
#ifndef linearTranslationRigidBodySimMsg_h
21+
#define linearTranslationRigidBodySimMsg_h
2222

2323

24-
/*! @brief Structure used to define the data message*/
24+
/*! @brief Structure used to define the translating rigid body data message*/
2525
typedef struct {
26-
double scalarPos; //!< [m], spinning body translational displacement
27-
double scalarVel; //!< [m/s], spinning body translational displacement rate
28-
}PrescribedTransMsgPayload;
26+
double rho; //!< [m], body linear displacement
27+
double rhoDot; //!< [m/s], body linear displacement rate
28+
}LinearTranslationRigidBodyMsgPayload;
2929

3030

31-
#endif /* prescribedTransSimMsg_h */
31+
#endif /* linearTranslationRigidBodySimMsg_h */

src/fswAlgorithms/effectorInterfaces/prescribedTrans/_UnitTest/test_prescribedTrans.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def prescribedTransTestFunction(show_plots, scalarPosInit, scalarPosRef, scalarA
114114

115115
# Create input message
116116
scalarVelRef = 0.0 # [m/s]
117-
PrescribedTransMessageData = messaging.PrescribedTransMsgPayload()
118-
PrescribedTransMessageData.scalarPos = scalarPosRef
119-
PrescribedTransMessageData.scalarVel = scalarVelRef
120-
PrescribedTransMessage = messaging.PrescribedTransMsg().write(PrescribedTransMessageData)
121-
PrescribedTrans.prescribedTransInMsg.subscribeTo(PrescribedTransMessage)
117+
linearTranslationRigidBodyMessageData = messaging.LinearTranslationRigidBodyMsgPayload()
118+
linearTranslationRigidBodyMessageData.rho = scalarPosRef
119+
linearTranslationRigidBodyMessageData.rhoDot = scalarVelRef
120+
linearTranslationRigidBodyMessage = messaging.LinearTranslationRigidBodyMsg().write(linearTranslationRigidBodyMessageData)
121+
PrescribedTrans.linearTranslationRigidBodyInMsg.subscribeTo(linearTranslationRigidBodyMessage)
122122

123123
# Setup logging on the test module output message so that we get all the writes to it
124124
dataLog = PrescribedTrans.prescribedMotionOutMsg.recorder()

src/fswAlgorithms/effectorInterfaces/prescribedTrans/prescribedTrans.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void SelfInit_prescribedTrans(PrescribedTransConfig *configData, int64_t moduleI
4949
void Reset_prescribedTrans(PrescribedTransConfig *configData, uint64_t callTime, int64_t moduleID)
5050
{
5151
// Check if the input message is connected
52-
if (!PrescribedTransMsg_C_isLinked(&configData->prescribedTransInMsg)) {
53-
_bskLog(configData->bskLogger, BSK_ERROR, "Error: prescribedTrans.prescribedTransInMsg wasn't connected.");
52+
if (!LinearTranslationRigidBodyMsg_C_isLinked(&configData->linearTranslationRigidBodyInMsg)) {
53+
_bskLog(configData->bskLogger, BSK_ERROR, "Error: prescribedTrans.linearTranslationRigidBodyInMsg wasn't connected.");
5454
}
5555

5656
// Set the initial time
@@ -71,29 +71,29 @@ motion output message.
7171
void Update_prescribedTrans(PrescribedTransConfig *configData, uint64_t callTime, int64_t moduleID)
7272
{
7373
// Create the buffer messages
74-
PrescribedTransMsgPayload prescribedTransIn;
74+
LinearTranslationRigidBodyMsgPayload linearTranslationRigidBodyIn;
7575
PrescribedMotionMsgPayload prescribedMotionOut;
7676

7777
// Zero the output message
7878
prescribedMotionOut = PrescribedMotionMsg_C_zeroMsgPayload();
7979

8080
// Read the input message
81-
prescribedTransIn = PrescribedTransMsg_C_zeroMsgPayload();
82-
if (PrescribedTransMsg_C_isWritten(&configData->prescribedTransInMsg))
81+
linearTranslationRigidBodyIn = LinearTranslationRigidBodyMsg_C_zeroMsgPayload();
82+
if (LinearTranslationRigidBodyMsg_C_isWritten(&configData->linearTranslationRigidBodyInMsg))
8383
{
84-
prescribedTransIn = PrescribedTransMsg_C_read(&configData->prescribedTransInMsg);
84+
linearTranslationRigidBodyIn = LinearTranslationRigidBodyMsg_C_read(&configData->linearTranslationRigidBodyInMsg);
8585
}
8686

8787
// This loop is entered when a new maneuver is requested after all previous maneuvers are completed
88-
if (PrescribedTransMsg_C_timeWritten(&configData->prescribedTransInMsg) <= callTime && configData->convergence)
88+
if (LinearTranslationRigidBodyMsg_C_timeWritten(&configData->linearTranslationRigidBodyInMsg) <= callTime && configData->convergence)
8989
{
9090
// Store the initial information
9191
configData->tInit = callTime * NANO2SEC;
9292
configData->scalarPosInit = v3Norm(configData->r_FM_M);
9393
configData->scalarVelInit = v3Norm(configData->rPrime_FM_M);
9494

9595
// Store the reference information
96-
configData->scalarPosRef = prescribedTransIn.scalarPos;
96+
configData->scalarPosRef = linearTranslationRigidBodyIn.rho;
9797
configData->scalarVelRef = 0.0;
9898

9999
// Define temporal information

src/fswAlgorithms/effectorInterfaces/prescribedTrans/prescribedTrans.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <stdbool.h>
2424
#include "architecture/utilities/bskLogging.h"
2525
#include "cMsgCInterface/PrescribedMotionMsg_C.h"
26-
#include "cMsgCInterface/PrescribedTransMsg_C.h"
26+
#include "cMsgCInterface/LinearTranslationRigidBodyMsg_C.h"
2727

2828
/*! @brief Top level structure for the sub-module routines. */
2929
typedef struct {
@@ -51,10 +51,10 @@ typedef struct {
5151
double b; //!< Parabolic constant for the second half of the maneuver
5252

5353
// Messages
54-
PrescribedTransMsg_C prescribedTransInMsg; //!< Input message for the reference states
55-
PrescribedMotionMsg_C prescribedMotionOutMsg; //!< Output message for the prescribed states
54+
LinearTranslationRigidBodyMsg_C linearTranslationRigidBodyInMsg; //!< Input message for the reference states
55+
PrescribedMotionMsg_C prescribedMotionOutMsg; //!< Output message for the prescribed states
5656

57-
BSKLogger *bskLogger; //!< BSK Logging
57+
BSKLogger *bskLogger; //!< BSK Logging
5858

5959
}PrescribedTransConfig;
6060

src/fswAlgorithms/effectorInterfaces/prescribedTrans/prescribedTrans.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
%include "architecture/msgPayloadDefC/PrescribedMotionMsgPayload.h"
2828
struct PrescribedMotionMsg_C;
2929

30-
%include "architecture/msgPayloadDefC/PrescribedTransMsgPayload.h"
31-
struct PrescribedTransMsg_C;
30+
%include "architecture/msgPayloadDefC/LinearTranslationRigidBodyMsgPayload.h"
31+
struct LinearTranslationRigidBodyMsg_C;
3232

3333
%pythoncode %{
3434
import sys

src/fswAlgorithms/effectorInterfaces/prescribedTrans/prescribedTrans.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ provides information on what this message is used for.
3535
* - Msg Variable Name
3636
- Msg Type
3737
- Description
38-
* - prescribedTransInMsg
39-
- :ref:`PrescribedTransMsgPayload`
38+
* - linearTranslationRigidBodyInMsg
39+
- :ref:`LinearTranslationRigidBodyMsgPayload`
4040
- input msg with the prescribed body reference states
41-
* - prescribedTransOutMsg
42-
- :ref:`PrescribedTransMsgPayload`
43-
- output message with the scalar prescribed body states
4441
* - prescribedMotionOutMsg
4542
- :ref:`PrescribedMotionMsgPayload`
4643
- output message with the prescribed body states
@@ -132,11 +129,8 @@ the mount frame axis for the translational motion, the prescribed body's initial
132129
the mount frame :math:`\boldsymbol{r}_{F/M}(t_0)`, and the reference position vector of the prescribed body with respect
133130
to the mount frame :math:`\boldsymbol{r}_{F/M} (\text{ref})`.
134131

135-
This module provides two output messages in the form of :ref:`PrescribedTransMsgPayload` and
136-
:ref:`PrescribedMotionMsgPayload`. The first guidance message, describing the prescribed body's scalar states relative to
137-
the hub-fixed mount frame can be directly connected to a feedback control module. The second prescribed
138-
motion output message can be connected to the :ref:`PrescribedMotionStateEffector` dynamics module to directly profile
139-
a state effector's translational motion.
132+
This module provides a :ref:`PrescribedMotionMsgPayload` output message that can be connected to the
133+
:ref:`PrescribedMotionStateEffector` dynamics module to directly profile a state effector's translational motion.
140134

141135
This section is to outline the steps needed to setup a prescribed translational module in python using Basilisk.
142136

src/simulation/dynamics/prescribedMotion/_UnitTest/test_PrescribedMotionStateEffector.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ def PrescribedMotionTestFunction(show_plots, rotTest, thetaInit, theta_Ref, posI
425425

426426
# Create the prescribedTrans input message
427427
velRef = 0.0 # [m/s]
428-
PrescribedTransMessageData = messaging.PrescribedTransMsgPayload()
429-
PrescribedTransMessageData.scalarPos = posRef
430-
PrescribedTransMessageData.scalarVel = velRef
431-
PrescribedTransMessage = messaging.PrescribedTransMsg().write(PrescribedTransMessageData)
432-
PrescribedTrans.prescribedTransInMsg.subscribeTo(PrescribedTransMessage)
428+
linearTranslationRigidBodyMessageData = messaging.LinearTranslationRigidBodyMsgPayload()
429+
linearTranslationRigidBodyMessageData.rho = posRef
430+
linearTranslationRigidBodyMessageData.rhoDot = velRef
431+
linearTranslationRigidBodyMessage = messaging.LinearTranslationRigidBodyMsg().write(linearTranslationRigidBodyMessageData)
432+
PrescribedTrans.linearTranslationRigidBodyInMsg.subscribeTo(linearTranslationRigidBodyMessage)
433433

434434
# Connect the PrescribedTrans module's prescribedMotion output message to the prescribedMotion module's prescribedMotion input message
435435
platform.prescribedMotionInMsg.subscribeTo(PrescribedTrans.prescribedMotionOutMsg)

0 commit comments

Comments
 (0)