Go to Post The 2016 Palmetto regional will be the most watched regional during week 0.5. - Procolsaurus [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2011, 18:04
RoboElite640 RoboElite640 is offline
Registered User
FRC #0640
 
Join Date: Nov 2010
Location: NY
Posts: 36
RoboElite640 is an unknown quantity at this point
problem with motors and programs

When we run the robot, we have button 3 and button 2 on the right Joystick move the arm. but when we try it doesnt work. The speed controller turns red when we try, but w/o the codes its yellow. Anyhelp is our code wrong, cuz our tankdrive works

package org.team640;


import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.camera.AxisCameraException;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;

public class FRC2011Team640 extends SimpleRobot {
private final double TARGET_SCORE_THRESHOLD = .01;
private RobotDrive robotDrive = new RobotDrive(1,2);
private Victor arm = new Victor (3);
private Joystick stickLeft = new Joystick(1);
private Joystick stickRight = new Joystick(2);
private AxisCamera cam;
private TrackerDashboard trackerDashboard = new TrackerDashboard();



public FRC2011Team640() {
getWatchdog().setExpiration(0.5);
initializeTargetting();
}

public void autonomous() {
getWatchdog().setEnabled(false);
for (int i = 1; i <=4; i = i +1) {
robotDrive.drive(0.5,0.0);
Timer.delay(2.0);
robotDrive.drive(0.0,0.0);
Timer.delay (2.0);
}
}


private void processTarget() {
try {
System.out.println("Trying to obtain image");
if (cam.freshImage()) {// && turnController.onTarget()) {
System.out.println("Have fresh image");
ColorImage image = cam.getImage();
Thread.yield();
Target[] targets = Target.findCircularTargets(image);
Thread.yield();
image.free();
if (targets.length <= 100 || targets[10].m_score
< TARGET_SCORE_THRESHOLD) //length == 0 (original)
{
System.out.println("No target found");
Target[] newTargets = new Target[targets.length + 1];
newTargets[0] = new Target();
newTargets[0].m_majorRadius = 10;
// radius = 0 (original)
newTargets[0].m_minorRadius = 1;
newTargets[0].m_score = 2;
for (int i = 1; i < targets.length; i++) {
newTargets[i + 1] = targets[i];
}
trackerDashboard.updateVisionDashboard(0.0, 0.0,
0.0, 0.0, newTargets);
} else {
System.out.println("HAVE TARGET!!!!!");
System.out.println(targets[0]);
System.out.println("Target Angle: "
+ targets[0].getHorizontalAngle());
trackerDashboard.updateVisionDashboard(0.0, 0.0,
0.0, targets[0].m_xPos / targets[0].m_xMax, targets);
}
} else {
System.out.println("No image");
}
} catch (NIVisionException ex) {
ex.printStackTrace();
} catch (AxisCameraException ex) {
ex.printStackTrace();
}
}

private void initializeTargetting() {
Timer.delay(10.0);
cam = AxisCamera.getInstance();
cam.writeResolution(AxisCamera.ResolutionT.k320x24 0);
cam.writeBrightness(0);
}

public void moveArm1() {
getWatchdog().feed();

arm.set(1.0);
Timer.delay(0.4);


}

public void moveArm2 () {
getWatchdog().setEnabled(true);
arm.set(1.0);
Timer.delay(3.5);
}

public void operatorControl() {
getWatchdog().setEnabled(true);

while (isEnabled() && isOperatorControl()) {
if(stickLeft.getRawButton(3))
{ moveArm1();}
else if (stickLeft.getRawButton(2))
{ moveArm2(); }
}


}
}
Reply With Quote
  #2   Spotlight this post!  
Unread 18-02-2011, 18:24
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: problem with motors and programs

Does your driver station report the watchdog being fed? I don't know much about the SimpleRobot template, but in Iterative a delay like the ones you have in your moveArm functions would starve the watchdog until the delay is over.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2011, 19:49
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: problem with motors and programs

Take a look at your operatorControl.

You should have

Code:
getWatchdog().feed();
under

Code:
while(isEnabled && isOperatorControl()) {
    ....
}
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2011, 21:34
RoboElite640 RoboElite640 is offline
Registered User
FRC #0640
 
Join Date: Nov 2010
Location: NY
Posts: 36
RoboElite640 is an unknown quantity at this point
Re: problem with motors and programs

yeah, we changed it so that the watchdog is fed, but it still doesnt move the motors. could it be wiring problem because when we try to move the arm in driverstation, the speed controlers turn red or is that because our code is bad?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2011, 21:41
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: problem with motors and programs

What do they do when they turn red? Is it solid, quick flashing, or slow flashing? Based on your code, they should be either solid red or solid green (running at 100%). In any case, it may be worth checking the wiring.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2011, 21:52
RoboElite640 RoboElite640 is offline
Registered User
FRC #0640
 
Join Date: Nov 2010
Location: NY
Posts: 36
RoboElite640 is an unknown quantity at this point
Re: problem with motors and programs

Its solid red. We have the wire going to port 3 for the motor in the digital sidecar.
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2011, 22:17
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: problem with motors and programs

My apologies: I didn't notice that you were using Victors and not Jaguars - I do not believe the solid red/blinking red diagnostic tool exists on the Victors. However, if the watchdog is reportedly fed, I would still go at it with a multimeter to see if it is receiving a signal.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
Reply With Quote
  #8   Spotlight this post!  
Unread 19-02-2011, 10:55
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: problem with motors and programs

With Victor motors, they do indeed give out light for diagnostics. Just the same as Jaguars, actually.

Blinking orange - No input
Red - backwards
Green - forwards

If you have your dashboard coded (you can just use the sample if you haven't already), you can actually get a feed from PWM channels 1-10, typically under Slot 4. If your light is red, the dashboard should show whatever channel you have your victor plugged in to as a meter going down.
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye

Last edited by Robby Unruh : 19-02-2011 at 10:58.
Reply With Quote
Reply


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:01.

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