![]() |
Challenge problem: 'ladder of abstraction' iterative design in FRC
This is a really interesting read, and well worth your time if you're interested in interactive, iterative design processes.
http://worrydream.com/LadderOfAbstraction/ When reading this, it occurred to me that this kind of design process could be really useful for designing automated software solutions for the kinds of problems that we face in FRC every build season. Here's a challenge problem for the FIRST community then -- how can we make these kind of iterative design techniques easy to do for Robotics problems like that which we deal with every year? I think the first step is software that contains interactive robot simulators like PyFRC, Gazebo, CCRE, or frc-java-simulator. But we can do better, perhaps some interactive toolkit or more iterative-friendly simulation capabilities. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
That article brings up a number of interesting points! I know that we would have had significantly better autonomous modes if this kind of system were available and used this past season.
On the technical side of implementing these kinds of features, I'm not quite sure how it would be done well. If you try to abstract out time, you'd really have to run the entire program through (in 1:1 time) and record the results, as resuming from arbitrary states in complex robot code... probably would be extremely complicated to do. If you tried to speed this up, then the program could very easily "break the abstraction" (intentionally or not) and reference System.currentTimeMillis() (or the equivalent call in C++) which would cause different behavior unless you managed to figure out every single hole like that in the system. I suppose that adding recording functionality to existing emulation platforms might be the easiest way to provide a basic level of this kind of functionality. I might try to add this onto the CCRE's emulator this summer, and if I do I'll report how useful it seems to be. EDIT: Something that would make this kind of iteration easier would be to have Compile on Save work in NetBeans and another application to update the code within the running application, as this could let us modify code in real time in an emulator. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
I think the tricky thing is really being able to maintain state about the robots behavior in a way that the simulator/emulator could do proper reasoning/adjustment of. Another way I could imagine tackling the problem (particularly for autonomous mode state machines) is controlling the robot via abstractions that have state built into them, so that the simulator/stepper has ultimate control over the state machine. Then the variables are exposed via some mechanism, and that's how you do variance over time. I implemented a very early version of something like that for our code this year, where the actual logic for switching states is done by an underlying object, and the user code didn't have (much) to do with changing that. One more thought that I'm definitely going to implement by next year for PyFRC is just showing a basic 2D field that shows where the robot is. It's an easy enough thing to do, and though not totally accurate, would get one close enough for good testing. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Here are the only things that weren't totally clean: 1) We used the filesystem: Our shooter's speed presets depended on a config file, so if you wanted it to work the same every time you needed to start with the same config file. This was easy to deal with in practice; we would just delete the file and let it get recreated. 2) Some data about the current state of the jags wasn't kept with the other program state. This state was never available to the rest of the program so it wasn't an issue when trying to test the other pieces. This year we made our pieces truely independent of the underlying system, and it meant that we could get great test coverage. It's not that hard. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
The key part here is that since I'm writing a large framework for more people to use than just me or others on my team, I want to avoid forcing this kind of change in user programs. My current best idea is implementing a class transformer in the emulator that substitutes timing-related calls with abstracted calls. This makes a more complex implementation, but would be less complex for the user. The false implementations could have an auto-time-skip system, so that whenever no threads are ready to run, it fast-forwards until the next sleep or wait times out and then continues on. This would let it run at maximum simulation speed by eliminating the delays from the system, without actually making the program run in a different fashion, and therefore wouldn't limit the usefulness of the framework. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
That is exactly how PyFRC allows you to pause/step time, except that in python it's a bit easier to replace it out from underneath the program. :)
|
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
I know you've said that you've had your last release of CCRE to break compatibility but how many external users do you have? |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Quote:
Well, at the very minimum two ways to interact with time are required: getting and sleeping (you cannot reasonably implement either in terms of the other), at which point a custom timing system might be the best bet. I'm probably going to use Java's java.lang.instrumentation.Instrumentation interface and define a custom Agent to allow me to rewrite calls to the core timing methods. (Probably using the ASM4 library, which I've worked with before.) Alternatively, I can define a custom ClassLoader that provides similar transformations and reload the emulator and all of its dependencies with that, although I'm not sure that it would work properly if I need to modify built-in classes. It's a more complicated implementation, but a less complicated interface. Quote:
The biggest reason that we know of that would make others not want to use the CCRE would be worrying about its stability. If it's unstable and it breaks during a competition, they'd need someone who understands it to fix it on the spot. By keeping it maximally stable, we do our best to minimize this concern. (Also, let's avoid clogging this thread up with anything unrelated to the topic at hand, so if you want to discuss this part about the CCRE more, let's move to the CCRE's thread or private messages.) More on topic, I started implementing a basic prototype version of this: ![]() Currently it's a system that graphs the actuator outputs of autonomous mode (or any other period of time). It doesn't yet fast-forward the execution, but it does run the exact same unrestricted code that we've previously been able to write. It's for the following autonomous mode: Code:
protected void autonomousMain() throws AutonomousModeOverException, InterruptedException { |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Code:
void sleep(float length){ |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
I said "reasonably implement". Your suggestion, as I truly hope you know, pegs CPU usage at 100% and consumes all available processing power. This is not reasonable, except in very specific use cases. Also, if you try this on the cRIO under Java, you'll notice that it hangs every single thread other than the main thread for the duration, because Squawk does cooperative multitasking and this code has no "Thread.yield()". (It's still a bad idea in C++, of course, but not quite as horrendous.) |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
EDIT: Went and read the Java spec. This does appear to be allowed. In particular, the sections where it mentions the "sleep" containts an implicit yield and the section where it says that having one thread "diverge" (aka infinite loop with no observable effects) means that all threads are allowed to do so. I am now very happy not to be writing Java. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Code:
void sleep(float len){ |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Quote:
I agree that this is a good solution, in some rare cases. I've even used it myself in bare-metal programming, when there's literally nothing else that the computer could possibly be spending its time. But it's not a good solution in this case. While it is a solution that "works", it is not a reasonable solution for this context. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
Quote:
Maybe this is just the electrical engineer in me talking but when I hear about an embedded system where the CPU usage will never spike above 2% my reaction is not that the software is super-efficient but that the desginers should have put a cheaper part on their board. |
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC
Quote:
|
| All times are GMT -5. The time now is 02:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi