Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   Hello from Team 11999! (http://www.chiefdelphi.com/forums/showthread.php?t=152054)

jvanetten 26-10-2016 11:26

Hello from Team 11999!
 
Hello everyone.

We are a rookie team this year. I was wondering if we could get a hand with a question that has been a problem for a couple of weeks. Right now, our robot has a program that loads onto the driver station and seems to work (we can see the telemetry working for the remote and everything), but our robot does not move. I was wondering if anyone else has had this problem? Is it a problem with our code or is it a connectivity issue with the phone and the controller?

Thanks for helping out!

Bo8_87 26-10-2016 11:29

Re: Hello from Team 11999!
 
Quote:

Originally Posted by jvanetten (Post 1613624)
Hello everyone.

We are a rookie team this year. I was wondering if we could get a hand with a question that has been a problem for a couple of weeks. Right now, our robot has a program that loads onto the driver station and seems to work (we can see the telemetry working for the remote and everything), but our robot does not move. I was wondering if anyone else has had this problem? Is it a problem with our code or is it a connectivity issue with the phone and the controller?

Thanks for helping out!

Could you post your code?

jvanetten 26-10-2016 11:36

Re: Hello from Team 11999!
 
@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();


}
}
}

Bo8_87 26-10-2016 11:43

Re: Hello from Team 11999!
 
Quote:

Originally Posted by jvanetten (Post 1613629)
@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();
}

jvanetten 26-10-2016 11:48

Re: Hello from Team 11999!
 
Awesome! Thank you.

Daria Wing 26-10-2016 12:49

Re: Hello from Team 11999!
 
I got so confused for a second because I was in FRC thinking mode and was like, 11999????? WAY too many numbers there! And then I stopped to think, and yah. I haven't slept very much lately.:yikes:

jvanetten 26-10-2016 12:53

Re: Hello from Team 11999!
 
Yeah we are FTC, and this is my first year in the robotics world. So far it has been exciting and fun.


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

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