Aruna
aruna::movement::Actuator Class Referenceabstract

#include <Actuator.h>

Inheritance diagram for aruna::movement::Actuator:

Public Member Functions

 Actuator (axis_mask_t axis=axis_mask_t::NONE)
 Actuator object, used by the movement module for vehicle movement. More...
 
virtual ~Actuator ()
 
err_t set_axis (axis_mask_t new_axis)
 Set the axis that this Actuator is capable in moving in. More...
 
axis_mask_t get_axis ()
 get the movement modes that this driver supports. More...
 
err_t set (axis_mask_t axisMask, int16_t speed)
 Set the speed of the motors directly. More...
 
uint16_t get_speed ()
 Get the current speed of Actuator. More...
 

Public Attributes

err_t startup_error = err_t::NOT_STARTED
 error when constructing gets put here, read before usage. More...
 

Static Protected Member Functions

static double convert_range (uint16_t input, float range_max=100.f, float range_min=0.f)
 Convert uint16 to a new range. More...
 

Private Member Functions

virtual err_t _set (axis_mask_t axisMask, int16_t speed)=0
 Implementation of axis movement, this function is called from set(...). More...
 

Private Attributes

axis_mask_t axis = axis_mask_t::NONE
 
int16_t speed = 0
 

Detailed Description

Definition at line 14 of file Actuator.h.

Constructor & Destructor Documentation

◆ Actuator()

Actuator::Actuator ( axis_mask_t  axis = axis_mask_t::NONE)

Actuator object, used by the movement module for vehicle movement.

Define possible axis this Actuator can move in.

Parameters
axisaxis_mask_t possible containing multiple axis

Definition at line 12 of file Actuator.cpp.

12  : axis(axis){
13 
14 }

◆ ~Actuator()

Actuator::~Actuator ( )
virtual

Definition at line 51 of file Actuator.cpp.

51  {
52 
53 }

Member Function Documentation

◆ _set()

virtual err_t aruna::movement::Actuator::_set ( axis_mask_t  axisMask,
int16_t  speed 
)
privatepure virtual

Implementation of axis movement, this function is called from set(...).

Only gets called when axisMask match axis of Actuator.

Parameters
axisMaskaxis (can be multiple) to set speed to.
speeddesired speed.
Returns
err_t::OK if successful, others when not...

Implemented in aruna::driver::Stepper, aruna::driver::Dshot, aruna::driver::Pwm, and aruna::movement::ActuatorSet.

Here is the caller graph for this function:

◆ convert_range()

double Actuator::convert_range ( uint16_t  input,
float  range_max = 100.f,
float  range_min = 0.f 
)
staticprotected

Convert uint16 to a new range.

Parameters
inputinput to convert
range_maxmaximum range (default is 100)
range_minminimum range (default is 0)
Returns
output of convertion

Definition at line 46 of file Actuator.cpp.

46  {
47 // TODO allow for other type then uint_16 (maybe use <template>? and sizeof()?)
48  return ((input * (range_max - range_min)) / 65535) + range_min;
49 }
Here is the caller graph for this function:

◆ get_axis()

axis_mask_t Actuator::get_axis ( )

get the movement modes that this driver supports.

Returns
movement_mode mask ORed.

Definition at line 16 of file Actuator.cpp.

16  {
17  return axis;
18 }

◆ get_speed()

uint16_t Actuator::get_speed ( )

Get the current speed of Actuator.

Returns
speed.

Definition at line 34 of file Actuator.cpp.

34  {
35 // TODO speed should be axis indipendent.
36  return speed;
37 }

◆ set()

err_t Actuator::set ( axis_mask_t  axisMask,
int16_t  speed 
)

Set the speed of the motors directly.

Parameters
axisMask,multipleaxis to apply speed to.
speed,speedof the motors
Returns
err_t::OK if the command was succesfull, others when it fails.

Definition at line 20 of file Actuator.cpp.

20  {
21  err_t err = err_t::OK;
22 // TODO check direction via axisMask with(uint8_t) axisMask & (uint8_t) axis_mask_t::DIRECTION_BOTH & (uint8_t) axis
23 // or check direction with the speed value, of just leave direction check to implementation.
24  if ((uint8_t) axisMask & (uint8_t) axis_mask_t::ALL_AXIS & (uint8_t) axis) {
25 
26  err = _set(axisMask, speed);
27  if (err == err_t::OK)
28  this->speed = speed;
29  }
30 // TODO return not avaliable error?
31  return err;
32 }
virtual err_t _set(axis_mask_t axisMask, int16_t speed)=0
Implementation of axis movement, this function is called from set(...).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_axis()

err_t Actuator::set_axis ( axis_mask_t  new_axis)

Set the axis that this Actuator is capable in moving in.

Parameters
new_axisaxis_mask_t possible containing multible axis
Returns
always err_t::OK

Definition at line 40 of file Actuator.cpp.

40  {
41  axis = new_axis;
42  return err_t::OK;
43 }
Here is the caller graph for this function:

Member Data Documentation

◆ axis

axis_mask_t aruna::movement::Actuator::axis = axis_mask_t::NONE
private

Definition at line 28 of file Actuator.h.

◆ speed

int16_t aruna::movement::Actuator::speed = 0
private

Definition at line 29 of file Actuator.h.

◆ startup_error

err_t aruna::movement::Actuator::startup_error = err_t::NOT_STARTED

error when constructing gets put here, read before usage.

Definition at line 45 of file Actuator.h.


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