Robotics Framework ?

Hey all,

this is my first post in here, so bear with me :slight_smile:

So me and my friend want to build a little robot over the summer (we have no real experience in that, so some of the ideas might not be applicable at all).
Basically I want to present to you the idea we had for the software and wanted to get some feedback from you on whether

  • you think this is doable
  • you think this is reasonable
  • you think other people might be interested in using the software
  • something similar already exists

We thought it would be quite nice to have kind of a robotic framework in which hardware components could be easily added and removed to/from the robot without changing the code much.
That said we would like to have a set of components of the robot (carriage, sensors, LEDs, network stuff, etc) which would all implement a given interface and would be given the hardware location (i.e. pins or ic2 addresses or whatever) at creation. These components can then be connected to each other, not sure how exactly yet, maybe through function pointers... Meaning you could do something like this:

Component distanceSensor = new distanceSensor(2);     // to be found on port 2 analog
Component led1 = new led(5);           // to be found on port 13 digital
distanceSensor.onEvent(distanceSensor.EVENT_CLOSE_OBJECT, (void*)led1.turnOn());    // not sure if syntax is correct ;P

Then one would only have to implement or reuse the robot components, create them and connect them (onEvent methods and action mehtods). We'll then probably need some more interfaces and a more flexible way of connecting components, but we'll see that later.
Everything else would be handled by the framework, which would basically just call one specified method on every registered component each loop cycle. This method would then do things like poll sensor values, create output, etc.
Another nice thing that would be possible then would be to implement proxies for components running on a second arduino which would transparently handle the communication.

At the end some code like the following should be enough to get a simple rolling robot working:

void robotSetup() {
  Component carriage = new Carriage(12,13,3,11,9,8,0,1);     // motor shield ports;
  Component distanceSensor = new distanceSensor(2);
  distanceSensor.onEvent(distanceSensor.EVENT_CLOSE_OBJECT, (void*) carriage.stop());   // if there is a close object, stop the robot

  this.addComponent(carriage);             // this is the robot class

To sum it up the goal is to create flexible software for many different hardware configurations.
If someone would then be interested we could also put in on github.

Thanks for reading and happy hacking :slight_smile: