|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#31
|
|||
|
|||
|
Re: Compact rio not being able to use C
Quote:
In other words, using the old WPILib will give you and your team a feel for how to write robot programs with the new library. But the new library will be much more capable and the interfaces much richer than ever before. And besides all that, the source code will be available along with extensive documentation to make the transition as smooth as possible. We are very sensitive to the fact that a lot of new stuff is getting rolled out at the same time and FIRST is trying to make this as easy as possible. Brad |
|
#32
|
||||
|
||||
|
Re: Compact rio not being able to use C
Quote:
|
|
#33
|
|||||
|
|||||
|
Re: Compact rio not being able to use C
Quote:
Quote:
|
|
#34
|
||||
|
||||
|
Re: Compact rio not being able to use C
I'm not a big fan of C++ exceptions - they're hard to use properly, and not very safe. In fact, their use is banned by the two companies that I've worked for that use C++ (Sony, Google (for these reasons)).
On an embedded system, what's going to happen if a thrown exception is not handled properly? The program is going to terminate, which leaves you with nothing running on your robot controller (and this would be very hard to debug). |
|
#35
|
|||
|
|||
|
Re: Compact rio not being able to use C
Honestly I can't think of why you would want to use exceptions (or any error handling at all for that matter) on the robot, because it doesn't deal with literal user input. Errors (division by zero) means something wrong in your logic (a case for using assertions), and bad/conflicting input values (both upper and lower limit switches are triggered, say) should be handled when parsed and dealt with then, not inside a function that detects them.
On C++ programs, I only use it for passing down error messages through a large stack of functions, where I know it will be caught (as for the overhead, it can't be any worse then using a scripting language, or a custom-built method of passing down structs of data, but maybe I am just too ignorant). I go by the rule of thumb only add exceptions that you will be catching yourself (don't put them in libraries for other people to use). |
|
#36
|
||||
|
||||
|
Re: Compact rio not being able to use C
The only reason I would use exception handling is for debugging purposes. I really have no plans on using it in the competition builds. I agree with all people above that it would become a bit of a nightmare to properly handle all exceptions. I am a strong believer in just writing the code well so that exceptions aren't thrown in the first place.
|
|
#37
|
|||
|
|||
|
Re: Compact rio not being able to use C
OK, there's a bunch of stuff going on here, let me see if I can give the rationale for some of the design decisions with a disclaimer at the end.
First, something about our new environment. We have about 500x more memory and probably 100x more processor speed over the PIC that we're used to using. The past years high speed sensor-interrupt logic that required precise coding, hand optimization and lots of bugs has been replaced with dedicated hardware (FPGA). When the library wants the number of ticks on a 1000 pulse/revolution optical encoder it just asks the FPGA for the value. Another example is A/D sampling that used to be done with tight loops waiting for the conversions to finish. Now sampling across 16 channels is done in hardware. We chose C++ because we felt it represents a better level of abstraction for robot programs. C++ (when used properly) also encourages a level of software reuse that is not as easy or obvious in C. At all levels in the library, we have attempted to design it for maximum extensibility. There are classes that support all the sensors, speed controllers, drivers station, etc. that will be in the kit of parts. In addition most of the commonly used sensors that we could find that are not traditionally in the kit are also supported, like ultrasonic rangefinders. Another example are several robot classes that provide starting points for teams to implement their own robot code. These classes have methods that are called as the program transitions through the various phases of the match. One class looks like the old easyC/WPILib model with Autonomous and OperatorControl functions that get filled in and called at the right time. Another is closer to the old IFI default where user supplied methods are called continuously, but with much finer control. And the base class for all of these is available for teams wanting to implement their own versions. Even with the class library, we anticipate that teams will have custom hardware or other devices that we haven't considered. For them we have implemented a generalized set of hardware and software to make this easy. For example there are general purpose counters than count any input either in the up direction, down direction, or both (with two inputs). They can measure the number of pulses, the width of the pulses and number of other parameters. The counters can also count the number of times an analog signal reaches inside or goes outside of a set of voltage limits. And all of this without requiring any of that high speed interrupt processing that's been so troublesome in the past. And this is just the counters. There are many more generalized features implemented in the hardware and software. We also have interrupt processing available where interrupts are routed to functions in your code. They are dispatched at task level and not as kernel interrupt handlers. This is to help reduce many of the real-time bugs that have been at the root of so many issues in our programs in the past. We believe this works because of the extensive FPGA hardware support. We have chosen to not use the C++ exception handling mechanism, although it available to teams for their programs. Our reasoning has been that uncaught exceptions will unwind the entire call stack and cause the whole robot program to quit. That didn't seem like a good idea in a finals match in the Championship when some bad value causes the entire robot to stop. The objects that represent each of the sensors are dynamically allocated. We have no way of knowing how many encoders, motors, or other things a team will put on a robot. For the hardware an internal reservation system is used so that people don't accidentally reuse the same ports for different purposes (although there is a way around it if that was what you meant to do). I can't say that our library represents the only "right" way to implement FRC robot programs. There are a lot of smart people on teams with lots of experience doing robot programming. We welcome their input, in fact we expect their input to help make this better as a community effort. To this end all of the source code for the library will be published on a server. We are in the process of setting up a mechanism where teams can contribute back to the library. And we are hoping to set up a repository for teams to share their own work. This is too big for a few people to have exclusive control, we want this software to be developed as a true open source project like Linux or Apache. |
|
#38
|
|||||
|
|||||
|
Re: Compact rio not being able to use C
Apologies for the length of this post. I have trimmed it significantly from its original form, and it is still much larger than I would like.
Quote:
In short...huh? Quote:
Is your point that the FPGA makes it possible to support much higher rates of encoder ticks or A/D samples? A faster CPU would be able to do that itself, without FPGA assistance, using interrupts. So speed alone doesn't seem like a compelling argument for eschewing interrupts. Quote:
I can honestly say that I have never seen any problems in FRC robot code that I have traced to a "real-time bug". The one I thought I saw (in someone else's code) was eventually determined to be an EEPROM access contention issue, having nothing to do with interrupts, and was experimentally solved by adding a "real-time" feature (i.e. a semaphore) to the program. On the contrary, the big interrupt-related issue I have seen many teams run across is due to the IFI default library's not using "real-time" code for its PWM generator. Just how are we going to be able to implement PID control -- or even simple speedometers -- without using "real-time" features anyway? That's a question I asked some time ago when it was made clear that the cRIO doesn't have interrupts, and it was never satisfactorily answered. Quote:
|
|
#39
|
|||
|
|||
|
Re: Compact rio not being able to use C
Wow, tough crowd!
Alan - if I suggested that interrupts were evil, that wasn't my point and I'm sorry for not making that clear. And I certainly didn't mean to suggest that lots of bugs are a necessary part of interrupt logic. My point was that having dedicated hardware is a good thing and makes programming easier and offloads the CPU running the robot program. But let me try to answer some of your questions directly. You mentioned that you never received a satisfactory answer on the questions of "speedometers" and PID time-based code. By speedometers, I'm guessing you were asking about measuring the period of signals from encoders on rotating shafts for measuring motor speed directly, please correct me if that's not what you meant. There will be 8 hardware quadrature encoder inputs and 8 hardware counter inputs. Each of these can track the period as well as the count. The period gives an instantaneous representation of speed. Any digital I/O port can be routed to any of these encoders/counters. There are many ways of solving your issue with time-based algorithms like PID integration. One is to use the Notification class that will periodically call some function in your program. You can, for example, request notification every 20ms and do the PID calculations there. Even though it is not a true hardware level interrupt routine, the function can get the precise time and easily apply the appropriate weight as it's integrating the error value. There are many additional mechanisms that could be used for solving the same problem. You asked what i meant by "dedicated hardware" and asserted that it wasn't really necessary and ultimately could just be replaced by faster CPUs. I believe that having hardware to supplement the CPU is a good thing. Like video cards in PCs - it doesn't matter how fast CPUs get, they'll never be as fast as dedicated pipelined graphics engines we see on modern video cards. Same is true on the robot. A few years back there was a gear tooth sensor that generated a (about) 40 microsecond pulse for one direction and a (about) 70 microsecond pulse for the other. If the interrupt on the gear tooth sensor occurred while a higher priority master processor interrupt was being handled (delaying the start of the gear tooth sensor interrupt handler) there would be no way of measuring the pulse width. And we couldn't determine the direction. That's an example of where using the CPU just doesn't work. With "dedicated hardware" we can easily know and the program doesn't have to deal with those complexities. You mentioned Kevin Watson's code with respect to encoders and A/D converters. Kevin was able to accomplish amazing things with PIC chips. He really knew that hardware better than most people I've met and all FIRST teams recognized that. In his encoder FAQ he talks about about phasing errors caused by limited software sampling and interrupt rates that give false interpretations of encoder direction sensing. This is not a problem when there is dedicated hardware looking at each encoder channel, it's only an issue when the CPU is over taxed with many devices competing for the CPUs resources or encoder rates are too high. D/A converters can be sampled with software in interrupt routines, and as you pointed out Kevin's interrupt-based example proved that. But we now can achieve about 500k samples/second aggregate rate on each of two modules without the CPU getting involved at all. And that's with hardware oversampling and averaging and integration for gyros. I'm not saying this can't be done without dedicated hardware, but having it sure seems better to me than not having it. We hope to continue to get input from the FIRST community, make improvements and address concerns as they come up. Please keep asking questions, but please don't shoot the messenger. I for one would prefer to see constructive questions targeted at the hardware/software and not the developers. |
|
#40
|
|||
|
|||
|
Re: Compact rio not being able to use C
Quote:
Can you give us an ETA for the WPILib manual? Will it be released to all teams at once or only to the beta teams and later to the rest of us? edit - added questions: Can you tell us which Wind River Tools will be available? Will the source code be released with the manual? Will there be details such as Quote:
Thank you, Randy Wood Last edited by rwood359 : 09-09-2008 at 02:48. Reason: added questions |
|
#41
|
|||||
|
|||||
|
Re: Compact rio not being able to use C
Quote:
Quote:
Quote:
Quote:
Are those the details you were looking for? Quote:
|
|
#42
|
|||||
|
|||||
|
Re: Compact rio not being able to use C
I have many more comments, questions, and quizzical requests for clarification. I will defer them all until after I've received the opportunity to work with the platform I'm asking about.
As would I. Lacking the hardware/software, however, I have little choice but to aim my questions at the people whom I assume ought to be able to answer. |
|
#43
|
|||||
|
|||||
|
Re: Compact rio not being able to use C
Quote:
How will the library implement multitasking and scheduling? I think this the most significant change in the new system and the real challenge in an RTOS. There is a conflict between ease of programming (learning curve) and advanced functionality. I can see a need to abstract this issue away for the basic users who do not use utilize the CPU enough for it to be an difficult issue. However, the user with heavy vision processing (multi target tracking) and multiple PID loops will need low level access to the scheduling features to ensure deterministic performance. So in the library, how can the programmer declare a object/method/function as a separate task (process)? How do you set priority among these tasks? Is it an object attribute? What about inter process communication? A message class? Also since Day 1 I have been curious about how the disable/autonomous states will work across the control system as a whole. Specifically, can the driver station communicate with the cRIO in disable mode(as so many teams use to select auto modes)? Thanks for the info Brian Last edited by The Lucas : 09-09-2008 at 09:02. |
|
#44
|
|||
|
|||
|
Re: Compact rio not being able to use C
Quote:
Quote:
Quote:
For example, in your response above, you described the functionality of the gyro driver without giving any data rates. Will the functional document have the data rates for the sampling and such? You don't need to give details here. Thanks again, Randy Wood |
|
#45
|
||||
|
||||
|
Re: Compact rio not being able to use C
Quote:
Quote:
Quote:
No plans right now for messaging or interprocess communication. Good opportunity for a team contribution. Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| First CROSSING not being scored? | jgannon | Rules/Strategy | 22 | 09-03-2008 11:08 |
| CMUCam Forum messages are not being poseted as recent activity in the portal | Bob22341 | CD Forum Support | 3 | 31-01-2007 22:34 |
| Ethics 101: To re-use or not to re-use? | aaeamdar | General Forum | 87 | 07-12-2006 19:10 |
| Anyone concerned about the possibility of not being allowed to go to Nationals? | skrussel | Championship Event | 41 | 03-04-2003 11:35 |
| EDU RC not being recognized... | Caleb Fulton | Programming | 5 | 24-03-2003 09:29 |