OCCRA
Go to Post So go out and learn something new, even if it is old. Co-operate in this and you'll get much more out of it. Cheat and you are only cheating yourself. - ChrisH [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Events   CD-Media   CD-Spy   FRC-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 04-09-2012, 10:35 AM
coreyjon's Avatar
coreyjon coreyjon is offline
Flight Engineer
FRC #0250 (Team 250 Dynamos)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2001
Location: Upstate, Ny
Posts: 184
coreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nice
Send a message via AIM to coreyjon
Spike relay mapped to gamepad trouble.

First, let me preface this with this : I am teaching myself java (uh-oh) I'm a mechanical mentor/ flight engineer who has only programmed HTML back when it was new (yikes!) closest to java I've ever been to was DHTM (remember that?).

I'm helping to start a new team to the north and I'm going to be relied upon to help teach the control system / programming among other things (everything else). It's my weakest area so I've decided to dive in. I've set up a complete control board in my dining room (- brownie points) as well as maybe a smallish robot I'm building as a demo bot (already has a weight problem).

The problem I'm having is I mapped button 1 (A button) of a gamepad to turn on the spike (kOn) when pressed, and off at all other times. It worked. the problem now is I can't map it to any other button - I can try to map it to 2, or 3, or 4, push the code, re boot the c-Rio, power cycle, it's like button 1(A) has been hard wired to the spike on. even if I comment it out and push the code it still works??

attached is my very simple spaghetti code - I'm sure its probably something I'm missing (hopefully obvious to all of you. right now it has a left side and a right side drive to 4 can jags (which works just fine). My woes are with this relay. I have named the relay "light" as if it were actuating a light, which in this case all I've been doing is watching the state light on the spike itself.

here is the code.
Quote:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Relay;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class RobotTemplate extends IterativeRobot {

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
//Dim Jags
Joystick gp;// = new Joystick(1); //gamepad
Relay light; //sets up a relay named 'light'
CANJaguar leftFront;
CANJaguar leftRear;
CANJaguar rightFront;
CANJaguar rightRear;



public void robotInit() { //switched wiring for left drive to reverse drive
try {
gp = new Joystick(1);
light = new Relay(1); //defines new relay port 1
leftFront = new CANJaguar(10);
leftRear = new CANJaguar(11);
rightFront = new CANJaguar(12);
rightRear = new CANJaguar(13);
} catch (Exception e) {
System.out.println("Exception Thrown");
e.printStackTrace();
}
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
light.set(Relay.Value.kOn);

}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {

if (gp.getRawButton(1))
{
light.set(Relay.Value.kOn);
}
else
{
light.set(Relay.Value.kOff);
}

try{
//tank drive, gamepad
try{
leftFront.setX(gp.getRawAxis(2));//pulls gamepad left stick
leftRear.setX(gp.getRawAxis(2));//pulls gp left stick
rightFront.setX(gp.getRawAxis(5));//pulls gp right stick
rightRear.setX(gp.getRawAxis(5));//pulls gp right stick
} catch(Exception e){
e.printStackTrace();
}
} catch(edu.wpi.first.wpilibj.can.CANNotInitializedE xception cnie) {
cnie.printStackTrace();
}
}
}
Thanks for taking a look, hopefully I can figure this out. seams odd that I was able to program it in (didn't do it before I added the programming) but now its all it wants to do - and its a bit .

The gamepad we are using is the logitech rumble F510 if that matters.
__________________
"Jack of all trades, master of none, though offtimes better than master of one".

Last edited by coreyjon : 04-09-2012 at 10:40 AM.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-09-2012, 11:19 AM
coreyjon's Avatar
coreyjon coreyjon is offline
Flight Engineer
FRC #0250 (Team 250 Dynamos)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2001
Location: Upstate, Ny
Posts: 184
coreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nice
Send a message via AIM to coreyjon
Re: Spike relay mapped to gamepad trouble.

Ok, so it's doing what I want today - didn't change a thing, maybe the c-Rio needed to sleep? Very strange.

While the digital side car registers forward and reverse, the spike will only go forward (green light) can't get it to go into reverse. still some trouble shooting to be done. while frustrating, it has been a fun process (so far)..
__________________
"Jack of all trades, master of none, though offtimes better than master of one".

Last edited by coreyjon : 04-09-2012 at 12:22 PM.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-09-2012, 12:26 PM
coreyjon's Avatar
coreyjon coreyjon is offline
Flight Engineer
FRC #0250 (Team 250 Dynamos)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2001
Location: Upstate, Ny
Posts: 184
coreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nice
Send a message via AIM to coreyjon
Re: Spike relay mapped to gamepad trouble.

Quote:
public void teleopPeriodic() {

if (gp.getRawButton(1))
{
light.set(Relay.Value.kforward);
}
else if (gp.getRawButton(2))
{
light.set(Relay.Value.kReverse);
}
else
{
light.set(Relay.Value.kOff);
}
A button (1) turns on green light on sidecar, and spike (nice click!)
B button (2) turns on red light on sidecar, and spike just sits there (not nice)
no button, spike is orange - no lights on sidecar.

the logic seamed sound, and the sidecar behaves how I expected, but the pesky spike - the reason I'm still drinking coffee in the afternoon.
__________________
"Jack of all trades, master of none, though offtimes better than master of one".
Reply With Quote
  #4   Spotlight this post!  
Unread 04-09-2012, 06:19 PM
coreyjon's Avatar
coreyjon coreyjon is offline
Flight Engineer
FRC #0250 (Team 250 Dynamos)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2001
Location: Upstate, Ny
Posts: 184
coreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nicecoreyjon is just really nice
Send a message via AIM to coreyjon
Re: Spike relay mapped to gamepad trouble.

Looks like the spike is faulty.
__________________
"Jack of all trades, master of none, though offtimes better than master of one".
Reply With Quote
  #5   Spotlight this post!  
Unread 04-14-2012, 12:55 AM
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Spike relay mapped to gamepad trouble.

Quote:
Originally Posted by coreyjon View Post
Looks like the spike is faulty.
I hope you figured it out but this might be your problem:
http://www.chiefdelphi.com/forums/sh...d.php?t=101964
and maybe you would want to try the setDirection method
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 06:37 PM.

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


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