8#include <viam/api/component/motor/v1/motor.pb.h>
10#include <viam/sdk/common/proto_type.hpp>
11#include <viam/sdk/common/utils.hpp>
12#include <viam/sdk/config/resource.hpp>
13#include <viam/sdk/resource/stoppable.hpp>
77 virtual void set_power(
double power_pct,
const AttributeMap& extra) = 0;
87 inline void go_for(
double rpm,
double revolutions) {
88 return go_for(rpm, revolutions, {});
100 virtual void go_for(
double rpm,
double revolutions,
const AttributeMap& extra) = 0;
107 inline void go_to(
double rpm,
double position_revolutions) {
108 return go_to(rpm, position_revolutions, {});
117 virtual void go_to(
double rpm,
double position_revolutions,
const AttributeMap& extra) = 0;
130 virtual void set_rpm(
double rpm,
const AttributeMap& extra) = 0;
182 virtual AttributeMap
do_command(
const AttributeMap& command) = 0;
193 virtual std::vector<GeometryConfig>
get_geometries(
const AttributeMap& extra) = 0;
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
Definition component.hpp:14
A Motor represents physical hardware that controls the rotation of an axle.
Definition motor.hpp:24
static viam::component::motor::v1::GetPositionResponse to_proto(const position &position)
Converts a position struct to its proto representation.
virtual AttributeMap do_command(const AttributeMap &command)=0
Send/receive arbitrary commands to the resource.
void go_to(double rpm, double position_revolutions)
Move the motor to a specific position that is relative to its home position at a specified speed whic...
Definition motor.hpp:107
virtual std::vector< GeometryConfig > get_geometries(const AttributeMap &extra)=0
Returns GeometryConfigs associated with the calling motor.
virtual properties get_properties(const AttributeMap &extra)=0
Returns the properties of the motor which comprises the booleans indicating.
position get_position()
Reports the position of the robot's motor relative to its zero position.
Definition motor.hpp:147
void set_power(double power_pct)
Sets the percentage of the motor's total power that should be employed.
Definition motor.hpp:69
static properties from_proto(const viam::component::motor::v1::GetPropertiesResponse &proto)
Creates a properties struct from its proto representation.
void set_rpm(double rpm)
Move the motor indefinitely at a specified speed which is expressed in RPM.
Definition motor.hpp:122
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling motor.
Definition motor.hpp:186
virtual position get_position(const AttributeMap &extra)=0
Reports the position of the robot's motor relative to its zero position.
static power_status from_proto(const viam::component::motor::v1::IsPoweredResponse &proto)
Creates a power_status struct from its proto representation.
virtual power_status get_power_status(const AttributeMap &extra)=0
static viam::component::motor::v1::IsPoweredResponse to_proto(const power_status &power_status)
Converts a power_status struct to its proto representation.
void go_for(double rpm, double revolutions)
Instructs the motor to turn at a specified speed, which is expressed in RPM, for a specified number o...
Definition motor.hpp:87
properties get_properties()
Returns the properties of the motor which comprises the booleans indicating which optional features t...
Definition motor.hpp:158
power_status get_power_status()
Definition motor.hpp:168
virtual void set_rpm(double rpm, const AttributeMap &extra)=0
Move the motor indefinitely at a specified speed which is expressed in RPM.
virtual void reset_zero_position(double offset, const AttributeMap &extra)=0
Sets the current position of the motor as the new zero position.
static viam::component::motor::v1::GetPropertiesResponse to_proto(const properties &properties)
Converts a properties struct to its proto representation.
virtual void go_for(double rpm, double revolutions, const AttributeMap &extra)=0
Instructs the motor to turn at a specified speed, which is expressed in RPM, for a specified number o...
virtual void go_to(double rpm, double position_revolutions, const AttributeMap &extra)=0
Move the motor to a specific position that is relative to its home position at a specified speed whic...
void reset_zero_position(double offset)
Sets the current position of the motor as the new zero position.
Definition motor.hpp:135
static position from_proto(const viam::component::motor::v1::GetPositionResponse &proto)
Creates a position struct from its proto representation.
virtual bool is_moving()=0
Reports if a component is in motion.
virtual void set_power(double power_pct, const AttributeMap &extra)=0
Sets the percentage of the motor's total power that should be employed.
API api() const override
Returns the API associated with a particular resource.
virtual std::string name() const
Return the resource's name.
Definition stoppable.hpp:8
Current position of the motor relative to its home.
Definition resource_api.hpp:50
Information about power-state of the motor.
Definition motor.hpp:32
bool is_on
True if the motor is on.
Definition motor.hpp:34
double power_pct
Definition motor.hpp:38
Features that the specific motor supports.
Definition motor.hpp:43
bool position_reporting
True if the motor supports reporting its position.
Definition motor.hpp:45