12#include <magic_enum.hpp>
102 return std::move(res);
107const LegGroundedMap kLegGroundedPatternMap = MakeLegGroundedMap();
110const int kLegGroundedPatternNum =
static_cast<int>(kLegGroundedPatternMap.size());
119bool IsLegPairFree(
int leg_index,
int leg_ground_pattern_index)
127 ::kLegGroundedPatternMap.right.at(leg_ground_pattern_index);
135 if (!leg_ground_pattern[leg_index % HexapodConst::kLegNum] &&
136 !leg_ground_pattern[(leg_index + 1) % HexapodConst::kLegNum])
148std::unordered_map<DiscreteComPos, std::vector<int>> MakeLegGroundedPatternBanList()
150 std::unordered_map<DiscreteComPos, std::vector<int>> res;
156 std::unordered_map<DiscreteComPos, std::vector<int>> ban_leg_index_list;
157 ban_leg_index_list[DiscreteComPos::kFront] = { 0, 4, 5 };
158 ban_leg_index_list[DiscreteComPos::kFrontRight] = { 0, 1, 5 };
159 ban_leg_index_list[DiscreteComPos::kFrontLeft] = { 3, 4, 5 };
160 ban_leg_index_list[DiscreteComPos::kBack] = { 1, 2, 3 };
161 ban_leg_index_list[DiscreteComPos::kBackRight] = { 0, 1, 2 };
162 ban_leg_index_list[DiscreteComPos::kBackLeft] = { 2, 3, 4 };
163 ban_leg_index_list[DiscreteComPos::kCenterBack] = { 0, 2, 4 };
164 ban_leg_index_list[DiscreteComPos::kCenterFront] = { 1, 3, 5 };
172 if (ban_leg_index_list.count(i) == 0) {
continue; }
174 for (
auto& j : ban_leg_index_list[i])
176 for (
int k = 0; k < ::kLegGroundedPatternNum; ++k)
178 if (IsLegPairFree(j, k))
186 return std::move(res);
191std::vector<std::vector<int>> MakeLegGroundedPatternBanListFromLeg()
193 std::vector<std::vector<int>> res;
200 for (
int j = 0; j < ::kLegGroundedPatternNum; ++j)
204 if (::kLegGroundedPatternMap.right.at(j)[i])
211 return std::move(res);
216const std::unordered_map<::designlab::enums::DiscreteComPos, std::vector<int>>
217kLegGroundedPatternBanList = MakeLegGroundedPatternBanList();
220const std::vector<std::vector<int>> kLegGroundedPatternBanListFromLeg =
221MakeLegGroundedPatternBanListFromLeg();
231 return kLegGroundedPatternNum;
235 const int leg_ground_pattern_index)
240 res = ::kLegGroundedPatternMap.right.at(leg_ground_pattern_index);
247 boost::dynamic_bitset<>* output)
249 assert(output !=
nullptr);
255 for (
auto& i : kLegGroundedPatternBanList.at(discrete_com_pos))
257 (*output)[i] =
false;
262 boost::dynamic_bitset<>* output)
264 assert(output !=
nullptr);
271 for (
auto& i : kLegGroundedPatternBanListFromLeg[not_groundable_leg_index])
273 (*output)[i] =
false;
278 int not_lift_leg_index,
279 boost::dynamic_bitset<>* output)
281 assert(output !=
nullptr);
289 for (
auto& i : kLegGroundedPatternBanListFromLeg[not_lift_leg_index])
291 inverse_output[i] =
true;
294 (*output) &= inverse_output;
static constexpr int kLegNum
重心タイプに関する名前空間.Center of Mass Function の略.
void RemoveLegGroundPatternFromCom(enums::DiscreteComPos discrete_com_pos, boost::dynamic_bitset<> *output)
離散化された重心位置から,その重心位置では取り得ない脚接地パターンを falseにする.
LegGroundedMap::value_type LegGroundedMapValue
脚の接地パターンを表すマップの値の型.
int GetLegGroundPatternNum()
脚の接地パターンの総数を返す.
leg_func::LegGroundedBit GetLegGroundedBitFromLegGroundPatternIndex(const int leg_ground_pattern_index)
脚の接地パターンの番号から,その番号に該当する接地パターンを返す.
void RemoveLegGroundPatternFromNotGroundableLeg(int not_groundable_leg_index, boost::dynamic_bitset<> *output)
接地できない脚番号から, その脚が接地できない場合に取り得ない接地パターンを falseにする.
boost::bimaps::bimap< leg_func::LegGroundedBit, int > LegGroundedMap
脚の接地パターンを表す型.leftがビットのデータ,rightが int型の番号. bimaps::bimap は,左右の型の両方からアクセスできる map. key→value,value→key...
void RemoveLegGroundPatternFromNotFreeLeg(int not_lift_leg_index, boost::dynamic_bitset<> *output)
遊脚できない脚番号から, その脚が遊脚できない場合に取り得ない接地パターンを falseにする.
std::bitset< HexapodConst::kLegNum > LegGroundedBit
脚の遊脚・接地を表す型.6bitのビット型.接地が 1 遊脚が 0.