Revision 1554

View differences:

include/libwireless/sensor_matrix.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file sensor_matrix.h
28
 * @brief Definitions for sensor matrices
29
 *
30
 * Contains functions and declarations for using sensor matrices.
31
 *
32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33
 **/
34

  
35
#ifndef SENSOR_MATRIX_H
36
#define SENSOR_MATRIX_H
37

  
38

  
39
/**
40
 * @defgroup sensormatrix Sensor Matrix
41
 * @brief the robot sensor matrix
42
 *
43
 * These functions and structures are used for localization
44
 * to determine the relative directions of robots.
45
 *
46
 * @{
47
 **/
48

  
49
#define MAXIMUM_XBEE_ID		0x10
50
#define READING_UNKNOWN		0xFF
51

  
52
/**
53
 * @struct SensorMatrix
54
 *
55
 * A sensor matrix.
56
 **/
57
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct
58
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size.
59
// Thus, pointers should be first, followed by int, followed by char.
60
typedef struct
61
{
62
	/**
63
	 * The number of robots in the token ring.
64
	 **/
65
	int numJoined;
66
	/**
67
	 * The element representing a robot is true if that robot
68
	 * is in the token ring and false otherwise.
69
	 **/
70
	unsigned char joined[MAXIMUM_XBEE_ID];
71

  
72
	// on the bayboard, we don't include the matrix to save memory.
73
#ifndef BAYBOARD
74
	/**
75
	 * The matrix. Each row represents the readings of one
76
	 * robot.
77
	 **/
78
	unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
79
#endif
80
} SensorMatrix;
81

  
82
/**@brief Create a sensor matrix **/
83
void sensor_matrix_create(void);
84
/**@brief Set a reading in a sensor matrix **/
85
void sensor_matrix_set_reading(int observer, int robot, int reading);
86
/**@brief Get a reading in a sensor matrix **/
87
int sensor_matrix_get_reading(int observer, int robot);
88
/**@brief Set whether the robot is in the token ring **/
89
void sensor_matrix_set_in_ring(int robot, int in);
90
/**@brief Get whether the robot is in the sensor ring **/
91
int sensor_matrix_get_in_ring(int robot);
92
/**@brief Get the number of robots which have joined the token ring **/
93
int sensor_matrix_get_joined(void);
94
/**@brief Get the maximum size of the sensor matrix **/
95
int sensor_matrix_get_size(void);
96

  
97
/** @} **/ //end defgroup
98

  
99

  
100
#endif
101

  
include/libwireless/wireless.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file wireless.h
28
 * @brief Contains definitions for the wireless library.
29
 *
30
 * Contains functions for the wireless library.
31
 *
32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33
 **/
34

  
35
#ifndef WIRELESS_H
36
#define WIRELESS_H
37

  
38
//Note: If this is raised above 16, we will need to do
39
//something about frame numbers for TX Status packets.
40
/**
41
 * The maximum number of packet groups.
42
 **/
43
//TODO: a PacketGroupHandler is at least 10 bytes (I don't know if function pointers are 2 bytes
44
// or 4 bytes).  That means that in the c file, your array of packet groups is at least 160 bytes.
45
// Normally that might be fine (the robot's avr chips have 4k SRAM), but austin's chip only has
46
// 1k SRAM, so if this number can be reduced or if the size of the struct could be reduced, that would be a plus.
47
#define WL_MAX_PACKET_GROUPS 16
48

  
49
/**
50
 * @defgroup wireless Wireless
51
 * @brief Wireless definitions.
52
 *
53
 * Contains functions and definitions for dealing with wireless functionality.<br><br>
54
 *
55
 * The wireless library provides a modular method for dealing with
56
 * wireless packets, by allowing packet groups to be registered.
57
 * A packet group is a collection of packets which share a packet
58
 * group code. Each packet in the group also has a type. A packet
59
 * group code and type are sent with each packet. When a packet
60
 * with a group code registered in the wireless library is
61
 * received, the corresponding event handler is called. The
62
 * event handler uses the packet type and other information
63
 * stored in the packet to respond.<br><br>
64
 *
65
 * This architecture allows different wireless functionality to be
66
 * defined and handled separately, making it simpler and more
67
 * efficient to take advantage of the XBee's wireless functionality.
68
 *
69
 * @{
70
 **/
71

  
72
/**
73
 * @struct PacketGroupHandler
74
 * A PacketGroupHandler represents a packet group, and is used to
75
 * register a packet group with the wireless library. It contains
76
 * handlers for various events which can occur related to a packet
77
 * group.
78
 **/
