Skip to content

Commit bcb96e0

Browse files
committed
bug fixs
1 parent f2be779 commit bcb96e0

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"retrieval_timeout": 60000, "telemetry_port": 7000, "command_port": 6000, "heartbeat_timeout": 5000, "pod_address": "127.0.0.1", "pod_driver": "Simulation", "controlLaptopIpAddr": "192.168.0.2"}
1+
{"retrieval_timeout": 60000, "pod_driver": "Simulation", "controlLaptopIpAddr": "192.168.0.6", "heartbeat_timeout": 5000, "pod_address": "127.0.0.1", "telemetry_port": 7000, "command_port": 6000}

OnPod/FlightComputer/include/States.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ class PodState{
4949

5050
void armedChecks();
5151

52-
5352
protected:
5453
std::string _currentFailure;
5554
std::chrono::steady_clock::time_point _enterStateTime;
56-
std::chrono::steady_clock::time_point _flightStartTime;
5755
bool _transitioning = false;
5856
std::string _transitionReason = "";
5957
PodStates _stateIdentifier = psBooting;

OnPod/FlightComputer/include/Structs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ struct PodValues {
2222

2323
// Flight Profile
2424
uint32_t motorTorque = 0;
25-
uint32_t flightDistance = 0;
25+
volatile uint32_t flightDistance = 0;
2626
uint32_t maxFlightTime = 0;
2727
uint32_t startTorque = 0;
2828
uint32_t accelerationTime = 0;
2929
uint32_t expectedTubePressure = 0;
3030
uint32_t maxVelocity = 0;
3131
uint32_t maxRPM = 0;
32-
uint32_t brakeDistance = 0;
32+
volatile uint32_t brakeDistance = 0;
3333
uint32_t maxStripCount = 0;
3434
bool taxi = false;
3535

@@ -47,9 +47,10 @@ struct PodValues {
4747
std::mutex positionLock;
4848
float motorDistance = 0;
4949
float podVelocity = 0;
50-
float podPosition = 0;
50+
volatile float podPosition = 0;
5151
int totalStripCount = 0;
5252
float stripVelocity = 0;
53+
std::chrono::steady_clock::time_point flightStartTime;
5354

5455
// Updates
5556
std::mutex updatesLock;

OnPod/FlightComputer/src/States.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ float PodState::timeInStateSeconds() {
4545

4646
float PodState::timeInFlightSeconds() {
4747
std::chrono::steady_clock::time_point current = std::chrono::steady_clock::now();
48-
return std::chrono::duration_cast<std::chrono::milliseconds>(current - this->_flightStartTime).count()/1000.0;
48+
return std::chrono::duration_cast<std::chrono::milliseconds>(current - pod->telemetry->flightStartTime).count()/1000.0;
4949
}
5050

5151
bool PodState::isNodeSensorCritical(uint32_t sensorIndex) {
@@ -302,6 +302,7 @@ Arming::Arming(TelemetryManager * pod ): PodState(pod) {
302302
this->pod->telemetry->commandedBrakeNodeState = bnsStandby;
303303
this->pod->telemetry->commandedLvdcNodeState = lvdcFlight;
304304
this->pod->telemetry->podPosition = 0.0f;
305+
this->pod->telemetry->totalStripCount = 0;
305306
}
306307

307308
Arming::~Arming() = default;
@@ -410,10 +411,15 @@ bool PreFlight::testTransitions() {
410411

411412
Acceleration::Acceleration(TelemetryManager * pod) : PodState(pod) {
412413
_stateIdentifier = psAcceleration;
413-
this->_flightStartTime = std::chrono::steady_clock::now();
414+
pod->telemetry->flightStartTime = std::chrono::steady_clock::now();
414415
this->pod->telemetry->commandedBrakeNodeState = bnsFlight;
415416
this->pod->telemetry->commandedLvdcNodeState = lvdcFlight;
416417
this->pod->telemetry->commandedTorque = this->pod->telemetry->motorTorque;
418+
419+
volatile uint32_t flightDistance = pod->telemetry->flightDistance;
420+
volatile uint32_t brakeDistance = pod->telemetry->brakeDistance;
421+
422+
LOG(INFO)<< flightDistance << " " << "ACCEL CONSTRUCT" << " " << brakeDistance;
417423
}
418424

419425
Acceleration::~Acceleration() {
@@ -487,7 +493,7 @@ bool Coasting::testTransitions() {
487493
}
488494

489495
if(this->timeInFlightSeconds() > this->pod->telemetry->maxFlightTime ){
490-
this->setupTransition(psBraking, (std::string)" Flight Timout of " + std::to_string(this->timeInStateSeconds()) + " reached. Pod --> Braking");
496+
this->setupTransition(psBraking, (std::string)" Flight Timout of " + std::to_string(this->timeInFlightSeconds()) + " reached. Pod --> Braking");
491497
return true;
492498
}
493499
return false;
@@ -497,7 +503,7 @@ Coasting::~Coasting() = default;
497503

498504
// * ******************** BRAKING ***********************
499505

500-
Braking::Braking(TelemetryManager* pod) : PodState(pod) {
506+
Braking::Braking(TelemetryManager* pod) : PodState(pod){
501507
_stateIdentifier = psBraking;
502508
this->pod->telemetry->commandedBrakeNodeState = bnsBraking;
503509
this->pod->telemetry->commandedLvdcNodeState = lvdcFlight;

OnPod/FlightComputer/src/Threads/CommanderThread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void parseProtoCommand(PodCommand podCommand, TelemetryManager *Pod) {
9797
Pod->telemetry->taxi = podCommand.taxi();
9898
Pod->telemetry->expectedTubePressure = podCommand.expectedtubepressure();
9999
Pod->telemetry->maxVelocity = podCommand.maxvelocity();
100-
Pod->telemetry->maxRPM = (podCommand.maxvelocity() * 60)/podCommand.maxvelocity();
100+
Pod->telemetry->maxRPM = (podCommand.maxvelocity() * 60)/GENERAL_CONSTANTS::REAR_WHEEL_CIRCUMFRENCE;
101+
LOG(INFO)<<Pod->telemetry->maxRPM;
101102
Pod->telemetry->brakeDistance = podCommand.brakingdistance();
102103
if(!podCommand.taxi()) {
103104
Pod->telemetry->maxStripCount = ( (Pod->telemetry->flightDistance - Pod->telemetry->brakeDistance) /

OnPod/FlightComputer/src/Threads/NavigationThread.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ int8_t getSerialPort(){
5151
}
5252

5353

54-
void updatePosition(int velocity, int irStripCount, TelemetryManager &pod){
55-
pod.telemetry->totalStripCount += irStripCount;
56-
float stripDistance = pod.telemetry->totalStripCount * GENERAL_CONSTANTS::STRIP_DISTANCE;
57-
pod.setPodDistance( stripDistance );
58-
pod.setPodVelocity(velocity/100);
59-
}
60-
61-
6254
void readNavigationNode(int serialPort, TelemetryManager &pod){
6355
std::stringstream dataStream;
6456
dataStream.str(std::string());

0 commit comments

Comments
 (0)