mirror of
https://github.com/supleed2/ELEC50003-P1-CW.git
synced 2024-11-10 01:35:50 +00:00
Add emergency stop function
This commit is contained in:
parent
39603efd3c
commit
0483397ae6
|
@ -18,8 +18,8 @@ void loop()
|
||||||
DynamicJsonDocument rdoc(1024); // receive doc, not sure how big this needs to be
|
DynamicJsonDocument rdoc(1024); // receive doc, not sure how big this needs to be
|
||||||
deserializeJson(rdoc, Serial1); // Take JSON input from UART1
|
deserializeJson(rdoc, Serial1); // Take JSON input from UART1
|
||||||
int requiredHeading = rdoc["rH"]; // if -1: command in progress, returning requested heading, dist/sp to be ignored
|
int requiredHeading = rdoc["rH"]; // if -1: command in progress, returning requested heading, dist/sp to be ignored
|
||||||
int distance = rdoc["dist"];
|
int distance = rdoc["dist"]; // -1 for emergency stop
|
||||||
float speed = rdoc["sp"];
|
float speed = rdoc["sp"]; // -1 for emergency stop
|
||||||
int currentHeading = rdoc["cH"];
|
int currentHeading = rdoc["cH"];
|
||||||
bool resetDistanceTravelled = rdoc["rstD"];
|
bool resetDistanceTravelled = rdoc["rstD"];
|
||||||
|
|
||||||
|
|
|
@ -357,12 +357,20 @@ void recvFromVision() // TO DO
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void emergencyStop() // TO DO
|
void emergencyStop()
|
||||||
{
|
{
|
||||||
// Send stop signals to drive, energy
|
DynamicJsonDocument tdoc(1024);
|
||||||
|
tdoc["rH"] = heading;
|
||||||
|
tdoc["dist"] = -1;
|
||||||
|
tdoc["sp"] = -1;
|
||||||
|
tdoc["cH"] = heading;
|
||||||
|
tdoc["ch"] = 0;
|
||||||
|
serializeJson(tdoc, Serial1); // Send stop signals to Drive
|
||||||
|
serializeJson(tdoc, Serial2); // Send stop signals to Energy
|
||||||
while (InstrQueue.size())
|
while (InstrQueue.size())
|
||||||
{
|
{
|
||||||
InstrQueue.pop(); // Clear Instruction Queue
|
InstrQueue.pop(); // Clear Instruction Queue
|
||||||
}
|
}
|
||||||
|
Status = CS_IDLE; // Reset rover to idle state
|
||||||
Serial.println("Instruction Queue cleared");
|
Serial.println("Instruction Queue cleared");
|
||||||
}
|
}
|
Loading…
Reference in a new issue