Fawkes API  Fawkes Development Version
nao.h
1 
2 /***************************************************************************
3  * nao.h - V4L2 camera with Nao specific extensions
4  *
5  * Created: Sun Feb 01 13:56:23 2009
6  * Copyright 2008 Tobias Kellner
7  * 2009 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef __FIREVISION_CAMS_NAO_H_
26 #define __FIREVISION_CAMS_NAO_H_
27 
28 #include <fvcams/v4l2.h>
29 
30 #include <fvcams/control/source.h>
31 
32 #include <core/exceptions/software.h>
33 #include <unistd.h>
34 
35 #define DSPIC_I2C_ADDR 0x8
36 #define DSPIC_SWITCH_REG 220
37 #define I2C_SLAVE 0x0703
38 
39 namespace firevision {
40 #if 0 /* just to make Emacs auto-indent happy */
41 }
42 #endif
43 
44 class CameraArgumentParser;
45 
46 class NaoCamera :
47  public V4L2Camera,
48  public CameraControlSource
49 {
50  public:
51  NaoCamera(const CameraArgumentParser *cap);
52  virtual ~NaoCamera();
53 
54  virtual unsigned char source();
55  virtual void set_source(unsigned char source);
56  virtual bool exposure_auto();
57  virtual void set_exposure_auto(bool enabled);
58 
59  private:
60  static int open_dev(const char *i2c);
61  static void close_dev(int dev, const char *error = 0);
62  static int get_open_cam_id(int dev);
63  static void switch_to_cam_id(int dev, int cam_id);
64  static void init_cam(const char *cam);
65 
66  private:
67  char *__i2c_device_name; ///< I2C device file descriptor
68  int __cam_id; ///< ID of the Camera to be used
69  bool __can_switch_cam; ///< Needs to be Nao V3 for camera switching
70 };
71 
72 } // end namespace firevision
73 
74 #endif //__FIREVISION_CAMS_V4L2_H_
75 
virtual bool exposure_auto()
Return whether auto exposure is enabled.
Definition: nao.cpp:282
virtual void set_source(unsigned char source)
Switch currently used camera.
Definition: nao.cpp:264
Camera source control interface.
Definition: source.h:35
Video4Linux 2 camera access implementation.
Definition: v4l2.h:46
Video4Linux 2 camera with Nao-specific extensions.
Definition: nao.h:46
Camera argument parser.
Definition: camargp.h:38
virtual unsigned char source()
Return which cam is currently being used.
Definition: nao.cpp:248
NaoCamera(const CameraArgumentParser *cap)
Constructor.
Definition: nao.cpp:117
virtual void set_exposure_auto(bool enabled)
Enable/disable auto exposure.
Definition: nao.cpp:291