Guide: State Machine - Toby-eaaa/Mini_Pupper_eaaa GitHub Wiki

The Pupper has 3 states:

  1. Idle or deactivated. The Face is black with yellow eyes.
  2. Activated, ready to move. The face is yellow with black eyes.
  3. Trot mode. The Pupper is walking on the spot.

To keep track of the state between programs, a function can be added to run_robot that saves the state in a txt file. This file can be accessed by other programs to see what state the Pupper is in at the moment.

In run_robot: Function to save "x" as a state to State.txt:

def write_state_to_txt(x):
    file1 = open("State.txt", "w")
    file1.write(x)
    file1.close()

The function is called:

write_state_to_txt("0")

In sequencer_with_state a function is made to read the txt file:

def read_from_txt():
    file1 = open("/home/ubuntu/Robotics/QuadrupedRobot/StanfordQuadruped/State.txt", "r")
    StringTemp = file1.read()
    file1.close()
    return StringTemp

The function is called:

state = read_from_txt()

More about write/read to txt: Here

State demo in EAAA folder: Here