dimanche 5 septembre 2021

how can I switch bool

I’m writing codes to simulate the motion of the artificial satellite.

This code updates the position of the satellite with the void numerical_dynamics(void) function as time passes.

In such a situation, I wanted to execute the function void attitude_stabilization(void) for a moment.

My plan was as follows:

if (trigger < 1) {
    stabilized_attitude = true;
    if (stabilized_attitude) stabilized_attitude = false;
}

Initially, the bool stabilized_attitude is false.

I thought that if (trigger < 1) is true then the code in the second line would be executed first, switching bool stabilized_attitude to true.

Then when the third line is executed, since (stabilized attitude) is true, the bool stabilized_attitude would be switched back to false.

However, these codes do not work despite (trigger < 1) == true is satisfied.

How can I change my code to implement my plan?

Aucun commentaire:

Enregistrer un commentaire