ANYdrive SDK
The SDK for interfacing ANYdrive.
anydrive_ros::AnydriveRos Class Reference

#include <AnydriveRos.hpp>

Inheritance diagram for anydrive_ros::AnydriveRos:
Inheritance graph

Public Member Functions

 AnydriveRos (ros::NodeHandle &nh, const unsigned int maxPublishMessageBufferSize)
 
virtual ~AnydriveRos ()
 
anydrive_msgs::Reading getReadingMsg ()
 
anydrive_msgs::ReadingExtended getReadingExtendedMsg ()
 
void startupWithoutCommunication () override
 
void updateProcessReading () override
 
void shutdownWithoutCommunication () override
 
void sendRos ()
 
- Public Member Functions inherited from anydrive::Anydrive
 Anydrive ()
 
virtual ~Anydrive ()=default
 
bool loadSetup (const setup::AnydrivePtr &setup)
 
std::string getName () const
 
configuration::ConfigurationgetConfiguration ()
 
const configuration::ConfigurationgetConfiguration () const
 
void setCommunicationInterface (const communication::CommunicationInterfaceBasePtr &communicationInterface)
 
const communication::CommunicationInterfaceBasePtrgetCommunicationInterface () const
 
void addReadingCb (const ReadingCb &readingCb, const int priority=0)
 
void addErrorCb (const ErrorCb &errorCb, const int priority=0)
 
void addErrorRecoveredCb (const ErrorRecoveredCb &errorRecoveredCb, const int priority=0)
 
void addFatalCb (const FatalCb &fatalCb, const int priority=0)
 
void addFatalRecoveredCb (const FatalRecoveredCb &fatalRecoveredCb, const int priority=0)
 
void addDeviceDisconnectedCb (const DeviceDisconnectedCb &deviceDisconnectedCb, const int priority=0)
 
void addDeviceReconnectedCb (const DeviceReconnectedCb &deviceReconnectedCb, const int priority=0)
 
virtual void startupWithCommunication ()
 
virtual void updateSendStagedCommand ()
 
virtual void shutdownWithCommunication ()
 
fsm::StateEnum getActiveStateEnum () const
 
fsm::StateEnum getGoalStateEnum () const
 
bool goalStateHasBeenReached () const
 
bool setGoalStateEnum (const fsm::StateEnum goalStateEnum, const bool reachState=false, const double timeout=5.0, const double checkingFrequency=100.0)
 
void clearGoalStateEnum ()
 
void errorCb ()
 
void errorRecoveredCb ()
 
bool deviceIsInErrorState ()
 
void fatalCb ()
 
void fatalRecoveredCb ()
 
bool deviceIsInFatalState ()
 
void deviceDisconnectedCb ()
 
void deviceReconnectedCb ()
 
bool deviceIsMissing () const
 
bool isWithinJointPositionLimitsSdk () const
 
bool isWithinJointPositionLimitsSoft () const
 
bool isWithinJointPositionLimitsHard () const
 
template<typename Value >
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, Value &value)
 
bool sendSdoReadGeneric (const std::string &indexString, const std::string &subindexString, const std::string &valueTypeString, std::string &valueString)
 
template<typename Value >
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const Value value)
 
bool sendSdoWriteGeneric (const std::string &indexString, const std::string &subindexString, const std::string &valueTypeString, const std::string &valueString)
 
bool getDriveInfo (DriveInfo &driveInfo) const
 
bool getDriveInfoSerialNumber (std::string &serialNumber) const
 
bool setDriveInfoSerialNumber (const std::string &serialNumber)
 
bool getDriveInfoName (std::string &name) const
 
bool setDriveInfoName (const std::string &name)
 
bool getDriveInfoId (uint16_t &id) const
 
bool setDriveInfoId (const uint16_t id)
 
bool getDriveInfoBootloaderVersion (common::Version &bootloaderVersion) const
 
bool setDriveInfoBootloaderVersion (const common::Version &bootloaderVersion)
 
bool getDriveInfoFirmwareVersion (common::Version &firmwareVersion) const
 
