Skip to content

Commit

Permalink
avoid case where joints are not populated
Browse files Browse the repository at this point in the history
  • Loading branch information
madan96 committed Dec 22, 2023
1 parent c066cae commit 1791287
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Gen3Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void addGravityCompensation(
{
Eigen::VectorXd q = pinocchio::neutral(model);
// convert ROS joint config to pinocchio config
for (int i = 0; i < model.joints.size(); i++)
for (int i = 0; i < model.nv; i++)
{
int jidx = model.getJointId(model.names[i + 1]);
int qidx = model.idx_qs[jidx];
Expand All @@ -55,7 +55,7 @@ void addGravityCompensation(
Eigen::VectorXd gravity
= pinocchio::computeGeneralizedGravity(model, data, q);
// add gravity compensation torque to base command
for (int i = 0; i < gravity.size(); i++)
for (int i = 0; i < model.nv; i++)
{
command[i] = command[i] + gravity[i];
}
Expand Down

0 comments on commit 1791287

Please sign in to comment.