79
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct
80
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size.
81
// Thus, pointers should be first, followed by int, followed by char.
82
typedef struct
83
{
84
	/**
85
	 * The group code for this packet group. This number
86
	 * must be unique. The maximum number of packet groups
87
	 * is defined by WL_MAX_PACKET_GROUPS.
88
	 **/
89
  //TODO: if this number must be less than or equal to WL_MAX_PACKET_GROUPS, don't you only need
90
  // one byte for it and it can be made an unsigned char?
91
	unsigned int groupCode;
92

  
93
	/**
94
	 * Called every half second (not in interrupt,
95
	 * but in wl_do).
96
	 **/
97
	void (*timeout_handler) (void);
98

  
99
	/**
100
	 * Called when a transmit status packet is received
101
	 * from the XBee where the first four bits of the frame
102
	 * are  the group code.
103
	 *
104
	 * @param frame the last four bits of the frame
105
	 * @param received is true if we received an ack, 0 if
106
	 * we did not.
107
	 **/
108
	void (*handle_response) (int frame, int received);
109

  
110
	/**
111
	 * Called when we receive a packet from this group.
112
	 *
113
	 * @param type the packet type
114
	 * @param source the 16-bit address of the XBee this
115
	 * packet was sent from
116
	 * @param packet the packet received
117
	 * @param length the length of the packet
118
	 **/
119
	void (*handle_receive) (char type, int source, unsigned char* packet, int length);
120

  
121
	/**
122
	 * Called for any cleanup when the network is turned off.
123
	 **/
124
	void (*unregister) (void);
125

  
126
} PacketGroupHandler;
127

  
128
/**@brief Initialize the wireless library **/
129
int wl_init(void);
130
/**@brief Uninitialize the wireless library **/
131
void wl_terminate(void);
132
/**@brief Perform wireless library functionality **/
133
void wl_do(void);
134
/**@brief Register a packet group with the wireless library **/
135
void wl_register_packet_group(PacketGroupHandler* h);
136
/**@brief Unregister a packet group with the wireless library **/
137
void wl_unregister_packet_group(PacketGroupHandler* h);
138

  
139
/**@brief Send a packet to a specific robot in any PAN **/
140
int wl_send_robot_to_robot_global_packet(char group, char type, char* data, int len, int dest, char frame);
141
/**@brief Send a packet to a specific robot in our PAN **/
142
int wl_send_robot_to_robot_packet(char group, char type, char* data, int len, int dest, char frame);
143
/**@brief Send a packet to all robots **/
144
int wl_send_global_packet(char group, char type, char* data, int len, char frame);
145
/**@brief Send a packet to all robots in our PAN **/
146
void wl_send_pan_packet(char group, char type, char* data, int len, char frame);
147

  
148
/**@brief Set the PAN we are using **/
149
int wl_set_pan(int pan);
150
/**@brief Get the PAN we are using **/
151
int wl_get_pan(void);
152
/**@brief Set the channel we are using **/
153
int wl_set_channel(int channel);
154
/**@brief Get the channel we are using **/
155
int wl_get_channel(void);
156
/**@brief Get the 16-bit address of the XBee module **/
157
int wl_get_xbee_id(void);
158
/**@brief Set the com port on a computer, undefined on the robot.**/
159
void wl_set_com_port(char* port);
160

  
161
/** @} **/ // end defgroup
162

  
163
#endif
164

  
include/libwireless/wl_token_ring.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file wl_token_ring.h
28
 * @brief Declarations for the token ring packet group
29
 * 
30
 * Contains declarations for the token ring packet group.
31
 *
32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33
 **/
34

  
35
#ifndef WL_TOKEN_RING_H
36
#define WL_TOKEN_RING_H
37

  
38
/**
39
 * @defgroup tokenring Token Ring
40
 * @brief Wireless library token ring implementation
41
 *
42
 * This packet group is used to form a token ring, which
43
 * keeps track of the relative directions of the robots
44
 * from one another.
45
 *
46
 * @{
47
 **/
48

  
49
/**@brief Register the token ring group with the wireless library.**/
50
int wl_token_ring_register(void);
51
/**@brief Unregister the token ring group with the wirelss library.**/
52
void wl_token_ring_unregister(void);
53
/**@brief Set the functions called to turn the bom on and off.**/
54
void wl_token_ring_set_bom_functions(void (*on_function) (void), void (*off_function) (void),
55
  int (*max_bom_function) (void));
