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 <viam/api/component/servo/v1/servo.grpc.pb.h>
7
9#include <viam/sdk/config/resource.hpp>
11#include <viam/sdk/rpc/dial.hpp>
12
13namespace viam {
14namespace sdk {
15namespace impl {
16
20class ServoClient : public Servo {
21 public:
22 using interface_type = Servo;
23 ServoClient(std::string name, const ViamChannel& channel);
24
25 const ViamChannel& channel() const {
26 return *channel_;
27 }
28 void move(uint32_t angle_deg, const ProtoStruct& extra) override;
29 position get_position(const ProtoStruct& extra) override;
30 void stop(const ProtoStruct& extra) override;
31 bool is_moving() override;
32 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
33 ProtoStruct do_command(const ProtoStruct& command) override;
34
37 using Servo::move;
38 using Servo::stop;
39
40 using StubType = viam::component::servo::v1::ServoService::StubInterface;
41 std::unique_ptr<StubType> stub_;
42 const ViamChannel* channel_;
43};
44
45} // namespace impl
46} // namespace sdk
47} // 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
Definition dial.hpp:25
gRPC client implementation of a Servo component.
Definition servo_client.hpp:20
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.