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
12#include <viam/sdk/config/resource.hpp>
14
15namespace viam {
16namespace sdk {
17namespace impl {
18
22class ServoClient : public Servo {
23 public:
24 using interface_type = Servo;
25 ServoClient(std::string name, std::shared_ptr<grpc::Channel> channel);
26 void move(uint32_t angle_deg, const AttributeMap& extra) override;
27 position get_position(const AttributeMap& extra) override;
28 void stop(const AttributeMap& extra) override;
29 bool is_moving() override;
30 std::vector<GeometryConfig> get_geometries(const AttributeMap& extra) override;
31 AttributeMap do_command(const AttributeMap& command) override;
32
35 using Servo::move;
36 using Servo::stop;
37
38 using StubType = viam::component::servo::v1::ServoService::StubInterface;
39 std::unique_ptr<StubType> stub_;
40 std::shared_ptr<grpc::Channel> channel_;
41};
42
43} // namespace impl
44} // namespace sdk
45} // namespace viam
virtual std::string name() const
Return the resource's name.
Definition servo.hpp:23
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling servo.
Definition servo.hpp:66
void move(uint32_t angle_deg)
Move the servo to the provided angle.
Definition servo.hpp:36
position get_position()
Get the current angle (degrees) of the servo.
Definition servo.hpp:47
void stop()
Stops a resource from running.
Definition stoppable.hpp:16
gRPC client implementation of a Servo component.
Definition servo_client.hpp:22
void move(uint32_t angle_deg, const AttributeMap &extra) override
Move the servo to the provided angle.
void stop(const AttributeMap &extra) override
Stops a resource from running.
bool is_moving() override
Reports if a component is in motion.
AttributeMap do_command(const AttributeMap &command) override
Send/receive arbitrary commands to the resource.
position get_position(const AttributeMap &extra) override
Reports the position of the robot's servo relative to its zero position.
std::vector< GeometryConfig > get_geometries(const AttributeMap &extra) override
Returns GeometryConfigs associated with the calling servo.
gRPC client implementation for a robot.
Defines a Servo component.
Implements a gRPC server for the Servo component.
Current position of the motor relative to its home.