56

  
57
/**@brief Join the token ring **/
58
int wl_token_ring_join(void);
59
/**@brief Leave the token ring **/
60
void wl_token_ring_leave(void);
61

  
62
/**@brief Return the number of robots in the token ring **/
63
int wl_token_get_robots_in_ring(void);
64
/**@brief Return whether a given robot is in the token ring **/
65
int wl_token_is_robot_in_ring(int robot);
66

  
67
/**@brief Begin iterating through robots in the token ring **/
68
void wl_token_iterator_begin(void);
69
/**@brief Returns whether there are more robots to iterate through **/
70
int wl_token_iterator_has_next(void);
71
/**@brief Returns the ID of the next robot in the token ring **/
72
int wl_token_iterator_next(void);
73

  
74
/**@brief Return the latest BOM reading between two robots **/
75
int wl_token_get_sensor_reading(int source, int dest);
76
/**@brief Return the latest BOM reading between us and another robot **/
77
int wl_token_get_my_sensor_reading(int dest);
78
/**@brief Return the number of robots in the sensor matrix.*/
79
int wl_token_get_num_robots(void);
80
/**@brief Return the number of non-null elements in the sensor matrix*/
81
int wl_token_get_matrix_size(void);
82

  
83
/** @} **/ //end token ring group
84

  
85
#endif
include/libwireless/wl_basic.h
1
/**
2
 * @file wl_basic.h
3
 * @brief High Level Wireless Packet Sending-Receiving Functions
4
 *
5
 * Abstracted wireless functionality for sending and receiving packets
6
 *
7
 * @author Christopher Mar, Colony Project, CMU Robotics Club
8
 **/
9

  
10
/**
11
 * @defgroup wl_basic Wireless Basic
12
 * @brief Wireless abstraction for easily sending and receing packets.
13
 *
14
 * A high level abstraction of the wireless library.
15
 *
16
 * This will allow you to easily send and receive packets.
17
 *
18
 * @{
19
 **/
20

  
21
#ifndef WL_BASIC_H
22
#define WL_BASIC_H
23

  
24
#include <wireless.h>
25

  
26
/** @brief default wireless group for basic sending and receiving packets **/
27
#define WL_BASIC_GROUP 8
28

  
29
/** @brief PacketGroupHandler struct for Basic Group **/
30
PacketGroupHandler wl_basic_group_handler;
31

  
32
/**
33
 * @brief struct that contains relevant packet information
34
 **/
35
struct PacketInfo {
36
    char new_flag;
37
    char type;
38
    int source;
39
    unsigned char* data;
40
    int length;
41
};
42

  
43
/**
44
 * @brief current packet information, correct after wl_basic_do()
45
 **/
46
struct PacketInfo current_packet;
47

  
48
/** @brief init wireless for Basic Group **/
49
int wl_basic_init( void (*handle_receive) (char type, int source, unsigned char* packet, int length) );
50
/** @brief init wireless for Basic Group with default packet handling **/
51
int wl_basic_init_default( void );
52
/** @brief internal function to register a packet handler function **/
53
void wl_basic_register_handler( void (*handle_receive) (char type, int source, unsigned char* packet, int length) );
54
/** @brief send a packet to a single robot in Basic Group **/
55
void wl_basic_send_robot_packet( char type, char* data, int len, int dest );
56
/** @brief send a packet to all robots in Basic Group **/
57
void wl_basic_send_global_packet( char type, char* data, int len );
58
/** @brief internal default packet handler if none is specified on init **/
59
void wl_basic_packet_receive_handler( char type, int source, unsigned char* packet, int length );
60
/** @brief wrapper for wl_do() to return packet data buffer **/
61
unsigned char* wl_basic_do_default( int *length );
62
/** @} **/ // end defgroup
63

  
64
#endif
65

  
include/libwireless/wl_defs.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file wl_defs.h
28
 * @brief Definitions for Wireless
29
 *
30
 * Contains definitions for wireless packet groups, packet types,
31
 * debugging information, etc.
32
 *
33
 * @author Brian Coltin, Colony Project, CMU Robotics Club
34
 **/
35

  
36
#ifndef WL_DEFS_H
37
#define WL_DEFS_H
38

  
39
//comment out this line if using a computer hooked up to an xbee
40
//#define ROBOT
41

  
42
//uncomment this line for debug information
43
//#define WL_DEBUG
44

  
45
// Packet Groups and Types
46

  
47
// Error group
48
#define WL_ERROR_GROUP 1
49

  
50
#define WL_ERROR_STRING_TYPE 1
51

  
52
// Token Ring group
53
#define WL_TOKEN_RING_GROUP 2
54

  
55
#define WL_TOKEN_PASS 1
56
#define WL_TOKEN_SENSOR_MATRIX 2
57
#define WL_TOKEN_BOM_ON 3
58
#define WL_TOKEN_JOIN 4
59
#define WL_TOKEN_JOIN_ACCEPT 5
60

  
61
// timing constants
62
#ifndef FIREFLY
63
#define BOM_DELAY 100
64
#else
65
#define BOM_DELAY 200
66
#endif
67

  
68
#define DEATH_DELAY 4
69
#define JOIN_DELAY 8
70

  
71
#ifdef WL_DEBUG
72

  
73
#ifdef ROBOT
74
#include <serial.h>
75
#endif
76

  
77
#ifdef ROBOT
78
#define WL_DEBUG_PRINT( s ) usb_puts( s )
79
#else
80
#define WL_DEBUG_PRINT( s ) printf( s )
81
#endif
82

  
83
#ifdef ROBOT
84
#define WL_DEBUG_PRINT_INT( i ) usb_puti(i)
85
#else
86
#define WL_DEBUG_PRINT_INT( i ) printf("%i", i)
87
#endif
88

  
89
#else
90

  
91
#define WL_DEBUG_PRINT( s )
92
#define WL_DEBUG_PRINT_INT( i )
93

  
94
#endif
95

  
96
#endif
97

  
include/libwireless/xbee.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file xbee.h
28
 * @brief Contains definitions for using the XBee