bool getDriveFirmwareInfo (common::FirmwareInfo &firmwareInfo)
 
bool getGearboxRatio (uint32_t &ratio)
 
bool eraseFlashStorage ()
 
bool resetFlashStorageSections (const uint8_t flashStorageSections)
 
bool getCalibrationState (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::CalibrationState &calibrationState) const
 
bool getCalibration (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::Calibration &calibration) const
 
bool getCalibrationMotorEncoderOffset (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::MotorEncoderOffset &motorEncoderOffset) const
 
bool getCalibrationMotorEncoderParameters (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::MotorEncoderParameters &motorEncoderParameters) const
 
bool getCalibrationGearJointEncoderOffset (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::GearJointEncoderOffset &gearJointEncoderOffset) const
 
bool getCalibrationGearAndJointEncoderHoming (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::GearAndJointEncoderHoming &gearAndJointEncoderHoming) const
 
bool getCalibrationImuGyroscopeDcBias (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::ImuGyroscopeDcBias &imuGyroscopeDcBias) const
 
bool setCalibrationSpringStiffness (const calibration::CalibrationTypeEnum calibrationTypeEnum, const calibration::parameter::SpringStiffness &springStiffness) const
 
bool getCalibrationSpringStiffness (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::SpringStiffness &springStiffness) const
 
bool setCalibrationFrictionEstimation (const calibration::CalibrationTypeEnum calibrationTypeEnum, const calibration::parameter::FrictionEstimation &frictionEstimation) const
 
bool getCalibrationFrictionEstimation (const calibration::CalibrationTypeEnum calibrationTypeEnum, calibration::parameter::FrictionEstimation &frictionEstimation) const
 
bool resetCustomCalibrationsToFactory (const calibration::CalibrationState calibrationState)
 
bool writeFactoryCalibration ()
 
bool waitForCalibrationDone (double timeout=10.0, double checkingFrequency=10.0) const
 
bool getMaxCurrent (double &maxCurrent) const
 
bool setMaxCurrent (const double maxCurrent)
 
bool getMaxFreezeCurrent (double &current)
 
bool setMaxFreezeCurrent (const double current)
 
bool getMaxMotorVelocity (double &maxMotorVelocity) const
 
bool setMaxMotorVelocity (const double maxMotorVelocity)
 
bool getMaxJointTorque (double &maxJointTorque) const
 
bool setMaxJointTorque (const double maxJointTorque)
 
bool getCurrentIntegratorSaturation (double &saturation) const
 
bool setCurrentIntegratorSaturation (const double saturation)
 
bool getJointTorqueIntegratorSaturation (double &saturation) const
 
bool setJointTorqueIntegratorSaturation (const double saturation)
 
bool getDirection (int16_t &direction) const
 
bool setDirection (const int16_t direction)
 
bool getJointPositionLimitsSdk (common::Limits &limits) const
 
bool setJointPositionLimitsSdk (const common::Limits &limits)
 
bool getJointPositionLimitsSoft (common::Limits &limits) const
 
bool setJointPositionLimitsSoft (const common::Limits &limits)
 
bool getJointPositionLimitsHard (common::Limits &limits) const
 
bool setJointPositionLimitsHard (const common::Limits &limits)
 
bool getControlGains (const mode::ModeEnum mode, mode::PidGainsF &pidGains) const
 
bool setControlGains (const mode::ModeEnum mode, const mode::PidGainsF &pidGains)
 
bool getErrorStateBehavior (uint16_t &errorStateBehavior) const
 
bool setErrorStateBehavior (const uint16_t errorStateBehavior)
 
bool getImuEnabled (bool &enabled) const
 
bool setImuEnable (const bool enable)
 
bool getImuAccelerometerRange (uint32_t &range)
 
bool setImuAccelerometerRange (const uint32_t range)
 
bool getImuGyroscopeRange (uint32_t &range)
 
bool setImuGyroscopeRange (const uint32_t range)
 
bool getFanMode (uint32_t &mode)
 
bool setFanMode (const uint32_t mode)
 
bool getFanIntensity (uint32_t &intensity)
 
bool setFanIntensity (const uint32_t intensity)
 
