NDEVR
API Documentation
Motor.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Hardware
28File: Motor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Device.h>
35#include <NDEVR/Angle.h>
36namespace NDEVR
37{
38 class Log;
45 class HARDWARE_API Motor : public Device
46 {
47 public:
52 Motor(const Model& model, LogPtr log = nullptr, QObject* parent = nullptr);
54 [[nodiscard]] virtual Angle<fltp08> location() const;
56 [[nodiscard]] virtual Angle<fltp08> speed() const { return m_current_speed; }
58 [[nodiscard]] virtual Angle<fltp08> parkAngle() const { return m_park_angle; }
60 [[nodiscard]] virtual Angle<fltp08> preferredSpeed() const { return m_preferred_speed; }
62 [[nodiscard]] virtual Angle<fltp08> targetAngle() const { return m_target_angle; }
64 [[nodiscard]] virtual bool supportsMoveTo() const;
66 [[nodiscard]] virtual bool supportsSetSpeed() const;
68 [[nodiscard]] virtual bool activated() const { return m_activated; };
71 virtual void setLocation(const Angle<fltp08>& location);
77 void updatePositionFromSpeed(Time current_time);
84 virtual void setModelTransformOffset(const Matrix<fltp08>& offset);
87 virtual void setParkAngle(const Angle<fltp08>& location);
93 virtual void setAxisOfRotation(const Vector<3, fltp08>& rotation_axis);
96 virtual void setCenterOfRotation(const Vector<3, fltp08>& rotation_axis);
99 virtual void setTorqueLimit(fltp08 limit) { m_torque_limit = limit; }
104 virtual void setSpeed(const Angle<fltp08>& speed);
107 virtual void setActivated(bool activated);
110 void setSpeedRange(const Bounds<2, Angle<fltp08>>& speed_range);
112 void parkMotor();
117 virtual void updateModel();
118 protected:
129 Time m_last_speed_time = Constant<Time>::Invalid;
132 };
133}
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
Device(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs a Device from a Model with the given log and optional Qt parent.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:50
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
Bounds< 1, Angle< fltp08 > > m_bounds
The angular position bounds for the motor.
Definition Motor.h:120
virtual Angle< fltp08 > location() const
Returns the current angular position of the motor.
Angle< fltp08 > m_current_angle
The current angular position.
Definition Motor.h:123
virtual void setParkAngle(const Angle< fltp08 > &location)
Sets the park angle position for the motor.
virtual void updateModel()
Updates the associated model's transform to reflect the motor's current position.
virtual Angle< fltp08 > preferredSpeed() const
Returns the preferred rotational speed of the motor.
Definition Motor.h:60
bool m_activated
Whether the motor is currently activated.
Definition Motor.h:131
Bounds< 2, Angle< fltp08 > > m_speed_range
The allowable speed range (forward and reverse).
Definition Motor.h:119
virtual void setCenterOfRotation(const Vector< 3, fltp08 > &rotation_axis)
Sets the center of rotation for the motor.
virtual bool supportsMoveTo() const
Returns whether this motor supports move-to-angle commands.
virtual void setSpeed(const Angle< fltp08 > &speed)
Sets the rotational speed of the motor.
virtual bool activated() const
Returns whether the motor is currently activated.
Definition Motor.h:68
virtual bool supportsSetSpeed() const
Returns whether this motor supports set-speed commands.
fltp08 m_torque_limit
The torque limit for the motor.
Definition Motor.h:130
Angle< fltp08 > m_target_angle
The target angle the motor is moving toward.
Definition Motor.h:126
virtual void parkMotorAtSpeed(const Angle< fltp08 > &speed)
Moves the motor to its park angle at the specified speed.
Angle< fltp08 > m_park_angle
The park angle position.
Definition Motor.h:128
virtual void setActivated(bool activated)
Activates or deactivates the motor.
Motor(const Model &model, LogPtr log=nullptr, QObject *parent=nullptr)
Constructs a Motor device.
void parkMotor()
Moves the motor to its park angle at the preferred speed.
virtual Angle< fltp08 > targetAngle() const
Returns the target angle the motor is moving toward.
Definition Motor.h:62
void setSpeedRange(const Bounds< 2, Angle< fltp08 > > &speed_range)
Sets the allowable speed range for the motor.
virtual Angle< fltp08 > speed() const
Returns the current angular speed of the motor.
Definition Motor.h:56
Vector< 3, fltp08 > m_center_of_rotation
The 3D center of rotation.
Definition Motor.h:122
Time m_last_speed_time
Timestamp of the last speed-based position update.
Definition Motor.h:129
Angle< fltp08 > m_current_speed
The current angular speed per second.
Definition Motor.h:124
Vector< 3, fltp08 > m_axis_of_rotation
The 3D axis of rotation.
Definition Motor.h:121
virtual void setAxisOfRotation(const Vector< 3, fltp08 > &rotation_axis)
Sets the axis of rotation for the motor.
Angle< fltp08 > m_preferred_speed
The preferred rotational speed.
Definition Motor.h:125
virtual void setPreferredSpeed(const Angle< fltp08 > &location)
Sets the preferred rotational speed.
Definition Motor.h:90
virtual void setTargetAndSpeed(const Angle< fltp08 > &location, const Angle< fltp08 > &speed)
Sets both the target angle and the speed to reach it.
void updatePositionFromSpeed(Time current_time)
Updates the motor position based on its current speed and elapsed time.
virtual void setTorqueLimit(fltp08 limit)
Sets the torque limit for the motor.
Definition Motor.h:99
virtual Angle< fltp08 > parkAngle() const
Returns the motor's park angle position.
Definition Motor.h:58
Matrix< fltp08 > m_model_transform_offset
Transform offset applied to the model.
Definition Motor.h:127
virtual Bounds< 2, Angle< fltp08 > > speedRange() const
Returns the speed range (forward and reverse) for the motor.
Definition Motor.h:101
virtual void setLocation(const Angle< fltp08 > &location)
Sets the current angular position of the motor.
virtual void setModelTransformOffset(const Matrix< fltp08 > &offset)
Sets a transform offset applied to the model when updating its position.
void setTarget(const Angle< fltp08 > &location)
Sets the target angle for the motor to move to.
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...