29
 *
30
 * Contains definitions for interfacing with the 
31
 * XBee module, from either a robot or a computer.
32
 * To use a robot, define ROBOT in wl_defs.h, and
33
 * to use a computer, don't define ROBOT.
34
 *
35
 * @author Brian Coltin, Colony Project, CMU Robotics Club
36
 **/
37

  
38
#ifndef XBEE_H
39
#define XBEE_H
40

  
41
/**
42
 * The port to use the XBee from on the computer.
43
 * Also, a backup port if the other is used.
44
 **/
45
#ifndef ROBOT
46
#define XBEE_PORT_DEFAULT "/dev/ttyUSB1"
47
#endif
48

  
49
/**
50
 * @defgroup xbee XBee
51
 * @brief Interface with the XBee module
52
 *
53
 * Interface with the XBee module.
54
 *
55
 * @{
56
 **/
57

  
58
/*Definitions*/
59
/**@brief Unset PAN, uses XBee default **/
60
#define XBEE_PAN_DEFAULT 0xFFFF
61
/**@brief Unset channel, uses XBee default **/
62
#define XBEE_CHANNEL_DEFAULT 0
63
/**@brief Broadcast to all robots in the PAN **/
64
#define XBEE_BROADCAST 0xFFFF
65
/**@brief No special options **/
66
#define XBEE_OPTIONS_NONE 0x00
67
/**@brief Do not receive a TX_STATUS message from this packet **/
68
#define XBEE_OPTIONS_DISABLE_RESPONSE 0x01
69
/**@brief Send the packet to all PANS **/
70
#define XBEE_OPTIONS_BROADCAST_ALL_PANS 0x04
71
/**@brief A transmit status packet **/
72
#define XBEE_TX_STATUS 0x89
73
/**@brief A packet received from another XBee **/
74
#define XBEE_RX 0x81
75

  
76
/**@brief Initialize the XBee library **/
77
int xbee_lib_init(void);
78
/**@brief Uninitialize the XBee library **/
79
void xbee_terminate(void);
80
/**@brief Get a packet from the XBee **/
81
int xbee_get_packet(unsigned char* packet);
82
/**@brief Send a packet to the XBee **/
83
int xbee_send_packet(char* packet, int len, int dest, char options, char frame);
84
/**@brief Set the PAN ID for the XBee **/
85
int xbee_set_pan_id(int id);
86
/**@brief Get the XBee's PAN ID **/
87
unsigned int xbee_get_pan_id(void);
88
/**@brief Set the channel the XBee is currently using **/
89
int xbee_set_channel(int channel);
90
/**@brief Get the channel the XBee is currently using **/
91
int xbee_get_channel(void);
92
/**@brief Get the XBee's 16-bit address **/
93
unsigned int xbee_get_address(void);
94
/**@brief Set the com port on a computer, undefined on the robot**/
95
void xbee_set_com_port(char* port);
96

  
97
/**@}**/ //end defgroup
98

  
99
#endif
include/libwireless/queue.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file queue.h
28
 * @brief A queue implementation
29
 * 
30
 * Implements a queue, a first in, first out data structure.
31
 *
32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33
 **/
34

  
35
#ifndef WIRELESS_QUEUE_H
36
#define WIRELESS_QUEUE_H
37

  
38
#ifndef ROBOT
39
#include <pthread.h>
40
#endif
41

  
42
struct node_def;
43

  
44
/**
45
 * @defgroup queue Queue
46
 * @brief A queue implementation
47
 * 
48
 * A queue implementation.
49
 *
50
 * @{
51
 **/
52

  
53
/**
54
 * @struct Queue
55
 * Represents a queue, a first in, first out data structure.
56
 **/