bool getFanLowerTemperature (float &temperature)
 
bool setFanLowerTemperature (const float temperature)
 
bool getFanUpperTemperature (float &temperature)
 
bool setFanUpperTemperature (const float temperature)
 
bool getGearJointVelocityFilterType (uint32_t &type)
 
bool setGearJointVelocityFilterType (const uint32_t type)
 
bool getGearJointVelocityKfNoiseVariance (float &variance)
 
bool setGearJointVelocityKfNoiseVariance (const float variance)
 
bool getGearJointVelocityKfLambda2 (float &lambda)
 
bool setGearJointVelocityKfLambda2 (const float lambda)
 
bool getGearJointVelocityKfGamma (float &gamma)
 
bool setGearJointVelocityKfGamma (const float gamma)
 
bool getGearJointVelocityEmaAlpha (float &alpha)
 
bool setGearJointVelocityEmaAlpha (const float alpha)
 
bool getJointVelocityForAccelerationFilterType (uint32_t &type)
 
bool setJointVelocityForAccelerationFilterType (const uint32_t type)
 
bool getJointVelocityForAccelerationKfNoiseVariance (float &variance)
 
bool setJointVelocityForAccelerationKfNoiseVariance (const float variance)
 
bool getJointVelocityForAccelerationKfLambda2 (float &lambda)
 
bool setJointVelocityForAccelerationKfLambda2 (const float lambda)
 
bool getJointVelocityForAccelerationKfGamma (float &gamma)
 
bool setJointVelocityForAccelerationKfGamma (const float gamma)
 
bool getJointVelocityForAccelerationEmaAlpha (float &alpha)
 
bool setJointVelocityForAccelerationEmaAlpha (const float alpha)
 
bool getJointAccelerationFilterType (uint32_t &type)
 
bool setJointAccelerationFilterType (const uint32_t type)
 
bool getJointAccelerationKfNoiseVariance (float &variance)
 
bool setJointAccelerationKfNoiseVariance (const float variance)
 
bool getJointAccelerationKfLambda2 (float &lambda)
 
bool setJointAccelerationKfLambda2 (const float lambda)
 
bool getJointAccelerationKfGamma (float &gamma)
 
bool setJointAccelerationKfGamma (const float gamma)
 
bool getJointAccelerationEmaAlpha (float &alpha)
 
bool setJointAccelerationEmaAlpha (const float alpha)
 
bool writeConfiguration ()
 
Statusword getStatusword () const
 
void sendControlword (const uint16_t controlwordId)
 
void stageDisable ()
 
void stageFreeze ()
 
void stageZeroJointTorque ()
 
void stageCommand (const Command &command)
 
bool commandIsStaged () const
 
bool waitForMode (const mode::ModeEnum &mode, double timeout=1.0, double checkingFrequency=100.0) const
 
ReadingExtended getReading () const
 
void getReading (ReadingExtended &reading) const
 
void startLog (const std::string &name)
 
void stopLog ()
 
Log< ReadingExtendedgetLog (const std::string &name) const
 
void clearLogs ()
 
bool getRtdlEnabled (bool &enabled)
 
bool setRtdlEnable (const bool enable)
 
bool setRtdlCommand (const uint16_t command)
 
bool getRtdlStatus (uint16_t &status)
 
bool getRtdlLoggingFrequency (uint16_t &frequency)
 
bool setRtdlLoggingFrequency (const uint16_t frequency)
 
bool getRtdlStreamingFrequency (uint16_t &frequency)
 
bool setRtdlStreamingFrequency (const uint16_t frequency)
 
bool getRtdlLastTimestamp (uint64_t &timestamp)
 
void printInfo (const std::string &prefix="") const
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, int8_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, int16_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, int32_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, int64_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, uint8_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, uint16_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, uint32_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, uint64_t &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, float &value)
 
template<>
bool sendSdoRead (const uint16_t index, const uint8_t subindex, const bool completeAccess, double &value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const int8_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const int16_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const int32_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const int64_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const uint8_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const uint16_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const uint32_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const uint64_t value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const float value)
 
