You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use pinocchio to create procedural animations for a procedural model; but after i create the model i try to do a little test with the pinnochio:Data; and i get an assertion failure that it doesn't go with the model and i don't understand what i'm doing wrong.
This is the code i've made:
using namespace glm;
struct Skeleton // currently this is populated by a mixamo rig so the output should be somewhat similar to making a humanoid model
{
~Skeleton();
vec3 * translation;
quat * rotation;
int * parent; // guaranteed: parent[i] < i
size_t size;
};
template<typename T>
int addJointAndBody(pinocchio::Model & model, int parent, T && joint, pinocchio::SE3 placement, std::string const& name)
{
int idx;
idx = model.addJoint(parent,
std::move(joint),
placement, name);
model.addJointFrame(idx);
model.appendBodyToJoint(idx,
pinocchio::Inertia::Identity(),
pinocchio::SE3::Identity());
model.addBodyFrame(name + "_body", idx);
return idx;
}
pinocchio::Model MakeModel(Skeleton const& skeleton)
{
pinocchio::Model model;
for(auto i = 0u; i < skeleton.size; ++i)
{
vec3 const& t = skeleton.translation[i];
quat const& r = skeleton.rotation[i];
auto translation = pinocchio::SE3::LinearType(t.x, t.y, t.z);
auto rotation = pinocchio::SE3::Quaternion(r.w, r.x, r.y, r.z);
//-1 is no parent; so i guess it should be 0 because thats the root parent in pinocchio?
addJointAndBody(model, skeleton.parent[i]+1,
pinocchio::JointModelRX(), // i dunno what any of these are yet
pinocchio::SE3(rotation, translation),
std::to_string(i));
}
TestModel(model);
return model;
}
void TestModel(pinocchio::Model & model)
{
// test the model!
pinocchio::Data data(model);
Eigen::VectorXd q = pinocchio::randomConfiguration(model);
// everything is inf
std::cout << "q: " << q.transpose() << std::endl;
//assertion failure (this data doesn't belong to the model)
forwardKinematics(model,data,q);
// Print out the placement of each joint of the kinematic tree
for(int joint_id = 0; joint_id < model.njoints; ++joint_id)
std::cout << std::setw(24) << std::left
<< model.names[joint_id] << ": "
<< std::fixed << std::setprecision(2)
<< data.oMi[joint_id].translation().transpose()
<< std::endl;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to use pinocchio to create procedural animations for a procedural model; but after i create the model i try to do a little test with the pinnochio:Data; and i get an assertion failure that it doesn't go with the model and i don't understand what i'm doing wrong.
This is the code i've made:
And as mentioned the output looks like this:
Beta Was this translation helpful? Give feedback.
All reactions