57
typedef struct
58
{
59
	/**
60
	 * The head of the queue, the next item to be removed.
61
	 **/
62
	struct node_def* head;
63
	/**
64
	 * The tail of the queue, the last item added.
65
	 **/
66
	struct node_def* tail;
67
	/**
68
	 * The number of elements in the queue.
69
	 **/
70
	int size;
71
	
72
#ifndef ROBOT
73
	pthread_mutex_t lock;
74
#endif
75
} Queue;
76

  
77
/** @brief Create a new queue **/
78
Queue* queue_create(void);
79
/** @brief Destroy a queue **/
80
void queue_destroy(Queue* q);
81
/** @brief Add an element to a queue **/
82
int queue_add(Queue* q, void* item);
83
/** @brief Remove an element from a queue **/
84
void* queue_remove(Queue* q);
85
/** @brief Remove all instances of a given element from a queue **/
86
void queue_remove_all(Queue* q, void* item);
87
/** @brief Get the size of a queue **/
88
int queue_size(Queue* q);
89
/** @brief Check if the queue is empty **/
90
int queue_is_empty(Queue* q);
91

  
92
/** @} **/
93

  
94

  
95
#endif
include/libwireless/wl_error_group.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * @file wl_error_group.h
28
 * @brief Error Packets
29
 *
30
 * A packet group for sending error packets.
31
 *
32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33
 **/
34

  
35
#ifndef WL_ERROR_GROUP_H
36
#define WL_ERROR_GROUP_H
37

  
38
/**
39
 * @file wl_error_group.h
40
 * @brief A packet group for error messages.
41
 *
42
 * A packet group for sending and receiving error
43
 * messages.
44
 *
45
 * @author Brian Coltin, Colony Project, CMU Robotics Club
46
 **/
47

  
48
/**
49
 * @defgroup wlerror Error Packets
50
 * @brief Functions for sending and receiving error packets
51
 * 
52
 * Functions for sending and receiving error packets.
53
 * 
54
 * @{
55
 **/
56

  
57
/**@brief Register this packet group with the wireless library **/
58
void wl_error_register(void);
59
/**@brief Unregister this packet group with the wireless library **/
60
void wl_error_unregister(void);
61
/**@brief Send a string in an error packet **/
62
void wl_error_send_string(char* str);
63

  
64
/** @} **/ // end defgroup
65

  
66
#endif
include/libdragonfly/motor.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26

  
27
/**
28
 * @file motor.h
29
 * @brief Contains definitions for controlling the motors
30
 *
31
 * Contains definitions and functions for controlling
32
 * the motors.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 * Based on Tom Lauwer's Firefly Library
36
 **/
37

  
38
#ifndef _MOTOR_H
39
#define _MOTOR_H
40

  
41
#include <avr/io.h>
42
/**
43
 * @addtogroup motors
44
 * @{
45
 **/
46

  
47
/** @brief make the motors go forwards **/
48
#define FORWARD 1
49
/** @brief make the motors go backwards **/
50
#define BACKWARD 0
51

  
52
/** @brief Initialize the motors **/
53
void motors_init(void);
54
/** @brief Set speed and direction of motor1 
55
 *  @deprecated use the left motor function instead. it's more intuitive and easier to read.**/
56
void motor1_set(int direction, int speed);
57
/** @brief Set speed and direction of motor2 
58
 *  @deprecated use the right motor function instead. it's more intuitive and easier to read.**/
59
void motor2_set(int direction, int speed);
60
/** @brief Set speed and direction of left motor **/
61
void motor_l_set(int direction, int speed);
62
/** @brief Set speed and direction of right motor **/
63
void motor_r_set(int direction, int speed);
64
/** @brief Turn the motors off **/
65
void motors_off(void);
66

  
67
/**@}**/ // end addtogroup
68

  
69
#endif
70

  
include/libdragonfly/analog.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
27
 * 
28
 * @file analog.h
29
 * @brief Contains functions and definitions for using the ADC
30
 * 
31
 * Contains definitions and function prototypes for using the
32
 * ADC to detect analog signals on pins AN0 - AN7.
33
 * AN6 and AN7 are used for the wheel and battery.
34
	
35
 * The pins labeled E6 and E7 are external interrupt pins and are not related 
36
 * to analog.
37
	
38
 * @author Colony Project, CMU Robotics Club, based on firefly
39
 * originally taken from fwr analog file (author: Tom Lauwers)
40
 * loop code written by Kevin Woo and James Kong
41
 */
42

  
43
#ifndef _ANALOG_H
44
#define _ANALOG_H
45

  
46
#include <inttypes.h>
47

  
48
/**
49
 * @addtogroup analog
50
 * @{
51
 **/
