GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
simulation_end_checker_factory.cpp
[詳解]
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
9
10#include <utility>
11
12#include "cassert_define.h"
13#include "math_quaternion.h"
14#include "math_rot_converter.h"
18
19
20namespace designlab
21{
22
23std::unique_ptr<ISimulationEndChecker> SimulationEndCheckerFactory::Create(const SimulationSettingRecord& record)
24{
27
28 if (record.end_check_mode == kGoalTape)
29 {
30 auto simulation_end_checker = std::make_unique<SimulationEndCheckerByGoalTape>(record.goal_tape_position_x);
31
32 return std::move(simulation_end_checker);
33 }
34 else if (record.end_check_mode == kPosture)
35 {
36 EulerXYZ target_euler_rad{
37 ConvertDegToRad(record.target_posture.x_angle),
38 ConvertDegToRad(record.target_posture.y_angle),
39 ConvertDegToRad(record.target_posture.z_angle)
40 };
41
42 auto simulation_end_checker = std::make_unique<SimulationEndCheckerByPosture>(ToQuaternion(target_euler_rad), ConvertDegToRad(record.target_posture_allowable_error_deg));
43
44 return std::move(simulation_end_checker);
45 }
46 else if (record.end_check_mode == kPosition)
47 {
48 const Vector3 goal_position(record.target_position);
49
50 auto simulation_end_checker = std::make_unique<SimulationEndCheckerByPosition>(goal_position, record.target_position_allowable_error);
51
52 return std::move(simulation_end_checker);
53 }
54 else
55 {
56 assert(false);
57 }
58
59 return nullptr;
60}
61
62} // namespace designlab
static std::unique_ptr< ISimulationEndChecker > Create(const SimulationSettingRecord &record)
シミュレーションの終了を判定するクラスを生成する.
constexpr T ConvertDegToRad(const T deg) noexcept
角度を [deg] から [rad] に変換する関数.
Definition math_util.h:126
Quaternion ToQuaternion(const RotationMatrix3x3 &rot)
回転角行列からクォータニオンへの変換.
XYZオイラー角を用いた回転を表す構造体.
Definition math_euler.h:33
float x_angle
X 軸周りの回転 [rad]
Definition math_euler.h:109
float y_angle
Y 軸周りの回転 [rad]
Definition math_euler.h:110
float z_angle
Z 軸周りの回転 [rad]
Definition math_euler.h:111
enums::SimulationEndCheckMode end_check_mode
3次元の位置ベクトルを表す構造体.