-
Notifications
You must be signed in to change notification settings - Fork 48
Path manager restructure #157
base: pathManRestructure
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments. Nice work so far!
Also, I'd recommend looking over our Style Guide and fixing any inconsistencies you have with it :))
* | ||
* @return true if the queue is empty. Else return false | ||
*/ | ||
bool instructionQueueIsEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To communicate that this function is specific to cruising mode, maybe name the function something like:
cruisingEditPathInstrQueueIsEmpty()
or something else if you have ideas
that way if we ever need to add new queues we can easily tell which queue we are calling.
* | ||
* @return telemetry data | ||
*/ | ||
Telemetry_PIGO_t dequeueInstruction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cruisingEditPathInstrPop()
?
Nice job with the comments :))
* Function to enqueue a new instruction onto the instruction queue. | ||
*/ | ||
void enqueueInstruction(Telemetry_PIGO_t newInstruction); | ||
instructionQueueNode* first_instr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your comment for the function here I'd write an @param field to explain what the parameter is.
Also, add a comment to the instructionQueueNode pointer so it's more clear what it is being used for. Maybe renaming it to cruising_edit_path_first_instr
may be more clear (especially if we add more queues in the future)
while (!cruise_mode->getModeSelector()->instructionQueueIsEmpty()) { | ||
instr = cruise_mode->getModeSelector()->dequeueInstruction(); | ||
|
||
_ModifyFlightPathErrorCode edit_error = editFlightPath(&instr, cruising_state_manager, waypoint_id_array); // Edit flight path if applicable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to think about: We return an error code when we edit the flight path. What should we do if we get an error while updating the flight path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, can we want to break out of the while loop (that dequeues the instructions) so we can run the setReturnValues function ASAP? We don't lose the flight path edit instructions that are stored on the queue, it's just going to be run later since handling the error code is a higher priority (though again I don't understand how the error is handled, since it doesn't seem to be directly handled inside cruisingModeStages.cpp
newInstructionQueueNode->nextInstruction = nullptr; | ||
|
||
//Add new instructionQueueNode to the entire queue | ||
latestInstruction->nextInstruction = newInstructionQueueNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We should write two unit tests for this when the time comes tho :)
Question: What do you think the tests should cover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Looks like we can look into testing now. We can discuss writing tests for this sometime later this week once assignments stop killing me lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I added a few comments and only have a few concerns:
1.) Considering that a lot of PM will be restructured (implementation of FW-CV comms instead of ground telemetry, usage of other states like hover), do you think its best to hold off on integrating this, or can you easily add more elements/add changes later on?
@@ -14,6 +14,12 @@ | |||
enum PathModeEnum {MODE_TAKEOFF = 0, MODE_CRUISING, MODE_LANDING, MODE_TAXIING}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on we'll have to change this to account for the states more relevant to multicopters (hover, no taxiing, etc.). Do you think its easily changeable for that once its implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think that makes more sense to sit in my PR for landing and takeoff
@@ -17,14 +17,28 @@ _CruisingState_Telemetry_Return CruisingFlight::_return_to_ground; | |||
void CruisingFlight::execute(CruisingMode* cruise_mode) { | |||
Telemetry_PIGO_t telem_data = cruise_mode->getTelemetryData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this will now be from the jetson instead of the plane. When FW-CV Comms gets merged into devel, you will have to re-adapt this restructure
@@ -17,14 +17,28 @@ _CruisingState_Telemetry_Return CruisingFlight::_return_to_ground; | |||
void CruisingFlight::execute(CruisingMode* cruise_mode) { | |||
Telemetry_PIGO_t telem_data = cruise_mode->getTelemetryData(); | |||
SFOutput_t sf_data = cruise_mode->getSensorFusionData(); | |||
|
|||
|
|||
// Set waypoint manager input struct | |||
_input_data.track = sf_data.track; // Gets track |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is _input_data defined?
@@ -0,0 +1,201 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give a rundown of which tests you're running here (in the comments or in documentation) for future reference?
|
||
// These were added to ensure CruisingMode_Fsm tests pass. | ||
// TODO: Ensure CruisingMode tests don't depend on this so we can delete this garbage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting this TODO to keep it visible
@@ -98,7 +99,10 @@ TEST(TakeoffModeFSM, TakeoffClimbTransitionsToCruising) { | |||
Telemetry_PIGO_t telem_data; | |||
telem_data.holdingAltitude = 20; | |||
|
|||
SFOutput_t sf_data {}; | |||
SFOutput_t sf_data; | |||
sf_data.altitude = 50; // So we transition to cruising mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once Hover is implemented, would this make more sense to transition to hover?
This is a pull requests that implements an instructionQueue.
Currently, we can only modify the flight path when we are in cruising mode. The problem with that is that if we are in takeoff mode, and we receive instructions to modify the flight path, these instructions will simply be lost.
This problem has been fixed by adding an instruction queue (implemented as a linked list) that stores these instructions when we are not in cruising mode. Once we transition to cruising mode, we will check the queue first, and if the queue is not empty, execute those instructions first.