52

  
53
/** @brief Analog port 0 **/
54
#define AN0 0x00
55
/** @brief Analog port 1 **/
56
#define AN1 0x01
57
/** @brief Analog port 2 **/
58
#define AN2 0x02
59
/** @brief Analog port 3 **/
60
#define AN3 0x03
61
/** @brief Analog port 4 **/
62
#define AN4 0x04
63
/** @brief Analog port 5 **/
64
#define AN5 0x05
65
/** @brief Analog port 6 **/
66
#define AN6 0x06
67
/** @brief Analog port 7 **/
68
#define AN7 0x07
69
/** @brief Analog port 8 **/
70
#define AN8 0x08
71
/** @brief Analog port 9 **/
72
#define AN9 0x09
73
/** @brief Analog port 10 **/
74
#define AN10 0x0A
75
/** @brief Analog port 11 **/
76
#define AN11 0x0B
77
/** @brief Analog port 12 **/
78
#define AN12 0x0C
79
/** @brief Analog port 13 **/
80
#define AN13 0x0D
81
/** @brief Analog port 14 **/
82
#define AN14 0x0E
83
/** @brief Analog port 15 **/
84
#define AN15 0x0F
85

  
86
/** @brief BOM_PORT analog port for BOM **/
87
#define BOM_PORT AN0
88
/** @brief EXT_MUX analog port **/
89
#define EXT_MUX AN7
90
/** @brief Analog port for the wheel **/
91
#define WHEEL_PORT AN10
92
/** @brief Analog port for the battery voltage detector **/
93
#define BATT_PORT  AN11
94

  
95
/** @brief Analog loop status. ADC conversion running. **/
96
#define ADC_LOOP_RUNNING 1
97
/** @brief Analog loop status.  No ADC conversion running.**/
98
#define ADC_LOOP_STOPPED 0
99

  
100
/** @brief Analog init parameter. Start the analog loop. **/
101
#define ADC_START 1
102
/** @brief Analog init parameter. Don't start the analog loop. **/
103
#define ADC_STOP  0
104

  
105
#define ADMUX_OPT 0x60
106

  
107
/** @brief Struct to hold the value of a particular analog port **/
108
typedef struct {
109
  uint8_t adc8;
110
  uint16_t adc10;
111
} adc_t;
112

  
113

  
114
/** @brief Initialize analog ports. Will start running a loop
115
    if start_conversion is ADC_START.**/
116
void analog_init(int start_conversion);
117
/** @brief starts the analog loop. Doesn't do anything if the loop is already running. **/
118
void analog_start_loop(void);
119
/** @brief Stops the analog loop. Doesn't do anything if the loop is already stopped. **/
120
void analog_stop_loop(void);
121
/** @brief Returns the status of the analog loop. **/
122
int analog_loop_status(void);
123
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog_get8. **/
124
unsigned int analog8(int which);
125
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog_get10. **/
126
unsigned int analog10(int which);
127
/** @brief Read the position of the wheel. **/
128
int wheel(void);
129
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/
130
unsigned int analog_get8(int which);
131
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/
132
unsigned int analog_get10(int which);
133

  
134

  
135
/**@}**/ //end group
136

  
137
#endif
138

  
include/libdragonfly/encoders.h
1
/**
2
 * 
3
 * @file encoders.h
4
 * @brief Contains functions for reading encoder values.
5
 *
6
 * Contains high and low level functions for reading encoders
7
 * including reading out total distance covered, and 
8
 * eventually velocity.
9
 *	
10
 * @author Colony Project, CMU Robotics Club
11
*/
12

  
13
/**
14
 * @addtogroup encoders
15
 * @{
16
 **/
17

  
18
#ifndef __ENCODERS_H__
19
#define __ENCODERS_H__
20

  
21

  
22
#ifndef LEFT
23
	/** @brief Left wheel **/
24
	#define LEFT 0
25
#endif
26
#ifndef RIGHT
27
	/** @brief Right wheel **/
28
	#define RIGHT 1
29
#endif
30

  
31
/** @brief Max value of valid encoder reading. **/
32
#define ENCODER_MAX 1024
33

  
34
/** @brief Magnet misaligned - likely distance from encoder problem. **/
35
#define ENCODER_MAGNET_FAILURE 1025
36
/** @brief Encoder misaligned - likely on XY plane. **/
37
#define ENCODER_MISALIGNED 1027
38
/** @brief Not enough time has passed - encoders not initialized in hardware. **/
39
#define ENCODER_DATA_NOT_READY 1026
40

  
41
/** @brief delay_ms argument after a full read is complete **/
42
#define ENCODER_DELAY 20
43

  
44
//Data invalid flags (hardware failure):
45
#define OCF _BV(4)
46
#define COF _BV(3)
47

  
48
//Data invalid alarm (May be invalid):
49
#define LIN _BV(2)
50

  
51
#define MagINCn _BV(1)
52
#define MagDECn _BV(0)
53

  
54
/** @brief Buffer size **/
55
#define BUFFER_SIZE 46
56

  
57
#define ERR_VEL 1024
58

  
59
/** @brief Initialize encoders. **/
60
void encoders_init(void);
61
/** @brief Read instantaneous encoder value. **/
62
int encoder_read(char encoder);
63

  
64
/** @brief Get total distance traveled.
65
 *  @note  Simply calls encoder_get_dx.
66
 **/
