View Single Post
  #2   Spotlight this post!  
Unread 30-01-2012, 22:19
Djur's Avatar
Djur Djur is offline
WPILib
AKA: Sam Carlberg
no team
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Massachusetts
Posts: 182
Djur will become famous soon enough
Re: New to FRC programming... How does this look?

Quote:
Originally Posted by joelg236 View Post
I am completely new at FRC programming, and I'm not sure what really is the best way to go about it. Anyone care to give suggestions?
  • You need to initialize all used objects in RobotInit() -- You're calling data from the gyro, but it's never been initialized, so you'll get Null Pointers from that; same for your Watchdog.
  • You don't need to use the watchdog class.
  • During teleopPeriodic: Timer.delay(0.002) only slows down the robot, same for Timer.delay(1.0) -- it makes that thread sleep and you can't do anything until it wakes up. You'd be better off using if(KTrigger.getTrigger())drivetrain.drive(0,0);} -- Since teleopPeriodic is looped anyway, the "while" loop is redundant.

Just some quick suggestions
__________________
WPILib dev (RobotBuilder, SmartDashboard, GRIP)

Last edited by Djur : 31-01-2012 at 09:07. Reason: Misread robotInit()
Reply With Quote