plcopen 0.22.0
载入中...
搜索中...
未找到
group_window.h
浏览该文件的文档.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <memory>
7
8#include "geom/geometry.h"
9#include "otg/profile1d.h"
10#include "rt/error.h"
11#include "rt/static_vector.h"
12
13// A5 joint-space look-ahead window state (KB-032 and later Part 4 reuse).
14//
15// This is the second AxisGroup split cluster. It owns only the fixed-capacity
16// preplanned window and its lifecycle state. AxisGroup deliberately keeps the
17// shared command queue, group status/error state and direct-command completion
18// points because those coordinate the other motion domains as well.
19
20namespace plcopen::core::axis
21{
22
23class AxisGroup;
24
25template <std::size_t MaxAxes>
27{
28 friend class AxisGroup;
29
30 static constexpr std::size_t BlendTableSize = 33;
31 static constexpr std::size_t Capacity = 64;
32
33 struct Node
34 {
35 bool has_curve = false;
36 std::array<std::array<double, MaxAxes>, 6> ctrl{};
37 std::array<double, BlendTableSize> cumulative{};
38 double curve_length = 0.0;
39 double corner_cap = 0.0;
40 double curve_velocity = 0.0;
41 std::int64_t curve_cycles = 0;
42 };
43
44 enum class Kind
45 {
46 line,
47 direct_line,
48 arc,
49 };
50
51 struct Segment
52 {
53 Kind kind = Kind::line;
54 std::array<double, MaxAxes> entry{};
55 std::array<double, MaxAxes> dir{};
56 std::array<double, MaxAxes> target{};
57 double full_length = 0.0;
58 double trim_in = 0.0;
59 double trim_out = 0.0;
60 geom::ArcSegment arc_geom{};
61 otg::Limits1D limits{};
62 std::uint32_t command_id = 0;
63 double entry_velocity = 0.0;
64 double exit_velocity = 0.0;
65 otg::Profile1D profile{};
66 Node node{};
67
68 double line_length() const
69 {
70 const double length = full_length - trim_in - trim_out;
71 return length > 0.0 ? length : 0.0;
72 }
73 };
74
75 class Storage
76 {
77 public:
78 Storage()
79 : data_(new rt::StaticVector<Segment, Capacity>())
80 {
81 }
82
83 bool empty() const { return data_->empty(); }
84 std::size_t size() const { return data_->size(); }
85 Segment &operator[](std::size_t index) { return (*data_)[index]; }
86 const Segment &operator[](std::size_t index) const { return (*data_)[index]; }
87 rt::ErrorCode push_back(const Segment &value) { return data_->push_back(value); }
88 void pop_back() { data_->pop_back(); }
89 void clear() { data_->clear(); }
90
91 private:
92 std::unique_ptr<rt::StaticVector<Segment, Capacity>> data_;
93 };
94
95 Storage segments_{};
96 otg::Profile1D stop_profile_{};
97 otg::State1D seed_state_{};
98 std::size_t depth_ = Capacity;
99 std::size_t index_ = 0;
100 std::int64_t tick_ = 0;
101 double stop_origin_ = 0.0;
102 bool active_ = false;
103 bool in_curve_ = false;
104 bool stopping_ = false;
105 bool override_paused_ = false;
106};
107
108} // namespace plcopen::core::axis