template<>
bool sendSdoWrite (const uint16_t index, const uint8_t subindex, const bool completeAccess, const double value)
 

Protected Member Functions

void commandCb (const anydrive_msgs::CommandConstPtr &commandMsg)
 
- Protected Member Functions inherited from anydrive::Anydrive
void requestAndSetStatusword ()
 
void setStatusword (Statusword &statusword)
 

Protected Attributes

ros::NodeHandle & nh_
 
std::string rosPrefix_
 
bool runCommandSubscriber_ = true
 
bool runReadingPublisher_ = true
 
bool runReadingExtendedThrottledPublisher_ = true
 
unsigned int readingExtendedThrottledPublisherCounter_ = 0
 
unsigned int readingExtendedThrottledPublisherDecimation_ = 0
 
ros::Subscriber commandSubscriber_
 
any_node::ThreadedPublisherPtr< anydrive_msgs::Reading > readingPublisher_
 
any_node::ThreadedPublisherPtr< anydrive_msgs::ReadingExtended > readingExtendedThrottledPublisher_
 
std::recursive_mutex readingMsgMutex_
 
std::atomic< bool > readingMsgUpdated_
 
anydrive_msgs::Reading readingMsg_
 
std::recursive_mutex readingExtendedMsgMutex_
 
std::atomic< bool > readingExtendedMsgUpdated_
 
anydrive_msgs::ReadingExtended readingExtendedMsg_
 
const unsigned int maxPublishMessageBufferSize_ = 0
 Publish options. More...
 
- Protected Attributes inherited from anydrive::Anydrive
std::string name_
 Name of the device. More...
 
configuration::Configuration configuration_
 Configuration of the device. More...
 
communication::CommunicationInterfaceBasePtr communicationInterface_
 Abstract communication interface. More...
 
common::Logger< ReadingExtendedlogger_
 Simple logger for calibrations. More...
 
fsm::StateMachine stateMachine_
 State machine of the device. More...
 
Statusword statusword_
 Current statusword. More...
 
std::atomic< bool > statuswordRequested_
 Remember if a statusword has been actively requested. More...
 
std::recursive_mutex readingMutex_
 Mutex protecting the reading. More...
 
ReadingExtended reading_
 Reading data. More...
 
std::recursive_mutex stagedCommandMutex_
 Mutex protecting the command. More...
 
Command stagedCommand_
 Command to be sent in the next update. More...
 
std::atomic< bool > commandIsStaged_
 Remember if a command has been staged. More...
 
std::multimap< int, ReadingCb, std::greater< int > > readingCbs_
 Prioritized callbacks called when a reading has been received. More...
 
std::multimap< int, ErrorCb, std::greater< int > > errorCbs_
 Prioritized callbacks called when an error appeared. More...
 
std::multimap< int, ErrorRecoveredCb, std::greater< int > > errorRecoveredCbs_
 Prioritized callbacks called when an error disappeared. More...
 
std::multimap< int, FatalCb, std::greater< int > > fatalCbs_
 Prioritized callbacks called when an fatal appeared. More...
 
std::multimap< int, FatalRecoveredCb, std::greater< int > > fatalRecoveredCbs_
 Prioritized callbacks called when an fatal disappeared. More...
 
std::multimap< int, DeviceDisconnectedCb, std::greater< int > > deviceDisconnectedCbs_
 Prioritized callbacks called when the device disconnected. More...
 
std::multimap< int, DeviceReconnectedCb, std::greater< int > > deviceReconnectedCbs_
 Prioritized callbacks called when the device reconnected. More...
 
std::atomic< bool > wasWithinJointPositionLimitsSdk_
 Remember if the joint position was in the SDK limit in the last time step. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from anydrive::Anydrive
static constexpr double nan_ = std::numeric_limits<double>::quiet_NaN()
 NaN abbreviation for convenience. More...
 
static constexpr double inf_ = std::numeric_limits<double>::infinity()
 Inf abbreviation for convenience. More...
 

Constructor & Destructor Documentation

◆ AnydriveRos()

