COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The...
-
Upload
irene-webster -
Category
Documents
-
view
212 -
download
0
Transcript of COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The...
![Page 1: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/1.jpg)
COLONYCOLONYWIRELESSWIRELESS
September 26, 2008September 26, 2008
![Page 2: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/2.jpg)
Outline
1.Motivation and Goals
2.Introduction to the XBee
3.The Wireless Library
4.Example Packet Group
5.The Token Ring
6.Questions
![Page 3: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/3.jpg)
Why Wireless?
Enables Cooperation Allows Sharing of Sensor Information
– BOM readings for cooperative searching Synchronizes BOM flashes
– Prevents interference from multiple robots Controls access to resources, such as
charging stations External monitoring through ColoNet
![Page 4: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/4.jpg)
XBee module
ZigBee wireless protocol– Open industry standard– IEEE 802.15.4– Low-cost, low-power– 2.4GHZ– Widely used in sensor networks
XBee wireless module– www.maxstream.net– 30m indoor range / 100m outdoor range– Simple interface
![Page 5: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/5.jpg)
5
Selected XBee Features
16-bit Addressing Personal Area Networks (PANs)
– May send packets only to your PAN– Able to change PAN at any time
16 Channels– XBees in different channels cannot communicate
API Mode– Provides more features
Interference prevention
![Page 6: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/6.jpg)
6
XBee Packets
Send up to 100 bytes as a packet Send to a single robot, a PAN, or everyone Optionally set a frame number
– Confirms reception of packets to single robots
![Page 7: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/7.jpg)
7
Packet Types
Robot to Robot– Send to a single XBee– Specified by 16-bit address– ACK confirms reception, matched with frame
PAN– Send to all XBees in our current PAN
Global– Send to all XBees in our channel
![Page 8: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/8.jpg)
8
Wireless Library
Simple Modular Functional
#include <dragonfly_lib.h>#include <wireless.h>
int main(){ dragonfly_init(ALL_ON); wl_init();
while (1) { wl_do(); do_stuff(); } return 0;}
![Page 9: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/9.jpg)
9
Packet Groups
Organize packets into groups with similar functions for modularity
Examples:– Error Messages– Token Ring
Each packet in a group shares a group code Individual packets have packet types Group and type uniquely identify a packet Packets can be of any length (< 100 bytes)
![Page 10: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/10.jpg)
10
Packet Group Handlers
Registered with the wireless library to receive packets from a specific group
Contains– Group Code– Function to handle received packets– Function to handle ACKs or failures– Function to call on timer tick– Function to call when the packet group is
removed
![Page 11: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/11.jpg)
11
C Programming: Function Pointers
Variables which point to the address of a function
When called, call thefunction they point to
void foo(void) { printf(“Hello World!”);}
void bar(void) { printf(“Goodbye World!”);
void (*func)(void) = &foo;
func();>> Hello World!func = &bar;func();>> Goodbye World!
![Page 12: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/12.jpg)
12
Packet Group Handlers (contd.)
typedef struct{ unsigned int groupCode;
void (*timeout_handler) (void); void (*handle_response) (int frame, int received); void (*handle_receive) (char type, int source, unsigned char* packet, int length); void (*unregister) (void);} PacketGroupHandler;
Register packet groups with wl_packet_group_register
![Page 13: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/13.jpg)
13
Packet Group Handler Example
Creating a packet group to control robots through ColoNet
Only need to respond to commands, so will only implement handle_receive
![Page 14: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/14.jpg)
14
ColoNet Example (contd.)
void colonet_receive (char type, int source, unsigned char* packet, int length){ switch (type) { case BEEP: buzzer_chirp(1000, 200); break; case HUNT_RON: find_ron(); ram_ron(); break; case SELF_DESTRUCT: self_destruct(); break; }}
![Page 15: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/15.jpg)
15
ColoNet Example (contd.)
PacketGroupHandler colonetHandler = {COLONET_GROUP, NULL, NULL, &colonet_receive, NULL}
int main(){ dragonfly_init(ALL_ON); wl_init(); wl_register_packet_group(&colonetHandler); while (1) wl_do();}
This program will obey all of ColoNet’s commands.
![Page 16: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/16.jpg)
16
Sending Packets
Now we are able to receive packets But how do we send packets? Simply call these functions in wireless.h
void wl_send_robot_to_robot_global_packet (char group, char type, char *data, int len, int dest, char frame)
Send a packet to a specific robot in any PAN. void wl_send_robot_to_robot_packet (char group, char type, char *data, int len, int dest, char frame)Send a packet to a specific robot in our PAN. void wl_send_global_packet (char group, char type, char *data, int len, char frame)Send a packet to all robots. void wl_send_pan_packet (char group, char type, char *data, int len, char frame)Send a packet to all robots in our PAN.
![Page 17: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/17.jpg)
17
Colonet Example
We can receive wireless packets, but we still need to send them
void send_beep(int robot){ wl_send_robot_to_robot_global_packet(COLONET_GROUP, BEEP, NULL, 0, robot, 0)}
void hunt_ron(){ wl_send_global_packet(COLONET_GROUP, HUNT_RON, NULL, 0, 0);}
![Page 18: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/18.jpg)
18
Colonet Example
void bomb_squad(){ wl_send_global_packet(COLONET_GROUP, SELF_DESTRUCT, NULL, 0, 0);}
![Page 19: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/19.jpg)
19
Colonet Example
Now, ColoNet is able to control robots using the ColoNet packet group.
![Page 20: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/20.jpg)
Bearing and Orientation Module (BOM)
IR emitter/detector ring Emitter mode
– All emitters are powered simultaneously (beacon)
Detector mode– Detectors can be polled
for analog intensity readings
Used for localization– Determining relative
directions of robots– Seeking charging station
![Page 21: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/21.jpg)
21
Why do we need a token ring?
If more than one BOM flashes at once, other robots won’t know which is which
Only one BOM can flash at a time Token ring controls which BOM can flash
![Page 22: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/22.jpg)
22
Token Ring
Only robot with “token” may flash BOM Once BOM is flashed, the robot with the
token passes it to the next robot (determined by XBee ID)
Sends BOM readings for the other robots with token, so that each robot has a sensor matrix of all BOM readings
![Page 23: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/23.jpg)
23
Sensor Matrix
Each robot passes its own sensor readings with the token
All robots form a sensor matrix, storing relative location of all robots
Various applications, including– Seeking a charging station– Cooperative Maze Solving– Following another robot
![Page 24: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/24.jpg)
24
Ad-hoc Network
If a robot does not pass the token quickly enough, or dies, the previous robot removes it from the network and it must rejoin
Robots can freely join and leave the network, and the token continues to be passed
To join the token ring, a robot sends a join request
Preceding robot in ring adds the robot, and sends the token to him next time
![Page 25: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/25.jpg)
25
Ad-hoc Network Advantages
Leaderless Network Stable when robots die New robots can join easily
![Page 26: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/26.jpg)
26
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
![Page 27: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/27.jpg)
27
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
![Page 28: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/28.jpg)
28
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
![Page 29: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/29.jpg)
29
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
![Page 30: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/30.jpg)
30
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
![Page 31: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/31.jpg)
31
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
Bot1 has been eliminated by ColoNet!
![Page 32: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/32.jpg)
32
Token Ring Example
Ron
Bot 1
Bot 2
Bot 3
- Token
Bot1 has been eliminated by ColoNet!
Bot1 does not respond, so Ron realizes it is dead. He sends the token to Bot2 instead.
![Page 33: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/33.jpg)
33
Using the Token Ring
#include <dragonfly_lib.h>#include <wireless.h>#include <wl_token_ring.h>
int main(){ dragonfly_init(ALL_ON); wl_init(); wl_token_ring_register(); while (1) wl_do();}
To use the wireless library, set USE_WIRELESS = 1 in the Makefile
![Page 34: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/34.jpg)
34
Summary
Packet Groups to add wireless functionality Token Ring to find relative locations of robots
![Page 35: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/35.jpg)
35
Troubleshooting
Connect to dongle at 9600 Baud '+++' enters command mode Only XBees with the latest firmware support
the wireless library (ATVR) Xbee ID ('ATMY' to read, 'ATMY num' to set) 0 < ID < XBEE_MAX_ID, must be unique Default Channel should be C (ATCH) ATWR to save settings Running the motors may cause interference
![Page 36: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/36.jpg)
36
Wireless Applications
Tag / Lemmings Cooperative Maze Solving Marching Band Task Allocation Wireless monitoring and control with Colonet Autonomous Recharging Mapping
![Page 37: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/37.jpg)
![Page 38: COLONYWIRELESS September 26, 2008. Outline 1.Motivation and Goals 2.Introduction to the XBee 3.The Wireless Library 4.Example Packet Group 5.The Token.](https://reader035.fdocuments.us/reader035/viewer/2022070415/5697bfde1a28abf838cb1fcb/html5/thumbnails/38.jpg)
Joke
Even bytes get lonely for a little bit.