![]() |
Code Simulator
I've been playing with the idea of creating a simulator for next year, where you would input code and an onscreen diagram would show you the values of sensors, location on the field, etc. How would I be able to simulate what code would do in a real world environment? I can understand making a scripting simulator (DRIVE_10_FEET kinda thing), but I can't comprehend how to take arrays/structs/variables in a piece of code and relate it to how a robot would react.
Thanks for the help guys, if/when I finish this I'm going to definetly post it here =) EDIT: Anybody have an idea on what language I should use? I'm thinking of C# so I can have an excuse to learn it ( :p ), but maybe VisualBasic for ease of use... |
Re: Code Simulator
Quote:
As for your description, you would want a real-time C preproccessor, plus a VM. (Or just a C scripting engine). Either way, I would like to here how it goes. |
Re: Code Simulator
Personally, I'd do it in C++, if only because I already know it. I've read a few books on C#, but I know it no where near well enough to do the fairly in depth way that will be required for this. Depends on your learning style though: if you like to get into the heavy stuff right away on a realy project, go right ahead. :)
I'm not positive if you're talking about a full blown simulator which would emulate all aspects of a full RC program, or just a simple training device. I'll assume the latter. (First one. :) I always get confused... ;)) There are two ways you could do it. The first way is to go from a compiled hex and execute it fairly directly (maybe?), which simplifies the final programming, but requires you to learn all the hex codes of the RC. You could also go from the source code and interpret it, which may make programming harder/longer, but will definetely require less study of something you'll use only once. I'd personally go with the second method (from source). I've experimented with creating my own C-like interpreted language and I'd probably use something similar to that. The basic idea is the code goes through each file and builds a giant hierarchy of "variable" and "function" objects. A variable can store any value (ignore typing a way for simplicity) and a function knows how interrprut individual statements in a function. Interrupts could also probably be fairly easily handled. Just have a seperate thread which wakes on a button press or every x ms and runs through an functions stored in a special location/vector/array. |
Re: Code Simulator
Guys,
I strongly suggest that you learn about the simulator which you already have before you go off and try and reinvent the wheel. Look at Introduction to MPLABŪ SIM Software Simulator for a good introduction. Mike |
Re: Code Simulator
Having a robot code simulator is an interesting idea.
My thoughts: We use the C language and there are C compilers for PCs. So theoretically you could compile the code for a robot on a PC with minimal changes. I already do something like this. I cut and paste code on my computer to test to see if it works as I expect it to before I try it out on the robot. The problem is that even if the logic is right the numbers are wrong. For instance, if I want to rotate right 20 degrees I can check my code on my computer and see that the pwms for the right drive motors are decreasing while the left ones are increasing but I cannot tell if I'm going too far or too fast or even if there is enough power going to the motors to for the robot to move at all. What I would need in a simulator would be to calculate the physics of the situation. This would probably be harder than making a C interpreter. However, if you do make a simulator, share it, because I would use it. :) |
Re: Code Simulator
From this thread:
Quote:
|
Re: Code Simulator
Don't know exactly, but it would support auton and interrupts. ;)
But yeah, Roboemu gets the job done mostly. |
Re: Code Simulator
I've used RoboEmu, nice program. The difference between mine and RoboEmu, is mine will be geared mostly towards autonomous mode (it'll also have support for user controlled).
User controlled mode would be similar to the RoboEmu program, a virtual joystick, the ability to change the values of sensors. It'll also have a view of where the robot is on the field, how the arm is positioned, etc. To see how the arm/other limbs are positioned will be a hard problem to solve, seeing as each teams is different. Originally, it'll be for a generic type of arm, and hopefully it will evolve into some type of customization system. Autonomous mode will be the same as user controlled, except that it runs just from the code (like in real life). Not sure how I'm gonna handle advanced sensors such as a gyroscope or CMUCam, so those probably won't be implemented in the first few versions. All in all, with the massive amount of projects I've thrown into a ToDo pile, this will probably result into a very basic version by the end of the summer. Maybe not something to completely replace Roboemu, but definetly as an alternative. |
| All times are GMT -5. The time now is 22:00. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi