|
Re: Processed Image > Robot Movement Help Needed
I attached an image with a few edits.
You were heading in the right direction, but making a few wrong turns.
Your code was reading "Left and Right Motors" from both RobotDrive and also from the Motors list. While this is supported, I suspect you were really meaning to update robot drive again. Please correct me if I'm wrong.
The next thing to think about is what the result is when a motor is given multiple commands during a teleOp execution or in parallel portions of the app. The better approach is to combine the logic and update the motors or other actuators just once. That is what I attempted to show I'm my modified image. You bring the joystick and the distance info into a single switch statement. You can update the motors either in a common location using outputs.
A slight variation that you may see or decide to use is to bring the values together and use a ternary ?: operator to select one of them to go to the motors.
Greg McKaskle
|