67
int encoder_get_x(char encoder);
68

  
69
/** @brief Get instantaneous velocity. **/
70
int encoder_get_v(char encoder);
71

  
72
/** @brief Get total distance traveled. **/
73
int encoder_get_dx(char encoder);
74
/** @brief Reset distance counter. **/
75
void encoder_rst_dx(char encoder);
76
/** @brief Get time count: The number of encoder reads that have occurred. **/
77
int encoder_get_tc(void);
78
/** @brief Reset the time count. **/
79
void encoder_rst_tc(void);
80

  
81
/** @brief Waits for the next n encoder reading, then returns. **/
82
void encoder_wait( int nReadings );
83

  
84
/**@}**/ //end group
85

  
86
#endif
include/libdragonfly/lcd.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26

  
27
/**
28
 * @file lcd.h
29
 * @brief Contains definitions for dealing with the LCD screen.
30
 * 
31
 * Contains definitions and functions for dealing with the 
32
 * LCD screen.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 **/
36

  
37
#ifndef _LCD_H_
38
#define _LCD_H_
39

  
40
/**
41
 * @addtogroup lcd
42
 * @{
43
 **/
44

  
45
/** @brief Initialize the LCD screen **/
46
void lcd_init(void);
47
/** @brief Clear the LCD screen **/
48
void lcd_clear_screen( void );
49
/** @brief Print a char to the LCD screen **/
50
void lcd_putc(char c);
51
/** @brief Print a string to the LCD screen **/
52
void lcd_puts(char *s);
53
/** @brief Print an int to the LCD screen **/
54
void lcd_puti(int value);
55
/** @brief Set the current cursor position **/
56
void lcd_gotoxy(int x, int y);
57

  
58
/** @} **/
59

  
60
#endif
61

  
include/libdragonfly/odometry.h
1

  
2
/**
3
 * @file odometry.h
4
 * @brief Code for estimating the robots pose.
5
 * 
6
 * Offers simple position and orientation information.
7
 *
8
 * @author Colony Project, CMU Robotics Club
9
 **/
10

  
11
#ifndef __ODOMETRY_C__
12
#define __ODOMETRY_C__
13

  
14
/**
15
 * @addtogroup odometry 
16
 * @{
17
 **/
18

  
19
//Odometry resolution, *64 microseconds.
20
#define ODOMETRY_CLK 255u 
21
#define TIME_SCALE 64
22

  
23
//Wheel = 2.613 in.  
24
//Circumference = 208.508133 mm
25
//Distance per encoder click (circumference / 1024)  = 203.621224 um.
26
//Robot width = 5.3745 in. = 136.5123 mm
27

  
28
#define ROBOT_WIDTH_UM 137000  //um
29
#define CLICK_DISTANCE_UM 204 //um
30

  
31
#define DISTANCE_SCALE 2.10526316 //Magic constant.
32
#define ANGLE_SCALE 1.12823207 //Magic constant.
33

  
34
/** @brief Retrieve the robots estimated x position*/
35
long odometry_dx(void);
36

  
37
/** @brief Retrieve the robots estimated y position*/
38
long odometry_dy(void);
39

  
40
/** @brief Retrieve the robots estimated orientation*/
41
double odometry_angle(void);
42

  
43
/** @brief Initialize odometry. MUST be called before 
44
 * the other functions work.**/
45
void odometry_init(void);
46

  
47
/** @brief Reset position and orientation to the origin facing
48
 * the x axis.*/
49
void odometry_reset(void);
50

  
51
/** @brief Report estimated velocity [mm/s].*/
52
long odometry_velocity(void);
53

  
54
/**@}**/ //end group
55

  
56
#endif
include/libdragonfly/move.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26

  
27
/**
28
 * @file move.h
29
 * @brief Contains definitions for controlling robot motion
30
 * 
31
 * This file offers higher-level functions for robot motion.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 **/
35

  
36
#ifndef _MOVE_H_
37
#define _MOVE_H_
38

  
39
/**
40
 * @addtogroup move
41
 * @{
42
 **/
