24 #ifndef _FIREVISION_CONTROL_VISCA_H_ 25 #define _FIREVISION_CONTROL_VISCA_H_ 27 #include <core/exception.h> 29 #ifdef TIMETRACKER_VISCA 30 # warning Visca time tracker enabled 31 # include <utils/timetracker.h> 38 namespace firevision {
65 void open(
const char *port);
74 void recv(
unsigned int max_wait_ms = 10);
75 void recv_ack(
unsigned int *socket = NULL);
94 void setPanTiltLimit(
int pan_left,
int pan_right,
int tilt_up,
int tilt_down);
99 void setZoom(
unsigned int zoom);
100 void getZoom(
unsigned int *zoom);
121 static const unsigned int VISCA_RUNINQ_NONE = 0;
122 static const unsigned int VISCA_RUNINQ_PANTILT = 1;
125 static const unsigned char VISCA_BUS_0 = 0;
126 static const unsigned char VISCA_BUS_1 = 1;
127 static const unsigned char VISCA_BUS_2 = 2;
128 static const unsigned char VISCA_BUS_3 = 3;
129 static const unsigned char VISCA_BUS_4 = 4;
130 static const unsigned char VISCA_BUS_5 = 5;
131 static const unsigned char VISCA_BUS_6 = 6;
132 static const unsigned char VISCA_BUS_7 = 7;
133 static const unsigned char VISCA_BUS_BROADCAST = 8;
136 static const unsigned char VISCA_COMMAND = 0x01;
137 static const unsigned char VISCA_CANCEL = 0x20;
138 static const unsigned char VISCA_INQUIRY = 0x09;
139 static const unsigned char VISCA_TERMINATOR = 0xFF;
142 static const unsigned char VISCA_RESPONSE_CLEAR = 0x40;
143 static const unsigned char VISCA_RESPONSE_ADDRESS = 0x30;
144 static const unsigned char VISCA_RESPONSE_ACK = 0x40;
145 static const unsigned char VISCA_RESPONSE_COMPLETED = 0x50;
146 static const unsigned char VISCA_RESPONSE_ERROR = 0x60;
149 static const unsigned char VISCA_ERROR_LENGTH = 0x01;
150 static const unsigned char VISCA_ERROR_SYNTAX = 0x02;
151 static const unsigned char VISCA_ERROR_BUFFERFULL = 0x03;
152 static const unsigned char VISCA_ERROR_CANCELLED = 0x04;
153 static const unsigned char VISCA_ERROR_NOSOCKET = 0x05;
154 static const unsigned char VISCA_ERROR_NOTEXECABLE = 0x41;
157 static const unsigned char VISCA_CATEGORY_INTERFACE = 0x00;
158 static const unsigned char VISCA_CATEGORY_CAMERA1 = 0x04;
159 static const unsigned char VISCA_CATEGORY_PAN_TILTER = 0x06;
160 static const unsigned char VISCA_CATEGORY_CAMERA2 = 0x07;
162 static const unsigned char VISCA_POWER = 0x00;
163 static const unsigned char VISCA_DEVICE_INFO = 0x02;
164 static const unsigned char VISCA_KEYLOCK = 0x17;
165 static const unsigned char VISCA_ID = 0x22;
166 static const unsigned char VISCA_ZOOM = 0x07;
167 static const unsigned char VISCA_ZOOM_STOP = 0x00;
168 static const unsigned char VISCA_ZOOM_TELE = 0x02;
169 static const unsigned char VISCA_ZOOM_WIDE = 0x03;
170 static const unsigned char VISCA_ZOOM_TELE_SPEED = 0x20;
171 static const unsigned char VISCA_ZOOM_WIDE_SPEED = 0x30;
172 static const unsigned char VISCA_ZOOM_VALUE = 0x47;
173 static const unsigned char VISCA_ZOOM_FOCUS_VALUE = 0x47;
174 static const unsigned char VISCA_DZOOM = 0x06;
175 static const unsigned char VISCA_DZOOM_ON = 0x02;
176 static const unsigned char VISCA_DZOOM_OFF = 0x03;
177 static const unsigned char VISCA_FOCUS = 0x08;
178 static const unsigned char VISCA_FOCUS_STOP = 0x00;
179 static const unsigned char VISCA_FOCUS_FAR = 0x02;
180 static const unsigned char VISCA_FOCUS_NEAR = 0x03;
181 static const unsigned char VISCA_FOCUS_FAR_SPEED = 0x20;
182 static const unsigned char VISCA_FOCUS_NEAR_SPEED = 0x30;
183 static const unsigned char VISCA_FOCUS_VALUE = 0x48;
184 static const unsigned char VISCA_FOCUS_AUTO = 0x38;
185 static const unsigned char VISCA_FOCUS_AUTO_MAN = 0x10;
186 static const unsigned char VISCA_FOCUS_ONE_PUSH = 0x18;
187 static const unsigned char VISCA_FOCUS_ONE_PUSH_TRIG = 0x01;
188 static const unsigned char VISCA_FOCUS_ONE_PUSH_INF = 0x02;
189 static const unsigned char VISCA_FOCUS_AUTO_SENSE = 0x58;
190 static const unsigned char VISCA_FOCUS_AUTO_SENSE_HIGH = 0x02;
191 static const unsigned char VISCA_FOCUS_AUTO_SENSE_LOW = 0x03;
192 static const unsigned char VISCA_FOCUS_NEAR_LIMIT = 0x28;
193 static const unsigned char VISCA_WB = 0x35;
194 static const unsigned char VISCA_WB_AUTO = 0x00;
195 static const unsigned char VISCA_WB_INDOOR = 0x01;
196 static const unsigned char VISCA_WB_OUTDOOR = 0x02;
197 static const unsigned char VISCA_WB_ONE_PUSH = 0x03;
198 static const unsigned char VISCA_WB_ATW = 0x04;
199 static const unsigned char VISCA_WB_MANUAL = 0x05;
200 static const unsigned char VISCA_WB_ONE_PUSH_TRIG = 0x05;
201 static const unsigned char VISCA_RGAIN = 0x03;
202 static const unsigned char VISCA_RGAIN_VALUE = 0x43;
203 static const unsigned char VISCA_BGAIN = 0x04;
204 static const unsigned char VISCA_BGAIN_VALUE = 0x44;
205 static const unsigned char VISCA_AUTO_EXP = 0x39;
206 static const unsigned char VISCA_AUTO_EXP_FULL_AUTO = 0x00;
207 static const unsigned char VISCA_AUTO_EXP_MANUAL = 0x03;
208 static const unsigned char VISCA_AUTO_EXP_SHUTTER_PRIORITY = 0x0A;
209 static const unsigned char VISCA_AUTO_EXP_IRIS_PRIORITY = 0x0B;
210 static const unsigned char VISCA_AUTO_EXP_GAIN_PRIORITY = 0x0C;
211 static const unsigned char VISCA_AUTO_EXP_BRIGHT = 0x0D;
212 static const unsigned char VISCA_AUTO_EXP_SHUTTER_AUTO = 0x1A;
213 static const unsigned char VISCA_AUTO_EXP_IRIS_AUTO = 0x1B;
214 static const unsigned char VISCA_AUTO_EXP_GAIN_AUTO = 0x1C;
215 static const unsigned char VISCA_SLOW_SHUTTER = 0x5A;
216 static const unsigned char VISCA_SLOW_SHUTTER_AUTO = 0x02;
217 static const unsigned char VISCA_SLOW_SHUTTER_MANUAL = 0x03;
218 static const unsigned char VISCA_SHUTTER = 0x0A;
219 static const unsigned char VISCA_SHUTTER_VALUE = 0x4A;
220 static const unsigned char VISCA_IRIS = 0x0B;
221 static const unsigned char VISCA_IRIS_VALUE = 0x4B;
222 static const unsigned char VISCA_GAIN = 0x0C;
223 static const unsigned char VISCA_GAIN_VALUE = 0x4C;
224 static const unsigned char VISCA_BRIGHT = 0x0D;
225 static const unsigned char VISCA_BRIGHT_VALUE = 0x4D;
226 static const unsigned char VISCA_EXP_COMP = 0x0E;
227 static const unsigned char VISCA_EXP_COMP_POWER = 0x3E;
228 static const unsigned char VISCA_EXP_COMP_VALUE = 0x4E;
229 static const unsigned char VISCA_BACKLIGHT_COMP = 0x33;
230 static const unsigned char VISCA_APERTURE = 0x02;
231 static const unsigned char VISCA_APERTURE_VALUE = 0x42;
232 static const unsigned char VISCA_ZERO_LUX = 0x01;
233 static const unsigned char VISCA_IR_LED = 0x31;
234 static const unsigned char VISCA_WIDE_MODE = 0x60;
235 static const unsigned char VISCA_WIDE_MODE_OFF = 0x00;
236 static const unsigned char VISCA_WIDE_MODE_CINEMA = 0x01;
237 static const unsigned char VISCA_WIDE_MODE_16_9 = 0x02;
238 static const unsigned char VISCA_MIRROR = 0x61;
239 static const unsigned char VISCA_FREEZE = 0x62;
240 static const unsigned char VISCA_PICTURE_EFFECT = 0x63;
241 static const unsigned char VISCA_PICTURE_EFFECT_OFF = 0x00;
242 static const unsigned char VISCA_PICTURE_EFFECT_PASTEL = 0x01;
243 static const unsigned char VISCA_PICTURE_EFFECT_NEGATIVE = 0x02;
244 static const unsigned char VISCA_PICTURE_EFFECT_SEPIA = 0x03;
245 static const unsigned char VISCA_PICTURE_EFFECT_BW = 0x04;
246 static const unsigned char VISCA_PICTURE_EFFECT_SOLARIZE = 0x05;
247 static const unsigned char VISCA_PICTURE_EFFECT_MOSAIC = 0x06;
248 static const unsigned char VISCA_PICTURE_EFFECT_SLIM = 0x07;
249 static const unsigned char VISCA_PICTURE_EFFECT_STRETCH = 0x08;
250 static const unsigned char VISCA_DIGITAL_EFFECT = 0x64;
251 static const unsigned char VISCA_DIGITAL_EFFECT_OFF = 0x00;
252 static const unsigned char VISCA_DIGITAL_EFFECT_STILL = 0x01;
253 static const unsigned char VISCA_DIGITAL_EFFECT_FLASH = 0x02;
254 static const unsigned char VISCA_DIGITAL_EFFECT_LUMI = 0x03;
255 static const unsigned char VISCA_DIGITAL_EFFECT_TRAIL = 0x04;
256 static const unsigned char VISCA_DIGITAL_EFFECT_LEVEL = 0x65;
257 static const unsigned char VISCA_MEMORY = 0x3F;
258 static const unsigned char VISCA_MEMORY_RESET = 0x00;
259 static const unsigned char VISCA_MEMORY_SET = 0x01;
260 static const unsigned char VISCA_MEMORY_RECALL = 0x02;
261 static const unsigned char VISCA_DISPLAY = 0x15;
262 static const unsigned char VISCA_DISPLAY_TOGGLE = 0x10;
263 static const unsigned char VISCA_DATE_TIME_SET = 0x70;
264 static const unsigned char VISCA_DATE_DISPLAY = 0x71;
265 static const unsigned char VISCA_TIME_DISPLAY = 0x72;
266 static const unsigned char VISCA_TITLE_DISPLAY = 0x74;
267 static const unsigned char VISCA_TITLE_DISPLAY_CLEAR = 0x00;
268 static const unsigned char VISCA_TITLE_SET = 0x73;
269 static const unsigned char VISCA_TITLE_SET_PARAMS = 0x00;
270 static const unsigned char VISCA_TITLE_SET_PART1 = 0x01;
271 static const unsigned char VISCA_TITLE_SET_PART2 = 0x02;
272 static const unsigned char VISCA_IRRECEIVE = 0x08;
273 static const unsigned char VISCA_IRRECEIVE_ON = 0x02;
274 static const unsigned char VISCA_IRRECEIVE_OFF = 0x03;
275 static const unsigned char VISCA_IRRECEIVE_ONOFF = 0x10;
276 static const unsigned char VISCA_PT_DRIVE = 0x01;
277 static const unsigned char VISCA_PT_DRIVE_HORIZ_LEFT = 0x01;
278 static const unsigned char VISCA_PT_DRIVE_HORIZ_RIGHT = 0x02;
279 static const unsigned char VISCA_PT_DRIVE_HORIZ_STOP = 0x03;
280 static const unsigned char VISCA_PT_DRIVE_VERT_UP = 0x01;
281 static const unsigned char VISCA_PT_DRIVE_VERT_DOWN = 0x02;
282 static const unsigned char VISCA_PT_DRIVE_VERT_STOP = 0x03;
283 static const unsigned char VISCA_PT_ABSOLUTE_POSITION = 0x02;
284 static const unsigned char VISCA_PT_RELATIVE_POSITION = 0x03;
285 static const unsigned char VISCA_PT_HOME = 0x04;
286 static const unsigned char VISCA_PT_RESET = 0x05;
287 static const unsigned char VISCA_PT_LIMITSET = 0x07;
288 static const unsigned char VISCA_PT_LIMITSET_SET = 0x00;
289 static const unsigned char VISCA_PT_LIMITSET_CLEAR = 0x01;
290 static const unsigned char VISCA_PT_LIMITSET_SET_UR = 0x01;
291 static const unsigned char VISCA_PT_LIMITSET_SET_DL = 0x00;
292 static const unsigned char VISCA_PT_DATASCREEN = 0x06;
293 static const unsigned char VISCA_PT_DATASCREEN_ON = 0x02;
294 static const unsigned char VISCA_PT_DATASCREEN_OFF = 0x03;
295 static const unsigned char VISCA_PT_DATASCREEN_ONOFF = 0x10;
296 static const unsigned char VISCA_PT_VIDEOSYSTEM_INQ = 0x23;
297 static const unsigned char VISCA_PT_MODE_INQ = 0x10;
298 static const unsigned char VISCA_PT_MAXSPEED_INQ = 0x11;
299 static const unsigned char VISCA_PT_POSITION_INQ = 0x12;
300 static const unsigned char VISCA_PT_DATASCREEN_INQ = 0x06;
304 static const unsigned char VISCA_WIDE_CON_LENS = 0x26;
305 static const unsigned char VISCA_WIDE_CON_LENS_SET = 0x00;
307 static const unsigned char VISCA_AT_MODE = 0x01;
308 static const unsigned char VISCA_AT_ONOFF = 0x10;
309 static const unsigned char VISCA_AT_AE = 0x02;
310 static const unsigned char VISCA_AT_AUTOZOOM = 0x03;
311 static const unsigned char VISCA_ATMD_FRAMEDISPLAY = 0x04;
312 static const unsigned char VISCA_AT_FRAMEOFFSET = 0x05;
313 static const unsigned char VISCA_ATMD_STARTSTOP = 0x06;
314 static const unsigned char VISCA_AT_CHASE = 0x07;
315 static const unsigned char VISCA_AT_CHASE_NEXT = 0x10;
317 static const unsigned char VISCA_MD_MODE = 0x08;
318 static const unsigned char VISCA_MD_ONOFF = 0x10;
319 static const unsigned char VISCA_MD_FRAME = 0x09;
320 static const unsigned char VISCA_MD_DETECT = 0x0A;
322 static const unsigned char VISCA_MD_ADJUST = 0x00;
323 static const unsigned char VISCA_MD_ADJUST_YLEVEL = 0x0B;
324 static const unsigned char VISCA_MD_ADJUST_HUELEVEL = 0x0C;
325 static const unsigned char VISCA_MD_ADJUST_SIZE = 0x0D;
326 static const unsigned char VISCA_MD_ADJUST_DISPTIME = 0x0F;
327 static const unsigned char VISCA_MD_ADJUST_REFTIME = 0x0B;
328 static const unsigned char VISCA_MD_ADJUST_REFMODE = 0x10;
330 static const unsigned char VISCA_AT_ENTRY = 0x15;
331 static const unsigned char VISCA_AT_LOSTINFO = 0x20;
332 static const unsigned char VISCA_MD_LOSTINFO = 0x21;
333 static const unsigned char VISCA_ATMD_LOSTINFO1 = 0x20;
334 static const unsigned char VISCA_ATMD_LOSTINFO2 = 0x07;
336 static const unsigned char VISCA_MD_MEASURE_MODE_1 = 0x27;
337 static const unsigned char VISCA_MD_MEASURE_MODE_2 = 0x28;
339 static const unsigned char VISCA_ATMD_MODE = 0x22;
340 static const unsigned char VISCA_AT_MODE_QUERY = 0x23;
341 static const unsigned char VISCA_MD_MODE_QUERY = 0x24;
342 static const unsigned char VISCA_MD_REFTIME_QUERY = 0x11;
343 static const unsigned char VISCA_AT_POSITION = 0x20;
344 static const unsigned char VISCA_MD_POSITION = 0x21;
346 static const unsigned int VISCA_NONBLOCKING_PANTILT = 0;
347 static const unsigned int VISCA_NONBLOCKING_ZOOM = 1;
348 static const unsigned int VISCA_NONBLOCKING_NUM = 2;
350 void recv_packet(
unsigned int max_wait_ms = 10);
351 void handle_response();
352 void finish_nonblocking(
unsigned int socket);
357 unsigned int inquire;
360 unsigned char recipient;
361 unsigned char sender;
363 unsigned char obuffer[16];
364 unsigned char ibuffer[1024];
368 unsigned int num_commands_running;
370 bool nonblocking_running[2];
371 unsigned int nonblocking_sockets[2];
372 #ifdef TIMETRACKER_VISCA 374 std::ofstream track_file;
375 unsigned int ttcls_pantilt_get_send;
376 unsigned int ttcls_pantilt_get_read;
377 unsigned int ttcls_pantilt_get_handle;
378 unsigned int ttcls_pantilt_get_interpret;
static const unsigned int VISCA_WHITEBALANCE_OUTDOOR
Outdoor white balance preset.
bool data_available()
Check data availability.
static const unsigned int VISCA_WHITEBALANCE_ATW
ATW white balance preset.
void resetPanTiltLimit()
Reset pan/tilt limit.
void applyEffectStretch()
Apply stretch effect.
void setPanTilt(int pan, int tilt)
Set pan tilt.
static const unsigned int VISCA_WHITEBALANCE_ONE_PUSH
One push white balance preset.
void applyEffectMosaic()
Apply mosaic effect.
void send_with_reply()
Send and wait for reply, blocking.
ViscaControlException(const char *msg)
Constructor.
void set_address(unsigned int num_cameras)
Set addresses of cameras.
Visca inquire running exception.
ViscaControl(bool blocking=true)
Constructor.
void applyEffectPastel()
Apply pastel effect.
int _errno
Error number, should be used if the error was caused by a method that supplies errno.
void applyEffectSolarize()
Apply solarize effect.
void getZoom(unsigned int *zoom)
Get zoom.
unsigned int getWhiteBalanceMode()
Get white balance mode.
void applyEffectSlim()
Apply slim effect.
void send()
Send outbound queue.
Visca control protocol implementation over a serial line.
void resetZoom()
Reset zoom.
void setPanTiltLimit(int pan_left, int pan_right, int tilt_up, int tilt_down)
Set pan tilt limit.
void startGetPanTilt()
Query for pan/tilt but do not wait until finished This will send an inquire to the camera that asks f...
void setZoomSpeedTele(unsigned int speed)
Set zoom speed in tele.
void resetEffect()
Reset effects.
Base class for exceptions in Fawkes.
void setZoomSpeedWide(unsigned int speed)
Set zoom speed in wide angle.
static const unsigned int VISCA_WHITEBALANCE_INDOOR
Indoor white balance preset.
void recv_ack(unsigned int *socket=NULL)
Receive ACK packet.
void open(const char *port)
Open serial port.
void resetPanTilt()
Reset pan/tilt.
void applyEffectBnW()
Apply B/W effect.
ViscaControlInquiryRunningException()
Constructor.
void setZoomDigitalEnabled(bool enabled)
Enable or disable digital zoome.
void process()
Process incoming data.
void setZoom(unsigned int zoom)
Set zoom.
void recv(unsigned int max_wait_ms=10)
Receive data.
void applyEffectSepia()
Apply sepia effect.
void getPanTilt(int *pan, int *tilt)
Get pan and tilt values.
void cancel_command(unsigned int socket)
Cancel a running command.
void send_nonblocking(unsigned int *socket=NULL)
Send non-blocking.
static const unsigned int VISCA_WHITEBLANCE_AUTO
Automatic white balance.
static const unsigned int VISCA_WHITEBALANCE_MANUAL
Manual white balance.
void applyEffect(unsigned char effect)
Apply effect.
void applyEffectNegArt()
Apply negative art effect.