Multibot Navigation
.
Okie, here we go. I just got my shipment of 6 m3pi. After working a lot with the 3pi I found it to be an awesome Agent for my Thesis experiment. I unboxed one of the robots, and assembled the mbed and the XBee on it.
Requirements
- The robot must be able to communicate with other robots.
- The robot must recognize approaching other robots.
- The robot must show it's battery level.
Current Hurdels
I've no idea how to connect the Sharp proximity sensor yet. It seems that they way they did it in 3pi is irrelevant. How can I connect it to a free IO line of the mbed it self? Is that even possible? I've currently working on the battery that shows me how low the battery is.
Battery Counter
It's working! It'll show you the battery level! It's awesome!
Battery
#include "mbed.h" #include "m3pi.h" m3pi m3pi; float bat; char buffer [4]; int main() { m3pi.locate(0,1); while(1) { bat=m3pi.battery(); bat=bat*1000; sprintf (buffer, "%f", bat); m3pi.cls(); m3pi.printf(buffer); wait(0.5); } }
the wait is so it won't over do it and randomly spam stuff.
Wireless communication
The robots will communicate using XBee. It is important to first indicate we have a serial device. More info about serial devices can be found in here: http://mbed.org/handbook/Serial The code parts currently relevant to me are as follow:
Serial xbee(p28, p27); xbee.baud(19200); xbee.printf("Hello World\n");
The port order is tx, rx. Note that if you would write p27,p28 (wrong order) the blue leds on the mbed will blink. The first command defines the serial part - the XBee. Please note that xbee is just a name and can be substituted with anything you might like. I found it helpful to use this name. The second line sets the communication protocol. I think that for now I will leave it at that. The third line will send a string, I will decide how to build this string later to encompass the information I want to transfer between agents.
I'm trying to create a simple communcation example between my two robots. one is using the following code
First_Robot
#include "mbed.h" #include "m3pi.h" m3pi m3pi; Serial xbee(p28, p27); // tx, rx int main() { m3pi.locate(0,1); m3pi.printf("one"); xbee.baud(19200); while(1) { xbee.printf("Hello World\n"); } }
The other one is using this line
Second_Robot
#include "mbed.h" #include "m3pi.h" m3pi m3pi; Serial xbee(p28, p27); // tx, rx char string[50]; int main() { m3pi.locate(0,1); m3pi.printf("two"); xbee.baud(19200); while(1) { xbee.scanf("%s", &string); m3pi.locate(0,1); m3pi.printf(string); } }
But obviously, this isn't working right now.
Please log in to post comments.