GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
map_renderer.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
8#include "map_renderer.h"
9
10#include <Dxlib.h>
11
12#include "dxlib_util.h"
13#include "loop_util.h"
14
15namespace designlab
16{
17
19 color_gray_(GetColor(180, 80, 80)),
20 color_light_gray_(GetColor(200, 160, 160)),
21 color_dark_gray_(GetColor(40, 40, 40)),
22 cube_size_(20.f)
23{
24}
25
27{
28 hexapod_pos_ = pos.center_of_mass_global_coord;
29
30 divided_map_.Init(map_, hexapod_pos_);
31}
32
34{
35 map_ = map;
36
37 divided_map_.Init(map_, hexapod_pos_);
38}
39
40
42{
45
46 const size_t map_point_size = map_.GetMapPointSize(); // マップの点の数.
47
48 for (size_t i = 0; i < map_point_size; i++)
49 {
50 DrawCube3DWithTopPos(ConvertToDxlibVec(map_.GetMapPoint(i)), cube_size_, color_dark_gray_);
51 }
52
53 for (const auto& [i, j] : DoubleIntRange(30, 30))
54 {
55 for (int k = 0; k < divided_map_.GetPointNum(i, j); k++)
56 {
57 DrawCube3DWithTopPos(
58 ConvertToDxlibVec(divided_map_.GetPointPos(i, j, k)),
59 cube_size_,
60 (i + j) % 2 == 0 ? color_light_gray_ : color_gray_);
61 }
62
63 }
64}
65
66} // namespace designlab
Vector3 GetPointPos(int x_index, int y_index, int divided_map_index) const
格子状に切り分けられたマップから,脚設置可能点の実際の座標を取得する. 範囲外の値を指定した場合は,(0,0,0)を返す.
void Init(const MapState &map_state, const Vector3 global_robot_com)
マップのデータを初期化する. ロボットの重心座標を中心にマップのデータを格子状に分割し, その中に存在する脚設置可能点を集める.
int GetPointNum(int x_index, int y_index) const
格子状に切り分けられたマップから,脚設置可能点の数を取得する. 範囲外の値を指定した場合は,0を返す.
void SetNode(const RobotStateNode &pos) override
ロボットの重心のグローバル座標を設定する. DividedMap はロボットの重心を中心にしているので, ロボットの重心のグローバル座標を設定する必要がある. 代入と同時に DividedMap...
void Draw() const override
マップの描画を行う.
void SetMapState(const MapState &map)
マップの状態を設定する.代入と同時に DividedMap も更新される.
マップを表すクラス.
Definition map_state.h:32
size_t GetMapPointSize() const noexcept
脚設置可能点の総数を返す.
Definition map_state.h:53
Vector3 GetMapPoint(const size_t index) const noexcept
脚設置可能点の座標を返す.
Definition map_state.h:44
void DrawCube3DWithTopPos(const VECTOR &top_pos, const float side_len, const unsigned int color)
3D空間に立方体を描画する.立方体の上面の中心の座標から描画する.
VECTOR ConvertToDxlibVec(const Vector3 &vec)
Dxlibの座標を示すVECTORと,このプログラムで使用しているVectorを変換する. ロボット座標系は右手座標系, Dxlibは左手座標系(工学は右手・ゲームライブラリは左手が多い)なのでyを...
Definition dxlib_util.h:35
グラフ構造のためのノード(頂点).旧名 LNODE
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM