Viam C++ SDK current
Loading...
Searching...
No Matches
servo.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <viam/sdk/common/proto_value.hpp>
7#include <viam/sdk/common/utils.hpp>
8#include <viam/sdk/config/resource.hpp>
9#include <viam/sdk/resource/stoppable.hpp>
10
11namespace viam {
12namespace sdk {
13
15
21class Servo : public Component, public Stoppable {
22 public:
25 typedef uint32_t position;
26
27 API api() const override;
28
31 inline void move(uint32_t angle_deg) {
32 return move(angle_deg, {});
33 }
34
38 virtual void move(uint32_t angle_deg, const ProtoStruct& extra) = 0;
39
43 return get_position({});
44 }
45
49 virtual position get_position(const ProtoStruct& extra) = 0;
50
52 virtual bool is_moving() = 0;
53
56 virtual ProtoStruct get_status() = 0;
57
61 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
62
65 inline std::vector<GeometryConfig> get_geometries() {
66 return get_geometries({});
67 }
68
72 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
73
74 protected:
75 explicit Servo(std::string name) : Component(std::move(name)) {}
76};
77
78template <>
80 static API api();
81};
82
83} // namespace sdk
84} // namespace viam
Definition resource_api.hpp:21
Definition component.hpp:10
virtual std::string name() const
Return the resource's name.
Definition servo.hpp:21
virtual ProtoStruct get_status()=0
Get the status of the servo.
virtual ProtoStruct do_command(const ProtoStruct &command)=0
Send/receive arbitrary commands to the resource.
API api() const override
Returns the API associated with a particular resource.
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling servo.
Definition servo.hpp:65
void move(uint32_t angle_deg)
Move the servo to the provided angle.
Definition servo.hpp:31
virtual position get_position(const ProtoStruct &extra)=0
Reports the position of the robot's servo relative to its zero position.
virtual bool is_moving()=0
Reports if a component is in motion.
position get_position()
Get the current angle (degrees) of the servo.
Definition servo.hpp:42
virtual void move(uint32_t angle_deg, const ProtoStruct &extra)=0
Move the servo to the provided angle.
virtual std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra)=0
Returns GeometryConfigs associated with the calling servo.
Definition stoppable.hpp:8
Current position of the motor relative to its home.
Definition resource_api.hpp:46