File motor.hpp

License:

License BSD-3-Clause

Copyright

Copyright (c) 2019-2020, New York University and Max Planck Gesellschaft.

Date

2019-07-11

namespace blmc_drivers

This namespace is the standard namespace of the package.

class Motor : public blmc_drivers::MotorInterface
#include <motor.hpp>

This class implements the MotorInterface.

Subclassed by blmc_drivers::SafeMotor

Public Functions

Motor(Ptr<MotorBoardInterface> board, bool motor_id)

Construct a new Motor object.

Parameters
  • board – is the MotorBoard to be used.

  • motor_id – is the id of the motor on the on-board card

inline virtual ~Motor()

Destroy the Motor object.

inline virtual void send_if_input_changed()

Actually send the command and controls via the network, See MotorInterface for more information.

virtual Ptr<const ScalarTimeseries> get_measurement(const int &index = 0) const

Getters.

Get the measurements

Parameters

index – is the kind of measurement we are instersted in. see MotorInterface::MeasurementIndex.

Returns

Ptr<const ScalarTimeseries> The history of the measurement

virtual Ptr<const ScalarTimeseries> get_current_target() const

Get the current target to be sent.

Returns

Ptr<const ScalarTimeseries> the list of current values to be sent.

virtual Ptr<const ScalarTimeseries> get_sent_current_target() const

Get the already sent current target values.

Returns

Ptr<const ScalarTimeseries>

virtual void set_current_target(const double &current_target)

Setters.

Set the current (Ampere) target. See MotorInterface for more information.

Parameters

current_target – in Ampere

inline virtual void set_command(const MotorBoardCommand &command)

Set the command.

See MotorInterface for more information.

Parameters

command

virtual void print() const

Print the motor status and state.

Protected Attributes

Ptr<MotorBoardInterface> board_

The MotorBoard to be used for the communication.

bool motor_id_

The id of the motor on the MotorBoard.

class MotorInterface : public blmc_drivers::DeviceInterface
#include <motor.hpp>

This class declares an interface to the motor.

It allows the user to access the sensors data as well as sending controls. The only control supported for now is the current.

Subclassed by blmc_drivers::Motor

Public Types

enum MeasurementIndex

Here is a list of the different measurement available on the blmc card.

Values:

enumerator current
enumerator position
enumerator velocity
enumerator encoder_index
enumerator measurement_count
typedef time_series::TimeSeries<double> ScalarTimeseries

This is a useful alias.

template<typename Type>
using Ptr = std::shared_ptr<Type>

This a useful alias for the shared Pointer creation.

Template Parameters

Type – is the Class to crate the pointer from.

Public Functions

inline virtual ~MotorInterface()

Destroy the MotorInterface object.

virtual void send_if_input_changed() = 0

Actually send the commands and controls.

virtual Ptr<const ScalarTimeseries> get_measurement(const int &index = 0) const = 0

Getters.

Get the measurements.

Parameters

index

Returns

Ptr<const ScalarTimeseries> the pointer to the desired measurement history.

virtual Ptr<const ScalarTimeseries> get_current_target() const = 0

Get the current target object.

Returns

Ptr<const ScalarTimeseries> the list of the current values to be sent.

virtual Ptr<const ScalarTimeseries> get_sent_current_target() const = 0

Get the history of the sent current targets.

Returns

Ptr<const ScalarTimeseries>

virtual void set_current_target(const double &current_target) = 0

Setters.

Set the current target. This function saves the data internally. Please call send_if_input_changed() to actually send the data.

Parameters

current_target

virtual void set_command(const MotorBoardCommand &command) = 0

Set the command.

Save internally a command to be apply by the motor board. This function save the command internally. Please call send_if_input_changed() to actually send the data.

Parameters

command

class SafeMotor : public blmc_drivers::Motor
#include <motor.hpp>

This class is a safe implementation of the Motor class.

It contains utilities to bound the control input. It could also contains some velocity limits at the motor level and why not some temperature management.

Todo:

the velocity limit should be implemented in a smoother way, and the parameters should be passed in the constructor.

Public Functions

SafeMotor(Ptr<MotorBoardInterface> board, bool motor_id, const double &max_current_target = 2.0, const size_t &history_length = 1000, const double &max_velocity = std::numeric_limits<double>::quiet_NaN())

Construct a new SafeMotor object.

Parameters
  • board

  • motor_id

  • max_current_target

  • history_length

inline virtual Ptr<const ScalarTimeseries> get_current_target() const

Getters.

Get the _current_target object

Returns

Ptr<const ScalarTimeseries>

virtual void set_current_target(const double &current_target)

Setters.

Set the current target (Ampere)

Parameters

current_target

inline void set_max_current(double max_current_target)

Set the max_current_target_ object.

Parameters

max_current_target

inline void set_max_velocity(double max_velocity)

Set the max_velocity_ constant.

Parameters

max_velocity

Private Members

double max_current_target_

max_current_target_ is the limit of the current.

double max_velocity_

max_velocity_ limits the motor velocity.

Ptr<ScalarTimeseries> current_target_

History of the target current sent.