8 #ifndef CscJacobianInverseKinematic_h
9 #define CscJacobianInverseKinematic_h
11 #include "../Simulator/CscEnvironmentSimulator.h"
15 #include <bullet/Bullet3Common/b3AlignedObjectArray.h>
16 #include <bullet/ThirdPartyLibs/BussIK/Jacobian.h>
17 #include <bullet/ThirdPartyLibs/BussIK/Node.h>
18 #include <bullet/ThirdPartyLibs/BussIK/Tree.h>
19 #include <bullet/ThirdPartyLibs/BussIK/VectorRn.h>
23 #define RADIAN(X) ((X) * RadiansToDegrees)
24 #define MAX_NUM_EFFECT 100
25 #define PROJECTION_DISTANCE 5.0f
26 #define MAX_TIME_FOR_RESET_TARGETS_IN_MS 1000
43 const int stationaryPivotId;
44 const int memberToMoveId;
46 optional<CscPoint3d *> orientationTarget;
48 TargetIKParams(
int stationaryPivotId,
int memberToMoveId,
CscPoint3d *targetToReach, optional<CscPoint3d *> orientationTarget = nullopt);
49 const int getStationaryPivotId()
const;
50 const int getMemberToMoveId()
const;
57 CscJacobianInverseKinematic(
CscEnvironmentSimulator *env,
float maxHorizontalDistance,
float maxVerticalDistance,
float maxDepthDistance,
CscPoint3d *offsetCenter,
CscState *beginState,
const CscEntityModel *entityModel, vector<TargetIKParams *> targets, map<int, CscPoint3d *> ¢erOfMassOfAllMemberByMemberId,
bool debugWithBox =
false,
bool constraintOnDistance =
false, vector<int> pivotIdToIgnore = vector<int>());
66 void changeTargets(vector<TargetIKParams *> newTargets,
bool relativeValues =
false);
68 void computeRandomly();
69 double getDistanceFromTarget();
70 map<int, float> getResult()
const;
71 vector<vector<int>> getPivotIdPaths()
const;
72 vector<TargetIKParams *> getTargets()
const;
73 void updateThetasRandomly();
77 const float targetPrecision = 1.5f;
96 void changeTargetsWithCenterOfMass(
const bool applyDimensionXYZ[3], vector<int> idTargetsToChange);
101 b3AlignedObjectArray<Node *> ikNodes;
103 Jacobian *ikJacobian =
nullptr;
104 int sleepCounter = 0;
106 const int sleepsPerStep = 100;
107 float offsetX = 1505;
109 float offsetZ = 1500;
111 float maxHorizontalDistance;
112 float maxVerticalDistance;
113 float maxDepthDistance;
117 vector<vector<int>> pivotIdPaths;
120 int countForMethod = 0;
121 vector<TargetIKParams *> targets;
122 vector<TargetIKParams *> lastTargetsValid;
124 bool constraintOnDistance;
125 map<int, CscPoint3d *> initCenterOfMassOfAllMemberByMemberId;
127 map<int, float> result;
128 vector<int> nNodeCenterOfMass;
129 map<int, int> memberIdFromNode;
132 vector<string> objectsId;
135 unsigned long long timeForResetTargets;
136 vector<int> pivotIdToIgnore;
137 bool computeEnable =
true;
159 Tree createTreePivots(
bool centerOfMass =
true);
168 vector<int> createPivotIdPath(
int stationaryPivotId,
int memberToMoveId);
181 void fillTreePivotId(vector<int> &treeToFill,
int pivotId,
int endId,
const map<int, int> &memberAIdByPivotId,
const map<int, int> &memberBIdByPivotId,
const vector<const CscMemberJoint *> *pivots,
int memberId);
210 Tree addNodeCenterOfMass(
int nbTarget,
int indexPivotIdPaths,
int ikNodesSizeWithoutCenterOfMass,
int nbNodes, Tree ¤tTree);