11static constexpr float link_0_length = 0.048;
12static constexpr float link_1_length = 0.048;
13static constexpr float link_2_length = 0.032;
16static constexpr float transmission_0 = -1.f / 4.f;
17static constexpr float transmission_1 = -1.f / 4.f;
18static constexpr float transmission_2 = -3.f / 8.f;
53static constexpr float motor_torque_limit = 5.0f;
67static constexpr Limits<float> joint_0_vel_limits{-10.0, 10.0};
68static constexpr Limits<float> joint_1_vel_limits{-10.0, 10.0};
75 const auto theta_0 = joint_angles.at(0);
76 const auto theta_1 = joint_angles.at(1);
77 const auto theta_2 = joint_angles.at(2);
79 const float xe = link_0_length * cos(theta_0) + link_1_length * cos(theta_0 + theta_1) +
80 link_2_length * cos(theta_0 + theta_1 + theta_2);
82 const float ze = -link_0_length * sin(theta_0) - link_1_length * sin(theta_0 + theta_1) -
83 link_2_length * sin(theta_0 + theta_1 + theta_2);
93 const auto radius =
pos.at(0) *
pos.at(0) +
pos.at(2) *
pos.at(2);
94 const auto theta_1 = (radius - link_0_length * link_0_length - link_1_length * link_1_length) /
95 (2 * link_0_length * link_1_length);
96 const auto theta_0 = std::atan2(
pos.at(2),
pos.at(0)) -
98 link_1_length * sin(theta_1),
99 link_0_length + link_1_length * cos(theta_1));
101 return {-theta_0, -theta_1};
106 const auto phi_0 = motor_vars.at(0);
107 const auto phi_1 = motor_vars.at(1);
108 const auto theta_0 = phi_0 * transmission_0;
109 const auto theta_1 = phi_1 * transmission_1 - theta_0;
110 const auto theta_2 = 0.0f;
111 return {theta_0, theta_1, theta_2};
116 const auto theta_0 = joint_vars.at(0);
117 const auto theta_1 = joint_vars.at(1);
120 const auto phi_0 = theta_0 / transmission_0;
121 const auto phi_1 = theta_1 / transmission_1 + theta_0 / transmission_1;
122 return {phi_0, phi_1};
145 const auto tau_0 = joint_taus.at(0);
146 const auto tau_1 = joint_taus.at(1);
147 const auto tau_2 = joint_taus.at(2);
149 const auto torque_0 = tau_0 * transmission_0 - tau_1 * transmission_0;
150 const auto torque_1 = tau_1 * transmission_1 + tau_2 * transmission_2;
152 return {torque_0, torque_1};
157 const auto torque_0 = motor_torques.at(0);
158 const auto torque_1 = motor_torques.at(1);
160 const auto tau_0 = torque_0 / transmission_0 + torque_1 / transmission_1;
161 const auto tau_1 = torque_1 / transmission_1;
163 return {tau_0, tau_1};
168 const auto theta_0 = joint_angles.at(0);
169 const auto theta_1 = joint_angles.at(1);
170 const auto theta_2 = joint_angles.at(2);
176 0) = -link_0_length * sin(theta_0) - link_1_length * sin(theta_0 + theta_1) - link_2_length * sin(theta_0 + theta_1 + theta_2);
177 J_s(0, 1) = -link_1_length * sin(theta_0 + theta_1) - link_2_length * sin(
178 theta_0 + theta_1 + theta_2);
179 J_s(0, 2) = -link_2_length * sin(theta_0 + theta_1 + theta_2);
182 0) = -link_0_length * cos(theta_0) - link_1_length * cos(theta_0 + theta_1) - link_2_length * cos(theta_0 + theta_1 + theta_2);
183 J_s(1, 1) = -link_1_length * cos(theta_0 + theta_1) - link_2_length * cos(
184 theta_0 + theta_1 + theta_2);
185 J_s(1, 2) = -link_2_length * cos(theta_0 + theta_1 + theta_2);
192 static constexpr float discouraging_stiffness = 0.175f;
197 return {joint_0_d_t, joint_1_d_t, 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 > joint_thetas
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)
Limit struct to store upper and lower limits.
T over_limits(T compare) const