6#include <grpcpp/channel.h>
8#include <viam/api/component/board/v1/board.grpc.pb.h>
12#include <viam/sdk/config/resource.hpp>
26 ProtoStruct
do_command(
const ProtoStruct& command)
override;
27 void set_gpio(
const std::string& pin,
bool high,
const ProtoStruct& extra)
override;
28 bool get_gpio(
const std::string& pin,
const ProtoStruct& extra)
override;
31 double duty_cycle_pct,
32 const ProtoStruct& extra)
override;
35 uint64_t frequency_hz,
36 const ProtoStruct& extra)
override;
38 const ProtoStruct& extra)
override;
39 void write_analog(
const std::string& pin,
int value,
const ProtoStruct& extra)
override;
41 const ProtoStruct& extra)
override;
43 const ProtoStruct& extra,
44 const boost::optional<std::chrono::microseconds>& duration)
override;
45 std::vector<GeometryConfig>
get_geometries(
const ProtoStruct& extra)
override;
47 void stream_ticks(std::vector<std::string>
const& digital_interrupt_names,
48 std::function<
bool(
Tick&&
tick)>
const& tick_handler,
49 const ProtoStruct& extra)
override;
74 using StubType = viam::component::board::v1::BoardService::StubInterface;
75 std::unique_ptr<StubType> stub_;
76 const std::shared_ptr<grpc::Channel> channel_;
Defines a Board component.
Implements a gRPC server for the Board component.
Represents a physical board with gpio pins, digital interrupts, and analog voltage reading.
Definition board.hpp:24
power_mode
Power mode of the board The effect of these power modes depends on your physical board.
Definition board.hpp:73
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling board.
Definition board.hpp:242
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.
Definition board.hpp:220
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 d...
Definition board.hpp:160
void set_gpio(const std::string &pin, bool high)
Set the gpio high/low state of the given pin on a board.
Definition board.hpp:92
uint64_t get_pwm_frequency(const std::string &pin)
Gets the PWM frequency of the given pin on a board.
Definition board.hpp:131
int64_t digital_value
Depending on the type of digital interrupt, this can have different meanings. If a basic (default) in...
Definition board.hpp:47
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....
Definition board.hpp:187
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.
Definition board.hpp:117
void write_analog(const std::string &pin, int value)
Writes the value to the analog writer of the board.
Definition board.hpp:174
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.
Definition board.hpp:203
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 frequenc...
Definition board.hpp:144
bool get_gpio(const std::string &pin)
Gets the high/low state of the given pin on a board.
Definition board.hpp:80
double get_pwm_duty_cycle(const std::string &pin)
Gets the duty cycle of the given pin on a board.
Definition board.hpp:104
virtual std::string name() const
Return the resource's name.
gRPC client implementation of a Board component.
Definition board_client.hpp:22
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.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
void write_analog(const std::string &pin, int value, const ProtoStruct &extra) override
Writes the value to the analog writer of the 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_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 frequenc...
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....
std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra) override
Returns GeometryConfigs associated with the calling board.
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.
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.
bool get_gpio(const std::string &pin, const ProtoStruct &extra) override
Gets the high/low state of the given pin on a board.
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.
uint64_t get_pwm_frequency(const std::string &pin, const ProtoStruct &extra) override
Gets the PWM frequency of the given pin on a board.
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 d...
gRPC client implementation for a robot.
A board's digital interrupt.
Represents the response received when reading the registered analog to digital converter (ADC)....
Definition board.hpp:36