anydrive_ros::AnydriveRos::AnydriveRos ( ros::NodeHandle &  nh,
const unsigned int  maxPublishMessageBufferSize 
)

◆ ~AnydriveRos()

anydrive_ros::AnydriveRos::~AnydriveRos ( )
virtual

Member Function Documentation

◆ commandCb()

void anydrive_ros::AnydriveRos::commandCb ( const anydrive_msgs::CommandConstPtr &  commandMsg)
protected

◆ getReadingExtendedMsg()

anydrive_msgs::ReadingExtended anydrive_ros::AnydriveRos::getReadingExtendedMsg ( )

◆ getReadingMsg()

anydrive_msgs::Reading anydrive_ros::AnydriveRos::getReadingMsg ( )

◆ sendRos()

void anydrive_ros::AnydriveRos::sendRos ( )

◆ shutdownWithoutCommunication()

void anydrive_ros::AnydriveRos::shutdownWithoutCommunication ( )
overridevirtual

Shutdown step 2: Shutdown/cleanup procedures which do not require communication with the device.

Reimplemented from anydrive::Anydrive.

◆ startupWithoutCommunication()

void anydrive_ros::AnydriveRos::startupWithoutCommunication ( )
overridevirtual

Startup step 1: Startup/initialization procedures which do not require communication with the device.

Reimplemented from anydrive::Anydrive.

◆ updateProcessReading()

void anydrive_ros::AnydriveRos::updateProcessReading ( )
overridevirtual

Update step 1: Process the last received reading. This includes updating the statusword and the state machine.

Reimplemented from anydrive::Anydrive.

Member Data Documentation

◆ commandSubscriber_

ros::Subscriber anydrive_ros::AnydriveRos::commandSubscriber_
protected

◆ maxPublishMessageBufferSize_

const unsigned int anydrive_ros::AnydriveRos::maxPublishMessageBufferSize_ = 0
protected

Publish options.

◆ nh_

ros::NodeHandle& anydrive_ros::AnydriveRos::nh_
protected

◆ readingExtendedMsg_

anydrive_msgs::ReadingExtended anydrive_ros::AnydriveRos::readingExtendedMsg_
protected

◆ readingExtendedMsgMutex_

std::recursive_mutex anydrive_ros::AnydriveRos::readingExtendedMsgMutex_
protected

◆ readingExtendedMsgUpdated_

std::atomic<bool> anydrive_ros::AnydriveRos::readingExtendedMsgUpdated_
protected

◆ readingExtendedThrottledPublisher_

any_node::ThreadedPublisherPtr<anydrive_msgs::ReadingExtended> anydrive_ros::AnydriveRos::readingExtendedThrottledPublisher_
protected

◆ readingExtendedThrottledPublisherCounter_

unsigned int anydrive_ros::AnydriveRos::readingExtendedThrottledPublisherCounter_ = 0
protected

◆ readingExtendedThrottledPublisherDecimation_

unsigned int anydrive_ros::AnydriveRos::readingExtendedThrottledPublisherDecimation_ = 0
protected

◆ readingMsg_

anydrive_msgs::Reading anydrive_ros::AnydriveRos::readingMsg_
protected

◆ readingMsgMutex_

std::recursive_mutex anydrive_ros::AnydriveRos::readingMsgMutex_
protected

◆ readingMsgUpdated_

std::atomic<bool> anydrive_ros::AnydriveRos::readingMsgUpdated_
protected

◆ readingPublisher_

any_node::ThreadedPublisherPtr<anydrive_msgs::Reading> anydrive_ros::AnydriveRos::readingPublisher_
protected

◆ rosPrefix_

std::string anydrive_ros::AnydriveRos::rosPrefix_
protected

◆ runCommandSubscriber_

bool anydrive_ros::AnydriveRos::runCommandSubscriber_ = true
protected

◆ runReadingExtendedThrottledPublisher_

bool anydrive_ros::AnydriveRos::runReadingExtendedThrottledPublisher_ = true
protected

◆ runReadingPublisher_

bool anydrive_ros::AnydriveRos::runReadingPublisher_ = true
protected

The documentation for this class was generated from the following files: