Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
viam::sdk::Encoder Class Referenceabstract

An encoder is a device that is hooked up to motors to report a position. More...

#include "components/encoder.hpp"

+ Inheritance diagram for viam::sdk::Encoder:

Classes

struct  position
 reported position. More...
 
struct  properties
 Encodes the supported modes of this encoder. More...
 

Public Types

enum class  position_type : uint8_t { unspecified = 0 , ticks_count = 1 , angle_degrees = 2 }
 

Public Member Functions

position get_position (position_type position_type=position_type::unspecified)
 Returns position of the encoder which can either be ticks since last zeroing for an incremental encoder or degrees for an absolute encoder.
 
virtual position get_position (const ProtoStruct &extra, position_type position_type=position_type::unspecified)=0
 Returns position of the encoder which can either be ticks since last zeroing for an incremental encoder or degrees for an absolute encoder.
 
void reset_position ()
 Reset the value of the position.
 
virtual void reset_position (const ProtoStruct &extra)=0
 Reset the value of the position.
 
properties get_properties ()
 Returns a list of all the position_types that are supported by the encoder.
 
virtual properties get_properties (const ProtoStruct &extra)=0
 Returns a list of all the position_types that are supported by the encoder.
 
virtual ProtoStruct do_command (const ProtoStruct &command)=0
 Send/receive arbitrary commands to the resource.
 
std::vector< GeometryConfigget_geometries ()
 Returns GeometryConfigs associated with the calling encoder.
 
virtual std::vector< GeometryConfigget_geometries (const ProtoStruct &extra)=0
 Returns GeometryConfigs associated with the calling encoder.
 
API api () const override
 Returns the API associated with a particular resource.
 
- Public Member Functions inherited from viam::sdk::Component
Name get_resource_name () const override
 Returns the Name for a particular resource.
 
- Public Member Functions inherited from viam::sdk::Resource
 Resource (std::string name)
 
virtual std::string name () const
 Return the resource's name.
 

Protected Member Functions

 Encoder (std::string name)
 
- Protected Member Functions inherited from viam::sdk::Component
 Component (std::string name)
 
- Protected Member Functions inherited from viam::sdk::Resource
Name get_resource_name (const std::string &type) const
 

Detailed Description

An encoder is a device that is hooked up to motors to report a position.

This acts as an abstract base class to be inherited from by any drivers representing specific encoder implementations. This class cannot be used on its own.

Member Function Documentation

◆ api()

API viam::sdk::Encoder::api ( ) const
overridevirtual

Returns the API associated with a particular resource.

Implements viam::sdk::Resource.

◆ do_command()

virtual ProtoStruct viam::sdk::Encoder::do_command ( const ProtoStruct & command)
pure virtual

Send/receive arbitrary commands to the resource.

Parameters
Commandthe command to execute.
Returns
The result of the executed command.

Implemented in viam::sdk::impl::EncoderClient.

◆ get_geometries() [1/2]

std::vector< GeometryConfig > viam::sdk::Encoder::get_geometries ( )
inline

Returns GeometryConfigs associated with the calling encoder.

Returns
The requested GeometryConfigs associated with the component.

◆ get_geometries() [2/2]

virtual std::vector< GeometryConfig > viam::sdk::Encoder::get_geometries ( const ProtoStruct & extra)
pure virtual

Returns GeometryConfigs associated with the calling encoder.

Parameters
extraAny additional arguments to the method.
Returns
The requested GeometryConfigs associated with the component.

Implemented in viam::sdk::impl::EncoderClient, and viam::sdk::impl::EncoderClient.

◆ get_position() [1/2]

virtual position viam::sdk::Encoder::get_position ( const ProtoStruct & extra,
position_type position_type = position_type::unspecified )
pure virtual

Returns position of the encoder which can either be ticks since last zeroing for an incremental encoder or degrees for an absolute encoder.

Parameters
extraAny additional arguments to the method.
position_typeThe type of position you are requesting. If the driver does not implement the requested type, this call will return an error. If position type is unspecified, the response will return a default according to the driver.

Implemented in viam::sdk::impl::EncoderClient, and viam::sdk::impl::EncoderClient.

◆ get_position() [2/2]

position viam::sdk::Encoder::get_position ( position_type position_type = position_type::unspecified)
inline

Returns position of the encoder which can either be ticks since last zeroing for an incremental encoder or degrees for an absolute encoder.

Parameters
position_typeThe type of position you are requesting. If the driver does not implement the requested type, this call will return an error. If position type is unspecified, the response will return a default according to the driver.

◆ get_properties()

virtual properties viam::sdk::Encoder::get_properties ( const ProtoStruct & extra)
pure virtual

Returns a list of all the position_types that are supported by the encoder.

Parameters
extraAny additional arguments to the method.

Implemented in viam::sdk::impl::EncoderClient, and viam::sdk::impl::EncoderClient.

◆ reset_position()

virtual void viam::sdk::Encoder::reset_position ( const ProtoStruct & extra)
pure virtual

Reset the value of the position.

Parameters
extraAny additional arguments to the method.

Implemented in viam::sdk::impl::EncoderClient, and viam::sdk::impl::EncoderClient.


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