Viam C++ SDK current
Loading...
Searching...
No Matches
arm_trajectory_validation.hpp
1// components/private/arm_trajectory_validation.hpp
2//
3// Invariant checking for streamed arm trajectories.
4#pragma once
5
6#include <chrono>
7#include <string>
8
9#include <boost/optional.hpp>
10
12
13namespace viam {
14namespace sdk {
15namespace impl {
16
17// Validates the invariants of a streamed joint-space trajectory as its points
18// arrive. One instance validates one logical stream: feed it each point in wire
19// order via `check()`. On a valid point the running state advances; on a
20// violation the state is left untouched.
21//
22// `check()` reports the offending invariant as a string instead of throwing, and
23// the class pulls in no gRPC types. The only caller today is the server
24// dispatcher, which turns that string into a `grpc::Status` (so it could just as
25// well throw), but keeping it free of gRPC means that if we ever want the client
26// to validate before sending, this drops straight in and raises whatever error
27// the client wants from the same message.
28//
29// Invariants:
30// - the first point of the stream has time zero;
31// - the first point starts from rest, so any velocities it carries are zero;
32// - times strictly increase across the entire stream;
33// - every point carries at least one position;
34// - when constraints are present, velocities carries one entry per position;
35// - when accelerations are present, they carry one entry per velocity.
36//
37// Dimensions are only checked for internal consistency; the trajectory is not
38// validated against the arm's actual degrees of freedom.
40 public:
41 // Returns a description of the first invariant the point violates, or
42 // `boost::none` if the point is valid in sequence.
43 boost::optional<std::string> check(const Arm::trajectory_point& point);
44
45 private:
46 bool seen_first_ = false;
47 std::chrono::microseconds last_time_{};
48};
49
50} // namespace impl
51} // namespace sdk
52} // namespace viam
Defines an Arm component.
Definition arm_trajectory_validation.hpp:39
A single waypoint in a streamed joint-space trajectory.
Definition arm.hpp:129