PDA

View Full Version : FIRST 2008 Robot Emulator


ham90mack
10-05-2007, 09:41 PM
Rob Bayer's (http://www.chiefdelphi.com/forums/showpost.php?p=643515&postcount=6) robot emulator has quirked my interest... Therefore, I am currently planning to make a robot emulator for post-2005 code! It will be written in Java, so when all is done, hopefully it will run in both Windows and Linux (as long as the code is compiled to .dll or .so on the appropriate OS). Just like Rob Bayer's emulator, I hope to minimize the amount of code to change within the original robot code so it can be compiled with and without the "code hack" files with no modifications necessary.

I have no clue if this emulator will work with EasyC or not since my team uses MPLab. I am absolutely certain that it will not be able to parse .ecp files. So it will not work with EasyC unless somebody figures out how to make EasyC export files to .c and .h so it can be compiled elsewhere and make it work in the end.

I don't expect this program to be finished in a few months, however. I hope to be done before the robot build or at least within a few weeks of the kickoff. I am planning to make the GUI first and then implement the actual emulating background. I should be able to release a GUI only version within the next month.

Hopefully, most of the "hack code" Rob Bayer made will work with the post-2005 controller code. I know it doesn't work at the moment without modifications due to the new serial port for the camera. It would be nice to know what kind of implementation I need to fake the serial port feedback and what else changed with the post-2005 controller.

A few special features that might be in the final program (if I figure out how to do them all): extensive documentation for adaptability (such as an extra method put in the main that is not in the default code), special variable watch window, and camera emulator. But the main emulation will be finished before these features are added.

I will consider other special features if suggested, but I doubt I will have the time for anything too extensive. Besides, this program will be obsoleted next year anyway when the controller system is changed, so my main focus will be to make it work with this year's code the way Rob's did with 2004 code.

ham90mack
10-05-2007, 09:44 PM
CURRENT PROGRESS
as of 10/5/07

Joystick implementation in GUI nearly finished.
More GUI components to come.
Version: Unreleased.

DOWNLOAD (link will be posted when it is avaliable)

Branden Ghena
10-06-2007, 10:25 PM
Would your emulator have to take the .c and .h files?

If it instead ran on the compiled .asm files it would probably work with both EasyC and MPLab. Although I am far from certain, the compiled files from EasyC must be similar if not the same as MPLab's because both work in the robot.

By the way, great project. I hope it works out.

ham90mack
10-07-2007, 01:24 PM
Well, if the .asm files could be combined with the .c and .h files required for the hack and compiled into a .dll, then it might work. My emulator will work similar to Rob Bayer's design, except it will work with post-2005 code. Check out his emulator and see if you can figure out how to combine it with EasyC code. If nobody can figure out how to do this, I can't help.

In a PM with me, SamSofa330 said:
YOu can get the .c and .h files from EasyC and compile it differently using mcc18
But the real question is, can it be compiled with MinGW or something similar? The only way to find out is to compare the MPLab code with the extracted EasyC code.

I wonder how many teams use MPLab verses EasyC verses WPILib...

Tom Bottiglieri
10-07-2007, 08:06 PM
But the real question is, can it be compiled with MinGW or something similar? The only way to find out is to compare the MPLab code with the extracted EasyC code.

I wonder how many teams use MPLab verses EasyC verses WPILib...
It's all the same stuff.. EasyC is just an abstraction layer for WPILib, and WPILib is just an abstraction layer for the low level stuff. Either way, it all boils down to the communication between the uP and mP, and what all of your low level outputs and inputs are.

ham90mack
10-07-2007, 09:06 PM
It's all the same stuff.. EasyC is just an abstraction layer for WPILib, and WPILib is just an abstraction layer for the low level stuff. Either way, it all boils down to the communication between the uP and mP, and what all of your low level outputs and inputs are.
Well, that means I probably cannot emulate WPILib or EasyC unless I get source for the libraries since creating the emulator requires overriding the low level outputs and inputs. It appears that the way Rob Bayer's emulator works is to modify the headers of two .c files that use low level I/O stuff so it uses the "hacked" I/O overrides instead when compiled with that code. Then running the main becomes a breeze since the variables are just stored in the PC memory. The hacked I/O files may even redirect back to the emulator. Of course, I have yet to understand how the hacks are actually carried out, but I will learn in due time. Besides, I need to make one for the serial port eventually...

ham90mack
10-09-2007, 05:10 PM
Well, it seems that I am not allowed to edit my status post above... I didn't know that...

I have added the menu bar to the GUI now. Once I get the switches, analog inputs, and the PWM outputs added to the GUI, I should probably be able to release it for everyone to see. Hopefully this will be done some time next week, assuming nothing huge gets in the way.

I have been thinking of another feature: input recording and playback. This way, the input could be recorded step by step and tested on the robot code many times. It might be a bit easier to test with something like this since the inputs will always be the same, but the outputs would change with the changes in the code.