Skip to content

Fix fourbarlinkage #1837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace transmission_interface
* </td>
* <td>
* \f{eqnarray*}{
* \tau_{j_1} & = & n_{j_1} n_{a_1} \tau_{a_1} \\
* \tau_{j_2} & = & n_{j_2} (n_{a_2} \tau_{a_2} - n_{j_1} n_{a_1} \tau_{a_1})
* \tau_{j_1} & = & n_{j_1} n_{a_1} \tau_{a_1} + n_{a_2} \tau_{a_2} \\
* \tau_{j_2} & = & n_{j_2} n_{a_2} \tau_{a_2}2}
* \f}
* </td>
* <td>
Expand All @@ -67,8 +67,8 @@ namespace transmission_interface
* </td>
* <td>
* \f{eqnarray*}{
* \tau_{a_1} & = & \tau_{j_1} / (n_{j_1} n_{a_1}) \\
* \tau_{a_2} & = & \frac{ \tau_{j_1} + \tau_{j_2} / n_{j_2} }{ n_{a_2} }
* \tau_{a_1} & = & \frac{\tau_{j_1} - \tau_{j_2}/n_{j_2}} {n_{j_1} n_{a_1}} \\
* \tau_{a_2} & = & \frac{\tau_{j_2}} {n_{j_2} n_{a_2}}
* \f}
* </td>
* <td>
Expand Down Expand Up @@ -287,9 +287,8 @@ inline void FourBarLinkageTransmission::actuator_to_joint()
{
assert(act_eff[0] && act_eff[1] && joint_eff[0] && joint_eff[1]);

joint_eff[0].set_value(jr[0] * act_eff[0].get_value() * ar[0]);
joint_eff[1].set_value(
jr[1] * (act_eff[1].get_value() * ar[1] - jr[0] * act_eff[0].get_value() * ar[0]));
joint_eff[0].set_value(jr[0] * act_eff[0].get_value() * ar[0] + act_eff[1].get_value() * ar[1]);
joint_eff[1].set_value(jr[1] * act_eff[1].get_value() * ar[1]);
}
}

Expand Down Expand Up @@ -329,8 +328,8 @@ inline void FourBarLinkageTransmission::joint_to_actuator()
{
assert(act_eff[0] && act_eff[1] && joint_eff[0] && joint_eff[1]);

act_eff[0].set_value(joint_eff[0].get_value() / (ar[0] * jr[0]));
act_eff[1].set_value((joint_eff[0].get_value() + joint_eff[1].get_value() / jr[1]) / ar[1]);
act_eff[0].set_value((joint_eff[0].get_value() - joint_eff[1].get_value() / jr[1]) / (jr[0] * ar[0]));
act_eff[1].set_value(joint_eff[1].get_value() / (ar[1] * jr[1]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ TEST_F(WhiteBoxTest, MoveFirstJointOnly)
auto joint2_handle = JointHandle("joint2", HW_IF_EFFORT, j_vec[1]);
trans.configure({joint1_handle, joint2_handle}, {a1_handle, a2_handle});
trans.actuator_to_joint();
EXPECT_THAT(100.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(0.0, DoubleNear(j_val[1], EPS));
EXPECT_THAT(200.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(200.0, DoubleNear(j_val[1], EPS));
}

// Velocity interface
Expand Down Expand Up @@ -349,7 +349,7 @@ TEST_F(WhiteBoxTest, MoveSecondJointOnly)
auto joint2_handle = JointHandle("joint2", HW_IF_EFFORT, j_vec[1]);
trans.configure({joint1_handle, joint2_handle}, {a1_handle, a2_handle});
trans.actuator_to_joint();
EXPECT_THAT(0.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(100.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(200.0, DoubleNear(j_val[1], EPS));
}

Expand Down Expand Up @@ -402,8 +402,8 @@ TEST_F(WhiteBoxTest, MoveBothJoints)
auto joint2_handle = JointHandle("joint2", HW_IF_EFFORT, j_vec[1]);
trans.configure({joint1_handle, joint2_handle}, {a1_handle, a2_handle});
trans.actuator_to_joint();
EXPECT_THAT(-60.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(-160.0, DoubleNear(j_val[1], EPS));
EXPECT_THAT(-160.0, DoubleNear(j_val[0], EPS));
EXPECT_THAT(-400.0, DoubleNear(j_val[1], EPS));
}

// Velocity interface
Expand Down