00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef CServoeNeck_H 00030 #define CServoeNeck_H 00031 00032 #include <mrpt/utils/utils_defs.h> 00033 #include <mrpt/hwdrivers/link_pragmas.h> 00034 #include <mrpt/hwdrivers/CInterfaceFTDIMessages.h> 00035 00036 namespace mrpt 00037 { 00038 namespace hwdrivers 00039 { 00040 class HWDLLIMPEXP CServoeNeck : public hwdrivers::CInterfaceFTDIMessages 00041 { 00042 public: 00043 CServoeNeck(); 00044 ~CServoeNeck(); 00045 00046 /** Gets the firmware version of the eNeck board. 00047 * \param out_firmwareVersion: [OUTPUT] A string containing the firmware version. 00048 * \return Whether or not the procedure succeded. 00049 */ 00050 bool queryFirmwareVersion( std::string &out_firmwareVersion ); 00051 00052 /** Gets the current angle of the servo (in radians within (-pi,pi)) 00053 * \param Angle: [OUT] The current angle. 00054 * \param Servo: [IN] The id of the servo (in our ATMEGA16, from 0 to 2). 00055 * \return Whether or not the procedure succeded. 00056 */ 00057 bool getCurrentAngle( double &angle, const uint8_t servo = 0 ); 00058 00059 /** Turns the servo up to the specified angle (in radians in the range -pi,pi, other values will be saturated to the maximum or the mininum) 00060 * \param Angle: the desired angle to turn. 00061 * \param Servo: the id of the servo to move (in our ATMEGA16, from 0 to 2). 00062 * \return Whether or not the procedure succeded. 00063 */ 00064 bool setAngle( double angle, const uint8_t servo = 0 ); 00065 00066 /** Disables the servo so the neck will be loose. 00067 * \param Servo: the id of the servo to move (in our ATMEGA16, from 0 to 2). 00068 * \return Whether or not the procedure succeded. 00069 */ 00070 bool disableServo( const uint8_t servo = 0 ); 00071 00072 /** Enables the servo so the neck will be tight. 00073 * \param Servo: the id of the servo to move (in our ATMEGA16, from 0 to 2). 00074 * \return Whether or not the procedure succeded. 00075 */ 00076 bool enableServo( const uint8_t servo = 0 ); 00077 00078 /** Centers the servo at zero position 00079 */ 00080 bool center( const uint8_t servo = 0 ); 00081 00082 protected: 00083 std::string m_usbSerialNumber; //!< A copy of the device serial number (to open the USB FTDI chip). 00084 00085 bool setRegisterValue( const uint16_t value, const uint8_t servo = 0 ); 00086 bool getRegisterValue( uint16_t &value, const uint8_t servo = 0 ); 00087 00088 private: 00089 /** Converts from a decimal angle (in radians) to the corresponding register value for the ATMEGA16 controller (for inner use only). 00090 * \param The angle to convert. 00091 * \return The value of the register to send. 00092 */ 00093 unsigned int angle2RegValue( const double angle ); // Angle in rad 00094 00095 /** Converts from a certain value of the ATMEGA16 PWM register to the corresponding decimal angle (for inner use only). 00096 * \param The value to convert. 00097 * \return The corresponding angle. 00098 */ 00099 double regValue2angle( const uint16_t value ); 00100 00101 /** Tries to connect to the USB device (if disconnected). 00102 * \return True on connection OK, false on error. 00103 */ 00104 bool checkConnectionAndConnect(); 00105 00106 }; // End of class 00107 00108 } // End of namespace 00109 00110 } // End of namespace 00111 00112 #endif
| Page generated by Doxygen 1.6.2 for MRPT 0.8.1 SVN:exported at Mon Feb 15 22:01:07 UTC 2010 |
