11static constexpr float link_0_length = 0.0726;
12static constexpr float link_1_length = 0.0942;
15static constexpr float operator_x_offset = 0.0f;
16static constexpr float operator_y_offset = 0.0f;
17static constexpr float operator_z_offset = -0.05f;
27static constexpr float transmission_0 = -1.f / 7.f;
28static constexpr float transmission_1 = -1.f / 3.f;
32static constexpr Limits<float> joint_0_limits{-18.719, 107.719};
56static constexpr Limits<float> joint_0_vel_limits{-10.0, 10.0};
57static constexpr Limits<float> joint_1_vel_limits{-10.0, 10.0};
59static constexpr float motor_torque_limit = 5.0f;
66 const auto theta_0 = joint_angles.at(0);
67 const auto theta_1 = joint_angles.at(1);
69 const auto theta_0_hat = theta_0 - fk_joint_0_offset;
70 const auto theta_1_hat = theta_1 - fk_joint_1_offset;
72 const float xe = link_0_length * cos(theta_0_hat) + link_1_length * cos(theta_0_hat + theta_1_hat) - operator_x_offset;
73 const float ye = 0.f - operator_y_offset;
74 const float ze = -link_0_length * sin(theta_0_hat) - link_1_length * sin(theta_0_hat + theta_1_hat) - operator_z_offset;
84 const auto radius =
pos.at(0) *
pos.at(0) +
pos.at(2) *
pos.at(2);
85 const auto theta_1 = (radius - link_0_length * link_0_length - link_1_length * link_1_length) /
86 (2 * link_0_length * link_1_length);
87 const auto theta_0 = std::atan2(
pos.at(2),
pos.at(0)) - std::atan2(
90 link_0_length + link_1_length * cos(theta_1));
92 return {-theta_0 - fk_joint_0_offset, -theta_1 - fk_joint_1_offset};
97 const auto phi_0 = motor_vars.at(0);
98 const auto phi_1 = motor_vars.at(1);
99 const auto theta_0 = phi_0 * transmission_0;
100 const auto theta_1 = phi_1 * transmission_1 - theta_0;
101 return {theta_0, theta_1};
106 const auto theta_0 = joint_vars.at(0);
107 const auto theta_1 = joint_vars.at(1);
109 const auto phi_0 = theta_0 / transmission_0;
110 const auto phi_1 = theta_1 / transmission_1 + theta_0 / transmission_1;
111 return {phi_0, phi_1};
132 const auto tau_0 = joint_taus.at(0);
133 const auto tau_1 = joint_taus.at(1);
135 const auto torque_0 = tau_0 * transmission_0 - tau_1 * transmission_0;
136 const auto torque_1 = tau_1 * transmission_1;
138 return {torque_0, torque_1};
143 const auto torque_0 = motor_torques.at(0);
144 const auto torque_1 = motor_torques.at(1);
146 const auto tau_0 = torque_0 / transmission_0 + torque_1 / transmission_1;
147 const auto tau_1 = torque_1 / transmission_1;
149 return {tau_0, tau_1};
154 const auto theta_0 = joint_angles.at(0);
155 const auto theta_1 = joint_angles.at(1);
157 const auto theta_0_hat = theta_0 - fk_joint_0_offset;
158 const auto theta_1_hat = theta_1 - fk_joint_1_offset;
161 J_s(0, 0) = -link_0_length * sin(theta_0_hat) - link_1_length * sin(theta_0_hat + theta_1_hat);
162 J_s(0, 1) = -link_1_length * sin(theta_0_hat + theta_1_hat);
163 J_s(1, 0) = -link_0_length * cos(theta_0_hat) - link_1_length * cos(theta_0_hat + theta_1_hat);
164 J_s(1, 1) = -link_1_length * cos(theta_0_hat + theta_1_hat);
171 static constexpr float discouraging_stiffness = 0.0f;
constexpr float convert_angular_units(float ang, const AngleUnits curr_unit, const AngleUnits desr_unit)
Converts an angle from one unit to another.
Class that treats a std::vector as a matrix and implements simple operations.
std::vector< float > motors_to_joints(std::vector< float > motor_vars)
std::vector< float > inverse_kinematics(std::vector< float > pos)
Performs inverse kinematics for the haptic finger.
std::vector< float > phi_to_theta(std::vector< float > motor_phis)
std::vector< float > theta_to_phi(std::vector< float > joint_thetas)
std::vector< float > torque_to_tau(std::vector< float > motor_torques)
std::vector< float > joints_to_motors(std::vector< float > joint_vars)
std::vector< float > tau_to_torque(std::vector< float > joint_taus)
std::vector< float > forward_kinematics(std::vector< float > joint_angles)
Performs forward kinematics for the haptic finger.
Matrix spatial_jacobian(std::vector< float > joint_angles)
std::vector< float > soft_limit_torques(std::vector< float > joint_thetas)
std::vector< float > joint_thetas
Limit struct to store upper and lower limits.
T over_limits(T compare) const