Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
openinterface.h
Go to the documentation of this file.
1 
12 #ifndef __OPENINTERFACE_H
13 #define __OPENINTERFACE_H
14 
15 /* -- Includes -- */
16 #include "serialport.h"
17 
18 /* -- Types -- */
19 
24 {
25  // ID: 7
26  unsigned char wheeldrop_bump;
27  // ID: 8
28  unsigned char wall;
29  // ID: 9
30  unsigned char cliff_left;
31  // ID: 10
32  unsigned char cliff_front_left;
33  // ID: 11
34  unsigned char cliff_front_right;
35  // ID: 12
36  unsigned char cliff_right;
37  // ID: 13
38  unsigned char virtual_wall;
39  // ID: 14
40  unsigned char overcurrent;
41  // ID: 15 UNUSED
42  // ID: 16 UNUSED
43  // ID: 17
44  unsigned char infrared;
45  // ID: 18
46  unsigned char buttons;
47  // ID: 19
48  int distance;
49  // ID: 20
50  int angle;
51  // ID: 21
52  unsigned char charging_state;
53  // ID: 22
54  unsigned int voltage;
55  // ID: 23
56  int current;
57  // ID: 24
59  // ID: 25
60  unsigned int battery_charge;
61  // ID: 26
62  unsigned int battery_capacity;
63  // ID: 27
64  unsigned int wall_signal;
65  // ID: 28
66  unsigned int cliff_left_signal;
67  // ID: 29
69  // ID: 30
71  // ID: 31
72  unsigned int cliff_right_signal;
73  // ID: 32
74  unsigned char cargo_bay_digital_inputs;
75  // ID: 33
77  // ID: 34
79  // ID: 35
80  unsigned char io_mode;
81  // ID: 36
82  unsigned char song_number;
83  // ID: 37
84  unsigned char song_playing;
85  // ID: 38
86  unsigned char stream_packets_number;
87  // ID: 39
89  // ID: 40
91  // ID: 41
93  // ID: 42
95 
97 
102 {
103  serialport_t *sps; // Pointer to serial port structure
104  openinterface_sensor_t *oiss; // Pointer to Open Interface sensor structure
105 
107 
108 /* -- Constants -- */
109 
110 // Commands
111 #define s_OI_CMD_START 0x80
112 #define s_OI_CMD_MODE_SAFE 0x83
113 #define s_OI_CMD_MODE_FULL 0x84
114 #define s_OI_CMD_MODE_PASSIVE 0x80
115 #define s_OI_CMD_DRIVE 0x89
116 #define s_OI_CMD_DRIVE_DIRECT 0x91
117 #define s_OI_CMD_LEDS 0x8B
118 #define s_OI_CMD_DIGITAL_OUTPUTS 0x93
119 #define s_OI_CMD_PWM_LSD 0x90
120 #define s_OI_CMD_LSD 0x8A
121 #define s_OI_CMD_SEND_IR 0x97
122 #define s_OI_CMD_SONG 0x8C
123 #define s_OI_CMD_PLAY_SONG 0x8D
124 #define s_OI_CMD_SENSORS 0x8E
125 #define s_OI_CMD_QUERY_LIST 0x95
126 #define s_OI_CMD_STREAM 0x94
127 #define s_OI_CMD_PAUSE_RESUME_STREAM 0x96
128 #define s_OI_CMD_SCRIPT 0x98
129 #define s_OI_CMD_PLAY_SCRIPT 0x99
130 #define s_OI_CMD_SHOW_SCRIPT 0x9A
131 #define s_OI_CMD_WAIT_TIME 0x9B
132 #define s_OI_CMD_WAIT_DIST 0x9C
133 #define s_OI_CMD_WAIT_ANGLE 0x9D
134 #define s_OI_CMD_WAIT_EVENT 0x9E
135 
136 // Sensor packet ID
137 #define s_OI_SENSOR_PACKET_0 0 // Fisrt half of the sensors
138 #define s_OI_SENSOR_PACKET_1 1 // 1st block of sensors
139 #define s_OI_SENSOR_PACKET_2 2 // 2nd block of sensors
140 #define s_OI_SENSOR_PACKET_3 3 // 3rd block of sensors
141 #define s_OI_SENSOR_PACKET_4 4 // 4th block of sensors
142 #define s_OI_SENSOR_PACKET_5 5 // 5th block of sensors
143 #define s_OI_SENSOR_PACKET_6 6 // All sensors
144 
145 // Sensor packet size (See iRobot Create OpenInterface PDF)
146 #define s_OI_SENSOR_PACKET_0_SIZE 26 // Fisrt half of the sensors
147 #define s_OI_SENSOR_PACKET_1_SIZE 10 // 1st block of sensors
148 #define s_OI_SENSOR_PACKET_2_SIZE 6 // 2nd block of sensors
149 #define s_OI_SENSOR_PACKET_3_SIZE 10 // 3rd block of sensors
150 #define s_OI_SENSOR_PACKET_4_SIZE 14 // 4th block of sensors
151 #define s_OI_SENSOR_PACKET_5_SIZE 12 // 5th block of sensors
152 #define s_OI_SENSOR_PACKET_6_SIZE 52 // All sensors
153 
154 /* -- Function Prototypes -- */
155 // Communication
156 openinterface_t *openinterface_open(char *device_path); // Open OpenInterface connection
157 int openinterface_close(openinterface_t *ois); // Close OpenInteface connection
158 
159 // Comands
160 int openinterface_start(openinterface_t *ois); // Start OI
161 int openinterface_full(openinterface_t *ois); // Enable full control of OI
162 
163 //??
164 int openinterface_drive(openinterface_t *ois, int velocity, int radius); // Sends drive command
165 int openinterface_drive_direct(openinterface_t *ois, int right, int left); // Sends Direct Drive Command
166 int openinterface_sensor_get(openinterface_t *ois, const unsigned char id, const unsigned char len, unsigned char *data); // Get one sensor request readings
167 int openinterface_sensors_update(openinterface_t *ois, const unsigned int sensor_id, const unsigned int size); // Update one sensor packet
168 int openinterface_distance_get(openinterface_t *ois); // Get travelled distance
169 int openinterface_angle_get(openinterface_t *ois); // Get change of angle
170 
172  int play,
173  int advance,
174  unsigned char power_color,
175  unsigned char power_intensity); // Control LEDs
176 
177 #endif /* __OPENINTERFACE_H */
int openinterface_close(openinterface_t *ois)
Definition: openinterface.c:63
unsigned char charging_source_available
Definition: openinterface.h:78
unsigned char cargo_bay_digital_inputs
Definition: openinterface.h:74
unsigned char stream_packets_number
Definition: openinterface.h:86
openinterface_sensor_t * oiss
unsigned int cargo_bay_analog_signal
Definition: openinterface.h:76
Open Interface structure.
openinterface_t * openinterface_open(char *device_path)
Definition: openinterface.c:35
struct s_OPENINTERFACE_STRUCT openinterface_t
Open Interface structure.
Serial Port structure.
Definition: serialport.h:23
unsigned int cliff_front_left_signal
Definition: openinterface.h:68
int openinterface_sensor_get(openinterface_t *ois, const unsigned char id, const unsigned char len, unsigned char *data)
int openinterface_start(openinterface_t *ois)
Definition: openinterface.c:89
Open Interface Sensor structure.
Definition: openinterface.h:23
int openinterface_LEDs(openinterface_t *ois, int play, int advance, unsigned char power_color, unsigned char power_intensity)
int openinterface_angle_get(openinterface_t *ois)
int openinterface_drive(openinterface_t *ois, int velocity, int radius)
int openinterface_sensors_update(openinterface_t *ois, const unsigned int sensor_id, const unsigned int size)
unsigned int cliff_front_right_signal
Definition: openinterface.h:70
struct s_OPENINTERFACE_SENSOR_STRUCT openinterface_sensor_t
Open Interface Sensor structure.
int openinterface_full(openinterface_t *ois)
int openinterface_drive_direct(openinterface_t *ois, int right, int left)
int openinterface_distance_get(openinterface_t *ois)