Go to Post They have obviously figuered out something special. I want to learn from them. - dlavery [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 02-02-2014, 23:53
Zaque Zaque is offline
FF: Bobo Brigade
AKA: Zachary H.
FRC #3352 (Flaming Monkeys)
Team Role: Programmer
 
Join Date: Mar 2013
Rookie Year: 2013
Location: Belvidere, Illinois
Posts: 91
Zaque has a spectacular aura aboutZaque has a spectacular aura aboutZaque has a spectacular aura about
What to put in disabled() and robotinit()?

Hello all,

In my quest to better understand the control system of the robots, I have noticed that the default disabled and robotinit functions are usually running. I am aware that this is acceptable, but was wondering what could these functions could be used for. I have seen the camera initialized in robotinit() in the sample vision code, and from my understanding nothing will run that is put in the disabled method. What sorts of things does your team program in these methods?

Thanks,
Zaque.
__________________
Zaque (Zach) H.
President
Programming/Electrical Lead
Reply With Quote
  #2   Spotlight this post!  
Unread 03-02-2014, 08:06
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 103
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: What to put in disabled() and robotinit()?

Our understanding is that:
  • robotInit() is called only once per reboot/deploy (don't put any code in here that you want to run without rebooting the robot).
  • disabled() is called when you transition between states.
  • You can not execute any code in either of these methods which actuate devices on your robot. In other words, you can probably read sensors, but you can't drive motors or pneumatics.

When using the SimpleRobot framework, we typically implement robotInit() for the following purposes:
  • Construct the various parts used in the robot (Talons, Relays, Counters, etc).
  • Perform initialization tasks that only need to be done once per boot (initialize gyro, set up camera, etc).
  • The addition of our own System.out.println() message so we can see that our deploy was successful and ready to run in the NetBeans console.

Often we don't implement our own version of disabled(), but when we do we use it for purposes that don't involve controlling motors or pneumatics. Sometimes we will update the smart dashboard for sensor readings (for example, if we want to see how accurate the gyro is, we can put the value to the smart dashboard and have a few kids pick up and rotate the robot a few revolutions while the robot is disabled).

We've found that the SimpleRobot framework is excellent for quickly creating small programs to test specific electrical components. As projects grow and become more complex, switching to the CommandBase frame work pays off in the end.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-02-2014, 12:21
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: What to put in disabled() and robotinit()?

Here are some of the things we've put in disabled and robotInit:

robotInit:
Read preferences to determine if practice robot flag has been set
Read autonomous file
configure sensors that need additional configuration beyond the constructor

disabled:
read and display sensors (It's really handy to verify a sensor is working without enabling the robot)
check for changes in autonomous file
select autonomous mode
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2014, 10:18
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 332
fovea1959 will become famous soon enough
Re: What to put in disabled() and robotinit()?

we tapped into robotInit and made sure a corresponding (possibly empty) robotInit() gets called in every subsystem.

did the same for the autonomousInit(), disabledInit(), testInit(), teleopInit(): they all call a modeChanged() method in Robot that's calls a modeChanged() method in every subsystem.

same for all the *periodic() functions: they all call a method in Robot that calls a periodic() method in every subsystem (which take care of subsystem specific network table puts). The Robot.periodic() takes care of robot-wide telemetry (we have a "record network tables to disk" app on our driver station).

Robot has a getCurrentMode() and getPreviousMode() for everyone to use.

If we add a subsystem to the robot, we (just once) make sure it has empty robotInit(), modeChanged(), and periodic() methods, and we make sure that they get added to the list of called routines in Robot.java.

It seems like overkill, but the net effect is that *all* code for a subsystem is either in the subsystem or it's commands: none of it is off to the side in Robot.java. Consistency between subsystems cuts down on silly mistakes. Not having to remember to look in Robot.java for code that does subsystem-specific initializations or periodic() processing; cuts down on silly mistakes.

for example, in our drive subsystem (I'm paraphrasing...)
Code:
public void modeChanged() {
 if (Robot.getCurrentMode() == RobotMode.TELEOP) {
  // drive subsystem specific set up at start of Teleop
  setReverseMode(false);
 }
}
This might be overengineering, but we do like the consistency and modularity.
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:06.

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