Go to Post make sure to make it look really cool, it makes it easier for teams to remember you, which comes in handy for alliance selections ;) - Holtzman [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 26-10-2016, 11:43
Bo8_87 Bo8_87 is offline
Registered User
no team
 
Join Date: Aug 2016
Rookie Year: 2014
Location: California
Posts: 24
Bo8_87 is an unknown quantity at this point
Re: Hello from Team 11999!

Quote:
Originally Posted by jvanetten View Post
@TeleOp(name="Atlas: Teleop POV", group="WRW")

public class AtlasTeleop extends LinearOpMode {


HardwareAtlas robot = new HardwareAtlas();

double clawOffset = 0;
final double CLAW_SPEED = 0.02 ;


public void runOpMode() {
double left;
double right;
double max;


robot.init(hardwareMap);


telemetry.addData("Say", "Hello Atlas Driver");
telemetry.update();


waitForStart();


while (opModeIsActive()) {


left = -gamepad1.left_stick_y + gamepad1.right_stick_x;
right = -gamepad1.left_stick_y - gamepad1.right_stick_x;


max = Math.max(Math.abs(left), Math.abs(right));
if (max > 1.0)
{
left /= max;
right /= max;
}

robot.leftMotor.setPower(left);
robot.rightMotor.setPower(right);


if (gamepad1.right_bumper)
clawOffset += CLAW_SPEED;
else if (gamepad1.left_bumper)
clawOffset -= CLAW_SPEED;


clawOffset = Range.clip(clawOffset, -0.5, 0.5);
robot.leftClaw.setPosition(robot.MID_SERVO + clawOffset);
robot.rightClaw.setPosition(robot.MID_SERVO - clawOffset);


if (gamepad1.y)
robot.armMotor.setPower(robot.ARM_UP_POWER);
else if (gamepad1.a)
robot.armMotor.setPower(robot.ARM_DOWN_POWER);
else
robot.armMotor.setPower(0.0);


telemetry.addData("claw", "Offset = %.2f", clawOffset);
telemetry.addData("left", "%.2f", left);
telemetry.addData("right", "%.2f", right);
telemetry.update();


}
}
}
Since you are using LinearOpMode, you need a create and call an waitForTick method in your loop.

/***
*
* waitForTick implements a periodic delay. However, this acts like a metronome with a regular
* periodic tick. This is used to compensate for varying processing times for each cycle.
* The function looks at the elapsed cycle time, and sleeps for the remaining time interval.
*
* @param periodMs Length of wait cycle in mSec.
*/
public void waitForTick(long periodMs) {

long remaining = periodMs - (long)period.milliseconds();

// sleep for the remaining portion of the regular cycle period.
if (remaining > 0) {
try {
Thread.sleep(remaining);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}

// Reset the cycle clock for the next pass.
period.reset();
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi