Viam C++ SDK current
Loading...
Searching...
No Matches
servo_client.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <grpcpp/channel.h>
7
8#include <viam/api/component/servo/v1/servo.grpc.pb.h>
9
11#include <viam/sdk/config/resource.hpp>
13
14namespace viam {
15namespace sdk {
16namespace impl {
17
21class ServoClient : public Servo {
22 public:
23 using interface_type = Servo;
24 ServoClient(std::string name, std::shared_ptr<grpc::Channel> channel);
25 void move(uint32_t angle_deg, const ProtoStruct& extra) override;
26 position get_position(const ProtoStruct& extra) override;
27 void stop(const ProtoStruct& extra) override;
28 bool is_moving() override;
29 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
30 ProtoStruct do_command(const ProtoStruct& command) override;
31
34 using Servo::move;
35 using Servo::stop;
36
37 using StubType = viam::component::servo::v1::ServoService::StubInterface;
38 std::unique_ptr<StubType> stub_;
39 std::shared_ptr<grpc::Channel> channel_;
40};
41
42} // namespace impl
43} // namespace sdk
44} // namespace viam
virtual std::string name() const
Return the resource's name.
Definition servo.hpp:21
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling servo.
Definition servo.hpp:61
void move(uint32_t angle_deg)
Move the servo to the provided angle.
Definition servo.hpp:31
position get_position()
Get the current angle (degrees) of the servo.
Definition servo.hpp:42
void stop()
Stops a resource from running.
Definition stoppable.hpp:16
gRPC client implementation of a Servo component.
Definition servo_client.hpp:21
position get_position(const ProtoStruct &extra) override
Reports the position of the robot's servo relative to its zero position.
bool is_moving() override
Reports if a component is in motion.
void move(uint32_t angle_deg, const ProtoStruct &extra) override
Move the servo to the provided angle.
std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra) override
Returns GeometryConfigs associated with the calling servo.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
void stop(const ProtoStruct &extra) override
Stops a resource from running.
gRPC client implementation for a robot.
Defines a Servo component.
Current position of the motor relative to its home.