Go to Post 256:1 gear reductions provide surprisingly little torque once the gears have failed. - Kevin Sevcik [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 01-11-2011, 21:46
Thundrio Thundrio is offline
Dedicated Racer
FRC #3673
 
Join Date: Feb 2011
Rookie Year: 2010
Location: The Internet
Posts: 67
Thundrio is on a distinguished road
Should this code work as intended?

I'm the lead programmer for my team (this is our second year) and last year we used LabView, but I'm trying to get java ready for the build season. I wrote some code I thought should work, but it isn't. There are no compiling errors and when I tell it to deploy, the crio restarts like it should.

I want to know if something is wrong with my code, or if there must be something wrong with configuration somewhere (it will help to know which so I don't have to examine both possibilities).

This code should make the Jaguar in pwm 1 start going during autonomous(at least that is my intention)

Code:
//copyright shite

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Jaguar;


//the vm automatially runs this shizzy class
public class SimpleBob extends SimpleRobot {
     Jaguar test = new Jaguar(1);
    
    //called during autonomous
    public void autonomous() {
         test.set(0.75);
    }

    //called during operator control period of time
    public void operatorControl() {

    }
}
thanks for all help
__________________
Interested in a new way of playing old games?
visit http://www.speedrunslive.com for a way to make single player games multiplayer!
visit http://www.zeldaspeedruns.com to open up a new world for zelda lovers!
pm me here or at zsr for more information!
Reply With Quote
  #2   Spotlight this post!  
Unread 02-11-2011, 16:53
Kovs's Avatar
Kovs Kovs is offline
Registered User
FRC #1259 (Paradigm Shift)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Pewaukee, Wisconsin
Posts: 19
Kovs will become famous soon enough
Re: Should this code work as intended?

(As a warning, I use the IterativeRobot to code instead of the SimpleRobot, so there might be some error in my post)
The autonomous and operator control methods only run once when the robot is enabled, so when you start autonomous mode, it does do "test.set(0.75);" but right after that autonomous ends, putting it in disabled mode, which sets the motors to 0 . To fix this, you have to have a loop to repeat in the code, such as:
Code:
while( isAutonomous() && isEnabled() ) {
         test.set(0.75);
}
or, since you don't have to keep setting the speed controller value, you can do:

Code:
test.set(0.75);
while( isAutonomous() && isEnabled() ) {
}
which should set the motor to 75% when autonomous is enabled and will run til autonomous is disabled (or when the robot breaks).

Also, you should read this, it'll help: http://first.wpi.edu/Images/CMS/Firs...va_for_FRC.pdf
Reply With Quote
  #3   Spotlight this post!  
Unread 03-11-2011, 11:22
Anupam Goli's Avatar
Anupam Goli Anupam Goli is offline
PCH Q&A co-founder/Scouting Mentor
AKA: noops
FRC #1648 (G3 Robotics)
Team Role: Mentor
 
Join Date: Dec 2010
Rookie Year: 2008
Location: Atlanta, Georgia
Posts: 1,242
Anupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond reputeAnupam Goli has a reputation beyond repute
Re: Should this code work as intended?

Whenever i construct a Jaguar object and I'musing pwm, i like to pass the slot as a parameter, in case we end up using two digital sidecars. This code won't run on the robot, because you are missing your call to the watchdog. you need to either set the Watchdog to never be fed or you need to be feeding the watchdog in your main loop.
__________________
Team 1002: 2008-2012
Team 1648: 2012-2016
Georgia Tech Class of 2016
Reply With Quote
  #4   Spotlight this post!  
Unread 03-11-2011, 13:03
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: Should this code work as intended?

In SimpleRobot the autonomous (and teleop) methods are called only once. You should have a loop around your driving command and an explicit set(0.0) after it. e.g.

while(isAutonomous()){
test.set(0.75);
}
test.set(0.0);

but yes, your code should start the Jag on PWM 1 at 75%.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-11-2011, 12:23
Mk.32's Avatar
Mk.32 Mk.32 is offline
Registered User
AKA: Mark
FRC #2485 (W.A.R. Lords)
Team Role: Engineer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: San Diego
Posts: 770
Mk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud of
Re: Should this code work as intended?

Hm, you shouldn't need to loop the .set methods. I would also set the module the Digital SideCar is plugged into.
Are you sure your jags are wired correctly, when running the code do you notice the LEDs on them change color?
Also are you running auton mode in the Driver Station?

For basic auton code you can do:

Jag.set(.5);
Timer.Delay(4);
Jaq.set(0);

That will run the motor at speed .5 for 4 secs then shut it off.
__________________
Engineering mentor: Team 2485: WARLords 2013-

Team President: Team 3647 2010-2013
Reply With Quote
  #6   Spotlight this post!  
Unread 05-11-2011, 13:19
Thundrio Thundrio is offline
Dedicated Racer
FRC #3673
 
Join Date: Feb 2011
Rookie Year: 2010
Location: The Internet
Posts: 67
Thundrio is on a distinguished road
Re: Should this code work as intended?

Alright I tried the first two posts to no avail, but I will try what mk said on monday. I know everything is wired correctly because I have been imaging it back to LabView for demos (and I have been setting it to Autonomous in the DS)

tyvm
__________________
Interested in a new way of playing old games?
visit http://www.speedrunslive.com for a way to make single player games multiplayer!
visit http://www.zeldaspeedruns.com to open up a new world for zelda lovers!
pm me here or at zsr for more information!
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 00:39.

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