class mrpt::hwdrivers::CServoeNeck

Overview

A USB-interface for a custom “robotic neck” designed at MAPIR lab.

#include <mrpt/hwdrivers/CServoeNeck.h>

class CServoeNeck: public mrpt::comms::CInterfaceFTDI
{
public:
    // construction

    CServoeNeck();

    // methods

    bool queryFirmwareVersion(std::string& out_firmwareVersion);
    bool getCurrentAngle(double& angle, const uint8_t servo = 0);
    bool setAngle(double angle, const uint8_t servo = 0, bool fast = false);
    bool setAngleAndSpeed(double angle, const uint8_t servo, const uint8_t speed);
    bool setAngleWithFilter(double angle, const uint8_t servo = 0, bool fast = false);
    bool disableServo(const uint8_t servo = 0);
    bool enableServo(const uint8_t servo = 0);
    bool center(const uint8_t servo = 0);
    double getTruncateFactor();
    void setTruncateFactor(const double factor);
    void setNumberOfPreviousAngles(const unsigned int number);
    unsigned int getNumberOfPreviousAngles();
    void setOffsets(float offset0, float offset1, float offset2);
};

Inherited Members

public:
    // methods

    virtual size_t Read(void* Buffer, size_t Count) = 0;
    virtual size_t Write(const void* Buffer, size_t Count) = 0;
    virtual uint64_t getTotalBytesCount() const = 0;
    virtual uint64_t getPosition() const = 0;
    CInterfaceFTDI& operator = (const CInterfaceFTDI& o);

Methods

bool queryFirmwareVersion(std::string& out_firmwareVersion)

Gets the firmware version of the eNeck board.

Parameters:

out_firmwareVersion

[OUTPUT] A string containing the firmware version.

Returns:

Whether or not the procedure succeded.

bool getCurrentAngle(double& angle, const uint8_t servo = 0)

Gets the current angle of the servo (in radians within (-pi,pi))

Parameters:

Angle

[OUT] The current angle.

Servo

[IN] The id of the servo (in our ATMEGA16, from 0 to 2).

Returns:

Whether or not the procedure succeded.

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 saturated to the maximum or the mininum)

Parameters:

Angle

the desired angle to turn.

Servo

the id of the servo to move (in our ATMEGA16, from 0 to 2).

Fast

indicates if the servo must reach the angle at maximum speed

Returns:

Whether or not the procedure succeded.

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 saturated to the maximum or the mininum)

Parameters:

Angle

the desired angle to turn.

Servo

the id of the servo to move (in our ATMEGA16, from 0 to 2).

Speed

indicates the speed of the servo

Returns:

Whether or not the procedure succeded.

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 the last N specified angles.

Parameters:

Angle

the new desired angle to turn.

Servo

the id of the servo to move (in our ATMEGA16, from 0 to 2).

Fast

indicates if the servo must reach the angle at maximum speed

Returns:

Whether or not the procedure succeded.

bool disableServo(const uint8_t servo = 0)

Disables the servo so the neck will be loose.

Parameters:

Servo

the id of the servo to move (in our ATMEGA16, from 0 to 2).

Returns:

Whether or not the procedure succeded.

bool enableServo(const uint8_t servo = 0)

Enables the servo so the neck will be tight.

Parameters:

Servo

the id of the servo to move (in our ATMEGA16, from 0 to 2).

Returns:

Whether or not the procedure succeded.

bool center(const uint8_t servo = 0)

Centers the servo at zero position.

double getTruncateFactor()

Gets the truncate factor of the turn.

void setTruncateFactor(const double factor)

Gets the truncate factor of the turn.

void setNumberOfPreviousAngles(const unsigned int number)

Gets the truncate factor of the turn.

unsigned int getNumberOfPreviousAngles()

Gets the truncate factor of the turn.

void setOffsets(float offset0, float offset1, float offset2)

Load the Offset values for each servo.