|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools |
Rating:
|
Display Modes |
|
#7
|
|||
|
|||
|
Re: Introducing the CCRE!
Quote:
Quote:
The best summary document of the CCRE would be the DOCUMENTATION.MD file linked to above. I don't have a good enough understanding of Command-Based in order to thoroughly compare the two, but I can point out the main helpful features of the CCRE. First of all, The CCRE is designed to allow for very easy separation of concerns in the main robot code - the problem in our IterativeRobot code from last year, without the CCRE, was that while we did have multiple modules, there was no easy way to pull anything apart within files, meaning that you had to constantly search and reread the file to understand anything. Code written with the CCRE, as opposed to code written for IterativeRobot or SimpleRobot, is primarily ran a single time, and pulls together various components (motors, axes, etc) and tells handlers to update them each cycle. This means that a small section of code can, for example, handle shifting and nothing else, and not be interconnected with anything else: Code:
private void setupShifting() {
BooleanStatus shifter = new BooleanStatus(makeSolenoid(2));
shifter.setFalseWhen(startedTeleop);
shifter.setTrueWhen(joystick1.getButtonSource(3));
shifter.setFalseWhen(joystick1.getButtonSource(1));
}
The second main advantage is that channels are interchangeable. The CCRE has a handful of interfaces: BooleanOutput, FloatOutput, BooleanInputPoll, FloatInputPoll, BooleanInputProducer, and FloatInputProducer, as well as FloatInput and BooleanInput which are really just combinations of a InputPoll and InputProducer. Any status data sent anywhere in the CCRE uses one of these, and therefore they are all interchangeable. For example, there is no "Talon" class that the user interacts with. There is no "Solenoid" class either. When the user gets access to a Talon motor, they use makeTalonMotor(PORT_ID, MOTOR_DIRECTION, RAMPING_RATE) which gives them a FloatOutput. This is exactly the same as you could get for a Jaguar, for example. But then, you can plug any FloatOutput into many of the builtin Mixing methods. Mixing.negate could be ran on any FloatOutput to negate all values sent through it - Mixing.deadzone can be used similarly. And Mixing.limit. And ramping. The point of that means that you can have generic utility methods to remix anything without special-casing. So you can change a single line to switch from using a Solenoid to run an actuator: Code:
BooleanOutput actuator = makeSolenoid(1); Code:
BooleanOutput actuator = Mixing.select(makeServo(1, 0, 180), 45, 135);
As well, the CCRE has an emulator that can be launched directly from NetBeans (right click on the project - hit Test) that allows you to try out your code before putting it on the robot. This doesn't do anything as cool as put a virtual robot in a 3D field, but it does let you test how the robot gets controlled: ![]() It can display readouts/inputs for everything that the CCRE can interact with. (There's an extended IO combo box for things like encoders and gyros that pops up other windows.) As a final useful feature, it allows you to write your autonomous modes as imperative code, instead of using state machines, without pausing the rest of the code: Code:
new InstinctModule() {
protected void autonomousMain() throws AutonomousModeOverException, InterruptedException {
leftOut.writeValue(1);
rightOut.writeValue(1);
waitForTime(5000);
leftOut.writeValue(0);
rightOut.writeValue(0);
}
}.register(this);
TL;DR: Separation of concerns! Interchangeable channels! Prewritten modules! An emulator! Imperative autonomous! Last edited by Cel Skeggs : 30-12-2013 at 16:54. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|