Off Robot Development - MontclairRobotics/cyborg GitHub Wiki
Overview
While not meant (at least at the moment) to be a full real-time 3d simulation, work is in progress to develop a virtual environment to allow for code testing without robot hardware. This will take the form of an application that will display virtual devices (speed controllers, switches, endcoders, etc.) that will allow for input and return output from a cyborg robot class. This is done by hijacking the cyborg devices and linking them to the GUI components. This system will also allow for free running, slow, or single-step execution of init and periodic function calls to facilitate controlled testing often not possible on a live robot.
Implementation
This requires two fields in Cyborg - a boolean simulationActive and a CBSimLink simLink. Normally simulationActive will not be set, but if the robot class is instantiated by the simulation environment the simLink class will be set and simulationActive set to true. This must be done before the robot is initialized. This way during initialization the cyborg devices will operate in simulation mode and exchange data with the simLink class instead of the actual hardware.
The simulation environment will populate simLink base on the GUI, execute a call to the cyborg robot class and then update the GUI. This could be used with live or simulated network tables, which would allow for testing of live vision systems. Testing might also be done with live joysticks.
With minimal impact on the Cyborg class itself, it is hoped that essentially no code other than the devices themselves will effected by having a simulation active, with the goal that functionality testing will be quite accurate. Obviously, timing and physical response (PID) testing will not be valid in the simulation environment.
The simulation program will hopefully advance to where meaningful testing is easy. For example allowing linkage between a speed controller and an encoder or an encoder and a switch in the GUI would allow for complex behaviors to be tested.