No announcement yet.

State Machine issues!

  • Filter
  • Time
  • Show
Clear All
new posts

  • State Machine issues!

    Is there a way to ensure one case i.e. state.STEP_1 is complete before moving to the next case i.e. state.CASE_2 without using a sleep(250) function? what we are having to do is make the sleep at least sleep(1000) in order to ensure the robot has time to drive the required distance. We are using encoders and a "whileOpModeIsActive" statement to navigate.

  • #2
    You need some condition for the State such that the robot can tell you that it is done. A good default condition is a timer variable using Elapsed time, but a condition closer to what is happening within the State would be recommended. A condition could be a number of encoder ticks, distance from an object, found a color match, servo position reached, etc.

    Within each event loop cycle you want to go to a method that has all your States and in each State check for it's unique conditions to know whether to stop and change States. If the conditions are not true yet you will continue the action.

    Hope this makes sense!
    Coach Breton