Viam C++ SDK current
|
gRPC client implementation of a Board
component.
More...
#include <board_client.hpp>
Public Types | |
using | interface_type = Board |
Public Types inherited from viam::sdk::Board | |
enum class | power_mode : uint8_t { normal = 0 , offline_deep = 1 } |
Power mode of the board The effect of these power modes depends on your physical board. | |
using | analog_value = int32_t |
Represents the raw value received by the registered analog to digital converter (ADC). The range and conversion mechanism to voltage will vary depending on the specific ADC registered to the pin. | |
using | digital_value = int64_t |
Depending on the type of digital interrupt, this can have different meanings. If a basic (default) interrupt is configured, then this is the total interrupt count. If a servo interrupt is configured this tracks the pulse width value. Consult Viam's Board documentation for more details. | |
Public Member Functions | |
BoardClient (std::string name, std::shared_ptr< grpc::Channel > channel) | |
ProtoStruct | do_command (const ProtoStruct &command) override |
Send/receive arbitrary commands to the resource. | |
void | set_gpio (const std::string &pin, bool high, const ProtoStruct &extra) override |
Set the gpio high/low state of the given pin on a board. | |
bool | get_gpio (const std::string &pin, const ProtoStruct &extra) override |
Gets the high/low state of the given pin on a board. | |
double | get_pwm_duty_cycle (const std::string &pin, const ProtoStruct &extra) override |
Gets the duty cycle of the given pin on a board. | |
void | set_pwm_duty_cycle (const std::string &pin, double duty_cycle_pct, const ProtoStruct &extra) override |
Sets the given pin of a board to the given duty cycle. | |
uint64_t | get_pwm_frequency (const std::string &pin, const ProtoStruct &extra) override |
Gets the PWM frequency of the given pin on a board. | |
void | set_pwm_frequency (const std::string &pin, uint64_t frequency_hz, const ProtoStruct &extra) override |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency. | |
analog_response | read_analog (const std::string &analog_reader_name, const ProtoStruct &extra) override |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board docs for more information. | |
void | write_analog (const std::string &pin, int value, const ProtoStruct &extra) override |
Writes the value to the analog writer of the board. | |
digital_value | read_digital_interrupt (const std::string &digital_interrupt_name, const ProtoStruct &extra) override |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board docs for more information. | |
void | set_power_mode (power_mode power_mode, const ProtoStruct &extra, const boost::optional< std::chrono::microseconds > &duration) override |
Sets the power consumption mode of the board to the requested setting for the given duration. | |
std::vector< GeometryConfig > | get_geometries (const ProtoStruct &extra) override |
Returns GeometryConfig s associated with the calling board. | |
void | stream_ticks (std::vector< std::string > const &digital_interrupt_names, std::function< bool(Tick &&tick)> const &tick_handler, const ProtoStruct &extra) override |
Returns a stream of digital interrupt ticks. | |
std::vector< GeometryConfig > | get_geometries () |
Returns GeometryConfig s associated with the calling board. | |
virtual std::vector< GeometryConfig > | get_geometries (const ProtoStruct &extra)=0 |
Returns GeometryConfig s associated with the calling board. | |
bool | get_gpio (const std::string &pin) |
Gets the high/low state of the given pin on a board. | |
virtual bool | get_gpio (const std::string &pin, const ProtoStruct &extra)=0 |
Gets the high/low state of the given pin on a board. | |
double | get_pwm_duty_cycle (const std::string &pin) |
Gets the duty cycle of the given pin on a board. | |
virtual double | get_pwm_duty_cycle (const std::string &pin, const ProtoStruct &extra)=0 |
Gets the duty cycle of the given pin on a board. | |
uint64_t | get_pwm_frequency (const std::string &pin) |
Gets the PWM frequency of the given pin on a board. | |
virtual uint64_t | get_pwm_frequency (const std::string &pin, const ProtoStruct &extra)=0 |
Gets the PWM frequency of the given pin on a board. | |
analog_response | read_analog (const std::string &analog_reader_name) |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board docs for more information. | |
virtual analog_response | read_analog (const std::string &analog_reader_name, const ProtoStruct &extra)=0 |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board docs for more information. | |
digital_value | read_digital_interrupt (const std::string &digital_interrupt_name) |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board docs for more information. | |
virtual digital_value | read_digital_interrupt (const std::string &digital_interrupt_name, const ProtoStruct &extra)=0 |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board docs for more information. | |
void | set_gpio (const std::string &pin, bool high) |
Set the gpio high/low state of the given pin on a board. | |
virtual void | set_gpio (const std::string &pin, bool high, const ProtoStruct &extra)=0 |
Set the gpio high/low state of the given pin on a board. | |
void | set_power_mode (power_mode power_mode, const boost::optional< std::chrono::microseconds > &duration={}) |
Sets the power consumption mode of the board to the requested setting for the given duration. | |
virtual void | set_power_mode (power_mode power_mode, const ProtoStruct &extra, const boost::optional< std::chrono::microseconds > &duration={})=0 |
Sets the power consumption mode of the board to the requested setting for the given duration. | |
void | set_pwm_duty_cycle (const std::string &pin, double duty_cycle_pct) |
Sets the given pin of a board to the given duty cycle. | |
virtual void | set_pwm_duty_cycle (const std::string &pin, double duty_cycle_pct, const ProtoStruct &extra)=0 |
Sets the given pin of a board to the given duty cycle. | |
void | set_pwm_frequency (const std::string &pin, uint64_t frequency_hz) |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency. | |
virtual void | set_pwm_frequency (const std::string &pin, uint64_t frequency_hz, const ProtoStruct &extra)=0 |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency. | |
void | stream_ticks (std::vector< std::string > const &digital_interrupt_names, std::function< bool(Tick &&tick)> const &tick_handler) |
Returns a stream of digital interrupt ticks. | |
virtual void | stream_ticks (std::vector< std::string > const &digital_interrupt_names, std::function< bool(Tick &&tick)> const &tick_handler, const ProtoStruct &extra)=0 |
Returns a stream of digital interrupt ticks. | |
void | write_analog (const std::string &pin, int value) |
Writes the value to the analog writer of the board. | |
virtual void | write_analog (const std::string &pin, int value, const ProtoStruct &extra)=0 |
Writes the value to the analog writer of the board. | |
Public Member Functions inherited from viam::sdk::Board | |
API | api () const override |
Returns the API associated with a particular resource. | |
bool | get_gpio (const std::string &pin) |
Gets the high/low state of the given pin on a board. | |
void | set_gpio (const std::string &pin, bool high) |
Set the gpio high/low state of the given pin on a board. | |
double | get_pwm_duty_cycle (const std::string &pin) |
Gets the duty cycle of the given pin on a board. | |
void | set_pwm_duty_cycle (const std::string &pin, double duty_cycle_pct) |
Sets the given pin of a board to the given duty cycle. | |
uint64_t | get_pwm_frequency (const std::string &pin) |
Gets the PWM frequency of the given pin on a board. | |
void | set_pwm_frequency (const std::string &pin, uint64_t frequency_hz) |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency. | |
analog_response | read_analog (const std::string &analog_reader_name) |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board docs for more information. | |
void | write_analog (const std::string &pin, int value) |
Writes the value to the analog writer of the board. | |
digital_value | read_digital_interrupt (const std::string &digital_interrupt_name) |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board docs for more information. | |
void | stream_ticks (std::vector< std::string > const &digital_interrupt_names, std::function< bool(Tick &&tick)> const &tick_handler) |
Returns a stream of digital interrupt ticks. | |
void | set_power_mode (power_mode power_mode, const boost::optional< std::chrono::microseconds > &duration={}) |
Sets the power consumption mode of the board to the requested setting for the given duration. | |
std::vector< GeometryConfig > | get_geometries () |
Returns GeometryConfig s associated with the calling board. | |
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. | |
Additional Inherited Members | |
Protected Member Functions inherited from viam::sdk::Board | |
Board (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 |
gRPC client implementation of a Board
component.
|
overridevirtual |
Send/receive arbitrary commands to the resource.
Command | the command to execute. |
Implements viam::sdk::Board.
|
inline |
Returns GeometryConfig
s associated with the calling board.
GeometryConfig
s associated with the component.
|
overridevirtual |
Returns GeometryConfig
s associated with the calling board.
extra | Any additional arguments to the method. |
GeometryConfig
s associated with the component. Implements viam::sdk::Board.
|
virtual |
Returns GeometryConfig
s associated with the calling board.
extra | Any additional arguments to the method. |
GeometryConfig
s associated with the component. Implements viam::sdk::Board.
|
inline |
Gets the high/low state of the given pin on a board.
pin | board pin name |
|
overridevirtual |
Gets the high/low state of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Gets the high/low state of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Gets the duty cycle of the given pin on a board.
pin | board pin name |
|
overridevirtual |
Gets the duty cycle of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Gets the duty cycle of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Gets the PWM frequency of the given pin on a board.
pin | board pin name |
|
overridevirtual |
Gets the PWM frequency of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Gets the PWM frequency of the given pin on a board.
pin | board pin name |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board
docs for more information.
analog_reader_name | analog reader to read from |
|
overridevirtual |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board
docs for more information.
analog_reader_name | analog reader to read from |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Reads off the current value of an analog reader on a board. Consult your ADC's docs or Viam's Board
docs for more information.
analog_reader_name | analog reader to read from |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board
docs for more information.
digital_interrupt_name | digital interrupt to check |
|
overridevirtual |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board
docs for more information.
digital_interrupt_name | digital interrupt to check |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Returns the current value of the interrupt which is based on the type of interrupt. Consult Viam's Board
docs for more information.
digital_interrupt_name | digital interrupt to check |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Set the gpio high/low state of the given pin on a board.
high | true if the pin should be set to high (on) or false if it should be low (off) |
|
overridevirtual |
Set the gpio high/low state of the given pin on a board.
high | true if the pin should be set to high (on) or false if it should be low (off) |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Set the gpio high/low state of the given pin on a board.
high | true if the pin should be set to high (on) or false if it should be low (off) |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Sets the power consumption mode of the board to the requested setting for the given duration.
power_mode | Requested power mode |
duration | Requested duration to stay in power_mode (in microseconds) |
|
overridevirtual |
Sets the power consumption mode of the board to the requested setting for the given duration.
power_mode | Requested power mode |
extra | Any additional arguments to the method |
duration | Requested duration to stay in power_mode (in microseconds) |
Implements viam::sdk::Board.
|
virtual |
Sets the power consumption mode of the board to the requested setting for the given duration.
power_mode | Requested power mode |
extra | Any additional arguments to the method |
duration | Requested duration to stay in power_mode (in microseconds) |
Implements viam::sdk::Board.
|
inline |
Sets the given pin of a board to the given duty cycle.
pin | board pin name |
duty_cycle_pct | duty cycle percentage 0 to 1 |
|
overridevirtual |
Sets the given pin of a board to the given duty cycle.
pin | board pin name |
duty_cycle_pct | duty cycle percentage 0 to 1 |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Sets the given pin of a board to the given duty cycle.
pin | board pin name |
duty_cycle_pct | duty cycle percentage 0 to 1 |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency.
pin | board pin name |
frequency_hz | frequency in hz (0 = use board default frequency) |
|
overridevirtual |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency.
pin | board pin name |
frequency_hz | frequency in hz (0 = use board default frequency) |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Sets the given pin on a board to the given PWM frequency. 0 will use the board's default PWM frequency.
pin | board pin name |
frequency_hz | frequency in hz (0 = use board default frequency) |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Returns a stream of digital interrupt ticks.
digital_interrupt_names | digital interrupts to stream |
tick_handler | callback function to call when a tick occurs. This should return true to keep streaming ticks and false to indicate that the stream of ticks should terminate. The callback function should not be blocking. |
|
overridevirtual |
Returns a stream of digital interrupt ticks.
digital_interrupt_names | digital interrupts to stream |
tick_handler | callback function to call when a tick occurs. |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Returns a stream of digital interrupt ticks.
digital_interrupt_names | digital interrupts to stream |
tick_handler | callback function to call when a tick occurs. |
extra | Any additional arguments to the method |
Implements viam::sdk::Board.
|
inline |
Writes the value to the analog writer of the board.
pin | the pin to write to |
value | the value to set the pin to |
|
overridevirtual |
Writes the value to the analog writer of the board.
pin | the pin to write to |
value | the value to set the pin to |
extra | any additional arguments to the method |
Implements viam::sdk::Board.
|
virtual |
Writes the value to the analog writer of the board.
pin | the pin to write to |
value | the value to set the pin to |
extra | any additional arguments to the method |
Implements viam::sdk::Board.