Home > January 2013
January 2013
LaserBots: User Manual
Category : Game, Implementation, Phase Two, User Manual 1
OBJECTIVE OF THE GAME
PLAYERS
Technical Manual
Design
Firing Device and Detection
- Firing System and Detection
- Updated Firing Device
- Laser Setup and Detection
- Laser Detection: Handling Multiple Detector Circuits
Aiming
Communications
- Communications Design
- Understanding Control Signals on the Arduino
- IPad to Computer Comms
- Point-to-Point XBee Network Testing
- Point-to-Multipoint Broadcast Network
- XBee Configuration: Coordinator and Router (Circle Network)
- Circle Network: Controlling Each Robot
Human Computer Interfaces
- Offboard System
- Onboard Video
- Raspberry Pi Setup
- Processing On Raspberry Pi
- Improving IPad Interface
- Testing Multiple Controllers
- Games Master GUI
Conclusion
Future Work
Category : Implementation, Phase Two 0
Problems with Design
Category : Implementation, Phase Two 0
Motor Current Spikes Triggering Interrupts
It was discovered during extensive testing that when motors were turned on i.e. the robot driving, that the interrupts for laser detection were being called. This was only found when status LEDs were implemented, as otherwise there was no other indication of the laser detection other than on the GUIs. It is suggested that this is the reason why both robots cannot be controlled simultaneously through the network, as the interrupt is flooding the network with 'games master' packets, and causing the actual control signals to robot 2 to be lost.
On-board Video on Raspberry Pi
After attempting to get Processing to run on the Raspberry Pi, and observing the speed at which that runs, concerns were raised about the ability of the Pi to process two video streams simultaneously. In addition, other groups findings were that the Pi could only achieve an approximate refresh rate of 1 frame per second at a very low resolution from a wired webcam. Our project would require this stream to be wireless, and at a high enough resolution to see the laser.
Power Consumption
Other findings from testing were that each robot had a very short battery life, with the 6V power gradually running out. In addition the 9V batteries that were powering the Arduino and Xbee were very cheap batteries from a pound shop, and did not provide enough juice to run both. Higher quality batteries were purchased and this solved the issue, although it is unknown as to how long for.
Project Management
Project Timeline
Due to certain parts of the project taking less and some parts being considerably more difficult than was initially thought, along with delay in obtaining particular components the project timeline was updated to reflect the plan for the remainder of the project. Initial timing is on the top line and the revised timing is on the second line in red.
Updated Project Timeline |
Final Demonstration Code
Category : Implementation, Phase Two 0
Final Arduino Code for Robot 1
#include <Servo.h> #include "avr/interrupt.h" char instruction [10]; //instruction sent to arduino int i = 0; //index for instruction array int j = 0; //index for for loop String stringXCoord = ""; int intXCoord; //x coordinate for servo String stringYCoord = ""; int intYCoord; //y coordinate for servo Servo servoX; //servo x Servo servoY; //servo y
Final Build Pictures
Thursday, 17 January 2013 Category : Implementation, Phase Two 0
Games Master GUI
Wednesday, 16 January 2013 Category : Comms, Design, Implementation, Phase Two 0
DESIGN
Testing Multiple Controllers
Sunday, 13 January 2013 Category : Comms, Implementation, Phase Two 0
TouchOSC configuration screen |
Sending Messages
Using some of the examples on the OscP5 library's website it was possible to create some prototype code to send OSC messages back to the controller, to update labels and turn on LEDs etc. The processing code below updates the player's score label.Improving iPad Interface
Saturday, 12 January 2013 Category : Design, Phase Two 0
Improved Interface |
PCB Design and Manufacture
Friday, 11 January 2013 Category : Implementation, Phase Two 1
PCB Schematic |
Building a Full Robot
Tuesday, 8 January 2013 Category : Implementation, Phase Two 0
Completed Prototype |
Circle Network: Controlling each robot
Monday, 7 January 2013 Category : Comms, Implementation, Phase Two 0
Circle Network Setup |
NEW PACKET STRUCTURE
To implement this correctly, the packet that is being sent round needs to be modified so that the instruction is sent to the correct LaserBot. Therefore, the new packet format is as follows:< - character to signify start of message
1 or 2 - robot ID
F or f - turn laser on or off
XX - numbers to control servo x
XX - numbers to control servo y
F, B or S - left motor controls (forward, back or stop)
F, B or S - right motor controls (forward, back or stop)
> - character to signify end of message
Also, to send the scores back to the Games Master, another packet needs to be introduced:
[ - character to signify start of message
G - intended for Games Master
1 or 2 - robot ID
XX - number representing how much score should be incremented
] - character to signify end of message
LASERBOT ONE CODE
INSTRUCTION PACKET CODE
char instruction [10]; //instruction sent to arduinoNext, a String needs to be introduced so that a message can be resent on to robot 2.
//message to send on to Robot 2 String resendMessage = "";Inspecting the previous code for the robot, the first part of void loop() stays the same - while there is serial data available, read the data and store in the instruction array. Next, check to see if the instruction starts and ends with the characters '<' and '>' (remembering to change the index by one for the ending character).
Next, another if statement needs to be added to check whether or not the instruction received is for robot 1.
//check that message is for robot 1 <1....> if (instruction[j+1] == '1') {If the message is for the robot, the normal parsing takes place (parse the rest of the message to deal with lasers, servos and motors). Else, if the message is for robot 2, robot 1 needs to resend the message. The message is concatenated together and then printed out. Before being printed, however, the serial port is flushed.
//else check is message is for robot 2 <2...> else if (instruction[j+1] == '2') { //reset resend message to blank resendMessage = ""; int k = 0; //loop around the instruction message for (k = j; k<(j+10); k++) { //concatenate all characters of message resendMessage += instruction[k]; } Serial.print(0); //flush the serial port Serial.print(resendMessage); //send the message onto Robot 2 }That is all the code that needs to be added/changed for robot 1 to parse the instruction message.
SCORE PACKET CODE
//string to print to contact games master - in the following form: //G (games master) 2 (robot 2's score) 10 (how much to increment score) String GMscoreLR = "[G210]"; String GMscoreB = "[G215]";
As can be seen, the robot ID has been stated has 2, even though this code is on robot 1. This is because robot 1 has been hit, but it has been hit by robot 2 and so it is robot 2's score that needs to be updated.
The reason for two different score packets is for the two interrupts that are used to detect when the robot is hit. This allows for two different scores to be implemented. Therefore, in interrupt one the following code needs to be added
Serial.print(0);//flush the serial port //print message to GM to increment Robot 2's score Serial.println(GMscoreLR);In the other interrupt, this code needs to be added:
Serial.print(0);//flush the serial port //print message to GM to increment Robot 2's score Serial.println(GMscoreB);These interrupts print the correct string which will then be sent on to robot 2.
LASERBOT TWO CODE
INSTRUCTION PACKET CODE
char instruction [10]; //instruction sent to arduinoNext, a String needs to be introduced so that a message can be resent on to the Games Master.
//message to send on to Games Master String resendMessage = "";Again, inspecting the previous code for the robot, the first part of void loop() stays the same - while there is serial data available, read the data and store in the instruction array. Next, check to see if the instruction starts and ends with the characters '<' and '>' (remembering to change the index by one for the ending character).
Next, another if statement needs to be added to check whether or not the instruction received is for robot 2. This is not really needed as anything that is sent to robot 2 will be for it, but it is extra error checking.
//check the message is for robot 2 <2...> if (instruction[j+1] == '2') {
SCORE PACKET CODE
//if message is score packet for the Games Master else if ((instruction[j] == '[') && (instruction[j+5] == ']')) { //reset resend message to blank resendMessage = ""; int k = 0; //loop around the instruction message for (k = j; k<(j+6); k++) { //concatenate all characters of message resendMessage += instruction[k]; } Serial.print(0); //flush the serial port Serial.print(resendMessage); //send the message onto games master }In this else-if statement, the message is concatenated together and then sent on to the Games Master.
For robot 2's own score, the same code as robot 1 needs to be included in the interrupts.
Serial.print(0);//flush the serial port //print message to GM to increment Robot 2's score Serial.println(GMscoreLR);And in the other interrupt, this code needs to be added:
Serial.print(0);//flush the serial port //print message to GM to increment Robot 2's score Serial.println(GMscoreB);That concludes all the code that needs to be updated on the robots. Please see post BLAH for the parsing of the Games Master packets in Processing.
XBee Configuration: Coordinator and Router (Circle Network)
Category : Comms, Implementation, Phase Two 1
After trying a point to point network, and a point to multipoint network, it was decided that a circle network would be implemented.
Circle network |
WHICH ONE TO BE THE COORDINATOR?
Coordinator and Router Setup for Circle Network |
Running Processing on the Raspberry Pi
Category : Implementation, Phase Two 0
sudo apt-get install openjdk-6-jdk librxtx-java
Processing linux 32 ( in this case 1.5.1) was then downloaded and unzipped.
http://processing.org/download/
This linux verion of Processing assumes a Intel architecture so we need to remove the link to java directory from within the unzipped files. To do this the command rf is used. a side effect of this is that the director will most likely be deleted. This is described in more detail here. http://www.linuxjournal.com/article/50
rm -rf java
Point to Multipoint - Broadcast Network Design
Category : Comms, Implementation, Phase Two 0
Broadcast configuration for an Xbee network |
Point to Point Xbee Network Testing
Friday, 4 January 2013 Category : Comms, Implementation, Phase Two 2
Xbees in Unicast mode |
Xbee Shields
Trailer
Archives
-
▼
2013
(18)
-
▼
January
(18)
- Welcome!
- LaserBots: User Manual
- Technical Manual
- Future Work
- Problems with Design
- Project Management
- Final Demonstration Code
- Final Build Pictures
- Games Master GUI
- Testing Multiple Controllers
- Improving iPad Interface
- PCB Design and Manufacture
- Building a Full Robot
- Circle Network: Controlling each robot
- XBee Configuration: Coordinator and Router (Circle...
- Running Processing on the Raspberry Pi
- Point to Multipoint - Broadcast Network Design
- Point to Point Xbee Network Testing
-
▼
January
(18)
Categories
- Aiming (2)
- Comms (10)
- Design (13)
- Detection (2)
- Game (1)
- Implementation (22)
- Laser (2)
- Phase One Report (10)
- Phase Two (25)
- Plan (1)
- User Manual (1)