GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
interface_hexapod_joint_calculator.h
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
8#ifndef DESIGNLAB_INTERFACE_HEXAPOD_JOINT_CALCULATOR_H_
9#define DESIGNLAB_INTERFACE_HEXAPOD_JOINT_CALCULATOR_H_
10
11#include <array>
12#include <vector>
13
14#include "robot_state_node.h"
15
16
17namespace designlab
18{
19
24{
29 std::vector<Vector3> joint_pos_leg_coordinate;
30
34 std::vector<float> joint_angle;
35
37 bool is_in_range{ false };
38};
39
40
44{
45public:
46 virtual ~IHexapodJointCalculator() = default;
47
48
56 [[nodiscard]]
57 std::array<HexapodJointState, HexapodConst::kLegNum> CalculateAllJointState(
58 const RobotStateNode& node) const noexcept
59 {
60 std::array<HexapodJointState, HexapodConst::kLegNum> joint_state;
61
62 // 計算を行う.
63 for (int i = 0; i < HexapodConst::kLegNum; i++)
64 {
65 joint_state[i] = CalculateJointState(i, node.leg_pos[i]);
66 }
67
68 return joint_state;
69 }
70
79 [[nodiscard]]
81 const int leg_index, const Vector3& leg_pos) const noexcept = 0;
82
89 [[nodiscard]]
91 const RobotStateNode& node,
92 const std::array<HexapodJointState, HexapodConst::kLegNum>& joint_state)
93 const noexcept
94 {
95 for (int i = 0; i < HexapodConst::kLegNum; i++)
96 {
97 if (!IsValidJointState(i, node.leg_pos[i], joint_state[i]))
98 {
99 return false;
100 }
101 }
102
103 return true;
104 }
105
113 [[nodiscard]]
114 virtual bool IsValidJointState(
115 const int leg_index, const Vector3& leg_pos,
116 const HexapodJointState& joint_state) const noexcept = 0;
117};
118
119} // namespace designlab
120
121
122#endif // DESIGNLAB_INTERFACE_HEXAPOD_JOINT_CALCULATOR_H_
static constexpr int kLegNum
間接角度や角速度を計算する処理のインターフェース.
virtual HexapodJointState CalculateJointState(const int leg_index, const Vector3 &leg_pos) const noexcept=0
指定した脚の関節のグローバル座標と,角度を計算する. 重たいのでグラフ探索や,描画処理中にループで使用することは推奨しない. 間接の可動範囲外まで動いてしまう場合でも,答えを返す. 目標座標...
virtual bool IsValidJointState(const int leg_index, const Vector3 &leg_pos, const HexapodJointState &joint_state) const noexcept=0
指定した脚のHexapodJointStateが正しく計算できているかを調べる. 目標座標に届かない場合や,間接の可動範囲外まで動いてしまう場合, 戻り値は false になる.
std::array< HexapodJointState, HexapodConst::kLegNum > CalculateAllJointState(const RobotStateNode &node) const noexcept
全ての関節のグローバル座標と,角度を計算する. 重たいのでグラフ探索や,描画処理中にループで使用することは推奨しない. 間接の可動範囲外まで動いてしまう場合でも,答えを返す. 目標座標に届か...
virtual ~IHexapodJointCalculator()=default
bool IsValidAllJointState(const RobotStateNode &node, const std::array< HexapodJointState, HexapodConst::kLegNum > &joint_state) const noexcept
HexapodJointStateが正しく計算できているかを調べる. 目標座標に届かない場合や,間接の可動範囲外まで動いてしまう場合, 戻り値は false になる.
ロボットの関節の状態を表す構造体.
bool is_in_range
目標座標に脚が届かないならば false になる.
グラフ構造のためのノード(頂点).旧名 LNODE
3次元の位置ベクトルを表す構造体.