25 CServoeNeck::CServoeNeck() :
26 m_usbSerialNumber(
"eNeck001"),
28 m_TruncateFactor(0.5),
200 if ( msgRx.
content.size() != 2 )
255 std::cout <<
"Angle: " <<
RAD2DEG( angle ) <<
" - Reg: " << reg << std::endl;
270 uint8_t thisSpeed = speed < 15 ? 15 : speed > 250 ? 250 : speed;
271 uint16_t delSpeed =
uint16_t(0.25*1000000/(500+1000*(thisSpeed/180.0f-0.5)));
294 return (
setAngle( nangle, servo, fast ) );
void SetTimeouts(unsigned long dwReadTimeout_ms, unsigned long dwWriteTimeout_ms)
Change read & write timeouts, in milliseconds.
unsigned int angle2RegValue(const double angle)
Converts from a decimal angle (in radians) to the corresponding register value for the ATMEGA16 contr...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
unsigned __int16 uint16_t
bool setRegisterValueAndSpeed(const uint16_t value, const uint8_t servo, const uint16_t speed)
bool setAngle(double angle, const uint8_t servo=0, bool fast=false)
Turns the servo up to the specified angle (in radians in the range -pi,pi, other values will be satur...
bool checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
bool queryFirmwareVersion(std::string &out_firmwareVersion)
Gets the firmware version of the eNeck board.
void OpenBySerialNumber(const std::string &serialNumber)
Open by device serial number.
bool isOpen()
Checks whether the chip has been successfully open.
Contains classes for various device interfaces.
unsigned int m_NumPrevAngles
Number of previous angles to store for averaging.
bool center(const uint8_t servo=0)
Centers the servo at zero position.
bool setAngleWithFilter(double angle, const uint8_t servo=0, bool fast=false)
Turns the servo up to the specified angle (in radians in the range -pi,pi) filtered by average with t...
std::vector< float > m_offsets
The offset used for each servo.
void Purge()
Purge the I/O buffers.
This base provides a set of functions for maths stuff.
bool getCurrentAngle(double &angle, const uint8_t servo=0)
Gets the current angle of the servo (in radians within (-pi,pi))
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
bool disableServo(const uint8_t servo=0)
Disables the servo so the neck will be loose.
bool enableServo(const uint8_t servo=0)
Enables the servo so the neck will be tight.
GLsizei const GLchar ** string
void setOffsets(float offset0, float offset1, float offset2)
Load the Offset values for each servo.
void getContentAsString(std::string &str)
Gets the contents of the message as a string.
bool receiveMessage(utils::CMessage &msg)
Tries to receive a message from the device.
void SetLatencyTimer(unsigned char latency_ms)
Change the latency timer (in milliseconds) implemented on the FTDI chip: for a few ms...
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip).
void sendMessage(const utils::CMessage &msg)
Send a message to the device.
bool getRegisterValue(uint16_t &value, const uint8_t servo=0)
std::vector< uint8_t > content
The contents of the message (memory is automatically handled by the std::vector object) ...
double m_TruncateFactor
The range of turn of the servo will be truncated to "+-m_truncate_factor*(pi/2)". ...
GLsizei const GLfloat * value
bool setAngleAndSpeed(double angle, const uint8_t servo, const uint8_t speed)
Turns the servo up to the specified angle (in radians in the range -pi,pi, other values will be satur...
std::deque< double > m_PrevAngles
A vector containing the last N angles which where passed to the servo (for averaging) ...
double regValue2angle(const uint16_t value)
Converts from a certain value of the ATMEGA16 PWM register to the corresponding decimal angle (for in...
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
uint32_t type
An identifier of the message type (only the least-sig byte is typically sent)
bool setRegisterValue(const uint16_t value, const uint8_t servo=0, bool fast=false)
void Close()
Close the USB device.