|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
Quote:
Quote:
Quote:
In case it helps out, here is my team's code for this past year's robot: https://github.com/CAPS-Robotics/201...ree/master/src We did use C++ for this and it seems that you use Java, but the same basic idea is present (just ignore all of the pointer fun). We used SampleRobot for this code and you can see that the autonomous does not actually check if it is still enabled. We ran this code in competition and never had any problems with the autonomous disabling during a match. Disclaimer: I wrote some of this code, so it is not necessarily very good, but I hope it at least helps with the basic ideas. |
|
#2
|
||||
|
||||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
Just because you can do something and it doesn't break does not mean one should do so.
A great example of why loops are dangerous are these two bits of code in your autonomous: https://github.com/CAPS-Robotics/201...anOWar.cpp#L89 Code:
while (!aligned) {
... do things
}
Same thing here: Code:
do {
... fire = someSensor > some_value
} while (!fire)
Maybe you have magic hardware that never breaks, but I wouldn't put my trust in that. |
|
#3
|
|||
|
|||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
Wait that is a thing? This is my first year as the head robot programmer for the team and I never realized that it was possible that the robot could get stuck in autonomous and never enter teleop. I thought that the FCS changed modes automatically and that any residual problems from the autonomous would not affect the teleop.
|
|
#4
|
||||
|
||||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
Quote:
Use the source, Luke. ![]() As you can see from the source of SampleRobot, if you never return from the Autonomous function, OperatorControl will never be called. No magic here. |
|
#5
|
||||
|
||||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
I have been working with our programmers for a while now and have been working with the WPILIBJ since the beginning in 2010.
Our team uses the command based framework. We like the way we can modularize the code: Break apart functionality into Subsystems, Define commands that operate on those subsystems and then connect the overall system together in the Robot.java code segment while abstracting the harward connections away in the RobotMap layer. you can get a better look at this methodology by reviewing the Gearsbot code and if you look on Youtube there are videos on this system as well that explain it quite well. I have looked at he RobotBuilder and in some places it can work reasonably. However, it does make it more difficult to understand your code and our programmers are not a fan of placing all the constructors in the RobotMap file. I use it VERY early in the development to help understand the connections and plan the structure of the code. I can also use it to help with quick testing of systems without having to focus on having everything in place; you can define the subsystems with all their sensors and actuators, then use the 'Testing' mode on the dashboard to verify system functionality. I know that these capabilities can be developed using the other programming systems, like IterativeRobot, but we find this way easier. Enjoy! Floyd Moore |
|
#6
|
||||
|
||||
|
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|