![]() |
Re: Reducing code complexity
Quote:
Like many things in life I didn't really appreciate them until they were denied to me. |
Re: Reducing code complexity
Quote:
|
Re: Reducing code complexity
Quote:
Lookup/Interpolation tables are also my favorites. I'm surprised I don't see them more in FRC. As a note to LV users in this thread, you can make a typedef enum in LV by making a custom control (go to New instead of New VI and it's an option), set it to 'strict type def' and drop an enum. Anywhere you use it, it will auto-update to the type def, so you can change the control (.ctl file) and all of the constants and controls will update. When you create it, the order will define the associated number (it's to the right of the name), which is what you get if you use the enum as a uint. A similar method works for typedef struct, you just need a Cluster full of stuff. |
Re: Reducing code complexity
Quote:
We do use static final int and a naming convention to simulate enum, but of course you lose the benefit of syntactic typing constraints. My point was to subtly indicate that some of the earlier suggestions don't translate directly to the current platform due to Java ME limitations. |
Re: Reducing code complexity
My Java skills are a bit crusty but this should give you an idea.
Code:
// Enum replacement for State in my previous post |
Re: Reducing code complexity
Quote:
So, what's your beef with command based stuff? |
Re: Reducing code complexity
Quote:
|
Re: Reducing code complexity
Quote:
|
Re: Reducing code complexity
Quote:
|
Re: Reducing code complexity
I highly recommend separating your code into classes per subsystem. In terms of condensing your code you will see the most benefit if you do that - it will also make your code easier to read while some of the other methods will save very little space and make your code more difficult to read.
|
Re: Reducing code complexity
Just a hint: take full use of classes and inheritances.
|
Re: Reducing code complexity
Quote:
Here's a more minor problem: Our autonomous mode became Code:
correct angle -> shooter speed -> shootCode:
correct angle-\I get that it's also easier to do the steps linearly in non-command based code, but it's not much different. You'd go from: Code:
switch(mode){Code:
switch(mode){ |
Re: Reducing code complexity
Quote:
Code:
addParallel(new MoveAngle()); |
Re: Reducing code complexity
This thread reminds me why I dislike Java and the command architecture for embedded systems.
I've always designed the code so we can pass desired setpoints in a single auton function then terminate. That way, we send the Set command in the script, and the subsystem listens and controls to that commanded value indefinitely (or until disable->enable transition). This way, the subsystem holds all of the code required to fully run a mechanism, and the rest of the code just is just a button map or auton command. I can test the subsystem individually by commanding setpoint directly, and verify results using all of the data present in the subsystem. In our C code for Vex, each subsystem gets a single C and two H files (since RobotC dosen't exactly work like normal C, the data is in a H with externs in the other H, if we used 'real' C the data would be in a C, code in a C, and externs/prototypes/typedefs in a H). Main (which runs the main task and HMI) gets another C, and Auton has a few files (autosel, routines, psc, nav). All of the code fits easily in a single directory, and totals ~1400 lines (lots of comments and diagnostics). |
Re: Reducing code complexity
Quote:
1)Send a setpoint and exit immediately while holding the setpoint. 2)Send a setpoint, wait for it to get there, then exit and keep holding. 3)Send a setpoint, wait for it to get there, then exit and stop holding Not sure why you think there's only one way to write things with the command system. |
| All times are GMT -5. The time now is 16:26. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi