FIRST-Tech-Challenge / SkyStone

FTC SDK
https://www.firstinspires.org/robotics/ftc/what-is-first-tech-challenge
275 stars 1.04k forks source link

LinearOpMode executing without starting #225

Open OviedoRobotics opened 4 years ago

OviedoRobotics commented 4 years ago

This appears to be intermittent, but since updating to v5.4 we have seen several instances where we will initialize a LinearOpMode (our autonomous) and when we press stop (without having pressed start) the robot will execute a second of autonomous after waitForStart and stop. We had not seen this behavior with v5.3.

Windwoes commented 4 years ago

This sounds like a problem with your OpMode rather than with the SDK. I've looked at the changes in 5.4 and nothing was changed that would make me suspect the SDK is at fault.

cmacfarl commented 4 years ago

@OviedoRobotics Is your opmode on github someplace?

gearsincorg commented 4 years ago

In Autonomous, after calling waitForStart() you need to make sure stop wasn't pressed before you execute your autonomous code.

I always put a " if (!isStopRequested()) {} " condition around all of my Auto code to make sure it doesn't even think about starting if I press stop before play.

Windwoes commented 4 years ago

@gearsincorg That is one way to do it, though if you go that route I'd prefer simply returning from the function rather than wrapping your entire main auto in an "if" :)

gearsincorg commented 4 years ago

It's purely a personal preference. When I was learning to code (many years back, pre Java, pre C) I was taught to only have one exit point from a function. It stuck, and now it just helps me with diagnostics and other flow related debugging.

Funny how some habits never die.