43

  
44
/** @brief Move forwards **/
45
#define FWD 0
46
/** @brief Move backwards **/
47
#define BCK 1
48

  
49
/** @brief A slow speed **/
50
#define SLOW_SPD 96
51
/** @brief Half of the full speed **/
52
#define HALF_SPD 128
53
/** @brief A normal speed **/
54
#define NRML_SPD 160
55
/** @brief A fast speed **/
56
#define FAST_SPD 192
57
/** @brief The maximum speed **/
58
#define FULL_SPD 255
59

  
60
/** @brief A slow turning speed **/
61
#define SLOW_TURN 64
62
/** @brief A medium turning speed **/
63
#define NRML_TURN 96
64
/** @brief A high turning speed **/
65
#define FAST_TURN 128
66

  
67
/** @brief Move the robot at the specified velocity **/
68
void move(int velocity, int omega);
69
/** @brief Move the robot while avoiding obstacles **/
70
void move_avoid(int velocity, int omega, int strength);
71

  
72
/** @} **/
73

  
74
#endif
75

  
include/libdragonfly/battery.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26

  
27
/**
28
 * @file battery.h
29
 * @brief Definitions for checking battery voltage.
30
 * 
31
 * Contains definitions for checking the voltage of the 
32
 * battery.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 **/
36

  
37
#ifndef _BATTERY_H_
38
#define _BATTERY_H_
39

  
40
/**
41
 * @addtogroup battery
42
 * @{
43
 **/
44

  
45
/** @brief Normal battery voltage. (6 V) **/
46
#define BATTERY_NORMALV 154
47
/** @brief Charging battery voltage. (7 V) **/
48
#define BATTERY_CHARINGV 179
49
/** @brief Low battery voltage. ( < 6 V) **/
50
#define BATTERY_LOWV 152
51

  
52
/** @brief Read the battery voltage. **/
53
int battery8(void);
54
/** @brief Read the battery voltage in deciVolts. **/
55
int battery(void);
56
/** @brief Check if the battery is low. **/
57
char battery_low(void);
58
/** @brief Get an average battery voltage reading. **/
59
int battery8_avg(int n_samples);
60

  
61
/** @} **/ //end addtogroup
62

  
63
#endif
64

  
include/libdragonfly/dio.h
1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26

  
27
/**
28
 * @file dio.h
29
 * @brief Definitions for digital input / output
30
 *
31
 * This file contains definitions and functions for dealing
32
 * with digital input and output.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 * Based on Tom Lauwer's Firefly Library
36
 **/
37

  
38
#ifndef _DIO_H
39
#define _DIO_H
40

  
41
/*
42
  these are ALL the pins
43
  don't use unless you know what you're doing
44
*/
45

  
46
/*
47
  DIO pins on new dragonfly boards are shown below:
48
  -----------------------------------------------
49
  | _PIN_E6 | _PIN_E7 | _PIN_D2 | _PIN_D3 | VCC |
50
  -----------------------------------------------
51
  | _PIN_E2 | _PIN_E3 | _PIN_E4 | _PIN_E5 | GND |
52
  -----------------------------------------------
53
*/
54

  
55
/** @brief Port A **/
56
#define _PORT_A 1
57
/** @brief Port B **/
58
#define _PORT_B 2
59
/** @brief Port C **/
60
#define _PORT_C 3
61
/** @brief Port D **/
62
#define _PORT_D 4
63
/** @brief Port E **/
64
#define _PORT_E 5
65
/** @brief Port F **/
66
#define _PORT_F 6
67
/** @brief Port G **/
68
#define _PORT_G 7
69

  
70
/** @brief Pin A0 **/
71
#define _PIN_A0 8
72
/** @brief Pin A1 **/
73
#define _PIN_A1 9
74
/** @brief Pin A2 **/
75
#define _PIN_A2 10
76
/** @brief Pin A3 **/
77
#define _PIN_A3 11
78
/** @brief Pin A4 **/
79
#define _PIN_A4 12
80
/** @brief Pin A5 **/
81
#define _PIN_A5 13
82
/** @brief Pin A6 **/
83
#define _PIN_A6 14 
84
/** @brief Pin A7 **/
85
#define _PIN_A7 15
86

  
87
/** @brief Pin B0 **/
88
#define _PIN_B0 16
89
/** @brief Pin B1 **/
90
#define _PIN_B1 17
91
/** @brief Pin B2 **/
92
#define _PIN_B2 18
93
/** @brief Pin B3 **/
94
#define _PIN_B3 19
95
/** @brief Pin B4 **/
96
#define _PIN_B4 20
97
/** @brief Pin B5 **/
98
#define _PIN_B5 21
99
/** @brief Pin B6 **/
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff