tinyrobotics
Loading...
Searching...
No Matches
inversekinematics.hpp
Go to the documentation of this file.
1#ifndef TR_INVERSEKINEMATICS_HPP
2#define TR_INVERSEKINEMATICS_HPP
3
4#include <Eigen/Core>
5#include <Eigen/Geometry>
6#include <nlopt.hpp>
7#include <unsupported/Eigen/AutoDiff>
8
9#include "kinematics.hpp"
10#include "math.hpp"
11#include "model.hpp"
12
16namespace tinyrobotics {
17
25 template <typename Scalar, int n>
26 inline void eigen_to_nlopt(const Eigen::Matrix<Scalar, n, 1>& eigen_vec, std::vector<Scalar>& nlopt_vec) {
27 // Use Eigen::Map to create a view of the std::vector data
28 Eigen::Map<Eigen::Matrix<Scalar, n, 1>> nlopt_eigen_vec(nlopt_vec.data(), n);
29
30 // Copy the data from the Eigen vector to the std::vector view
31 nlopt_eigen_vec = eigen_vec;
32 }
33
41 template <typename Scalar, int n>
42 inline void nlopt_to_eigen(const std::vector<Scalar>& nlopt_vec, Eigen::Matrix<Scalar, n, 1>& eigen_vec) {
43 // Use Eigen::Map to create a view of the std::vector data
44 const Eigen::Map<const Eigen::Matrix<Scalar, n, 1>> nlopt_eigen_vec(nlopt_vec.data(), n);
45
46 // Copy the data from the std::vector view to the Eigen vector
47 eigen_vec = nlopt_eigen_vec;
48 }
49
55 template <typename Scalar, int nv>
57 std::function<Scalar(const Eigen::Matrix<Scalar, nv, 1>&, Eigen::Matrix<Scalar, nv, 1>&, void*)>;
58
69 template <typename Scalar, int nv>
70 inline Scalar eigen_objective_wrapper(unsigned n, const Scalar* x, Scalar* grad, void* data) {
72
73 // Convert input from NLopt format to Eigen format
74 Eigen::Map<const Eigen::Matrix<Scalar, nv, 1>> eigen_x(x, n);
75 Eigen::Matrix<Scalar, nv, 1> eigen_grad = Eigen::Matrix<Scalar, nv, 1>::Zero();
76
77 if (grad) {
78 eigen_grad.resize(n);
79 Eigen::Map<Eigen::Matrix<Scalar, nv, 1>>(grad, n) = eigen_grad;
80 }
81
82 // Call the actual objective function implemented with Eigen
83 Scalar result = obj_fun(eigen_x, eigen_grad, data);
84
85 if (grad) {
86 // Copy the gradient back to NLopt format
87 Eigen::Map<Eigen::Matrix<Scalar, nv, 1>>(grad, n) = eigen_grad;
88 }
89
90 return result;
91 }
92
97
99 NLOPT,
100
103
106
108 BFGS
109 };
110
112 template <typename Scalar, int nq>
115 Scalar tolerance = 1e-6;
116
118 Scalar xtol_rel = 1e-12;
119
121 int max_iterations = 5e3;
122
124 InverseKinematicsMethod method = InverseKinematicsMethod::JACOBIAN;
125
126 // ****************** Jacobian Method options ******************
128 Scalar step_size = 1e-1;
129
130 // ****************** NLopt Method options ******************
132 nlopt::algorithm algorithm = nlopt::LD_SLSQP;
133
135 Eigen::Matrix<Scalar, 6, 6> K = Eigen::Matrix<Scalar, 6, 6>::Identity();
136
138 Eigen::Matrix<Scalar, nq, nq> W = 1e-3 * Eigen::Matrix<Scalar, nq, nq>::Identity();
139
140 // ****************** Levenberg-Marquardt Method options ******************
142 Scalar initial_damping = 1e-2;
143
146
149
150 // ****************** Particle Swarm Optimization Method options ******************
152 int num_particles = 5e2;
153
155 Scalar omega = 1e-1;
156
158 Scalar c1 = 1e-1;
159
161 Scalar c2 = 1e-1;
162
164 Scalar init_position_scale = 1e-1;
165 };
166
178 template <typename Scalar, int nq>
179 Scalar cost(const Eigen::Matrix<Scalar, nq, 1>& q,
180 Model<Scalar, nq>& model,
181 const std::string& target_link_name,
182 const std::string& source_link_name,
183 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
184 const Eigen::Matrix<Scalar, nq, 1>& q0,
185 Eigen::Matrix<Scalar, nq, 1>& gradient,
187
188 // Compute the current pose
189 Eigen::Transform<Scalar, 3, Eigen::Isometry> current_pose =
190 forward_kinematics(model, q, target_link_name, source_link_name);
191
192 // Compute the pose error
193 Eigen::Matrix<Scalar, 6, 1> pose_error = homogeneous_error(current_pose, desired_pose);
194
195 // Compute the cost: q^T*W*q + (k(q) - x*)^TK*(k(q) - x*))), where k(q) is the current pose, x* is the desired
196 // pose, and W and K are the weighting matrices
197 Eigen::Matrix<Scalar, 1, 1> cost =
198 0.5 * pose_error.transpose() * options.K * pose_error + 0.5 * (q - q0).transpose() * options.W * (q - q0);
199
200 // Compute the gradient of the cost function
201 Eigen::Matrix<Scalar, 6, nq> J = jacobian(model, q, target_link_name);
202 gradient = J.transpose() * options.K * pose_error + options.W * (q - q0);
203
204 return cost(0);
205 }
206
218 template <typename Scalar, int nq>
219 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics_nlopt(
220 Model<Scalar, nq>& model,
221 const std::string& target_link_name,
222 const std::string& source_link_name,
223 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
224 const Eigen::Matrix<Scalar, nq, 1> q0,
226 // Create the NLopt optimizer and set the algorithm
227 nlopt::opt opt(options.algorithm, nq);
228
229 // Wrap the objective function in a lambda function
231 [&](const Eigen::Matrix<Scalar, nq, 1>& q, Eigen::Matrix<Scalar, nq, 1>& grad, void* data) -> Scalar {
232 (void) data; // Unused in this case
233
234 // Compute the cost and gradient
235 Eigen::Matrix<Scalar, nq, 1> gradient;
236 Scalar cost_value = 0.0;
237 cost_value = cost(q, model, target_link_name, source_link_name, desired_pose, q0, gradient, options);
238
239 // Pass the gradient to NLopt
240 for (int i = 0; i < nq; ++i) {
241 grad[i] = gradient(i);
242 }
243
244 return cost_value;
245 };
246 // Set the objective function
247 opt.set_min_objective(eigen_objective_wrapper<Scalar, nq>, &obj_fun);
248
249 // Set the optimization tolerances
250 opt.set_xtol_rel(options.xtol_rel);
251 opt.set_ftol_rel(options.tolerance);
252
253 // Set the maximum number of iterations
254 opt.set_maxeval(options.max_iterations);
255
256 // Convert the initial guess to NLopt format
257 std::vector<Scalar> x_initial(nq);
258 eigen_to_nlopt<Scalar, nq>(q0, x_initial);
259
260 // Find the optimal solution
261 Scalar minf;
262 opt.optimize(x_initial, minf);
263
264 // Convert the optimized solution back to an Eigen
265 Eigen::Matrix<Scalar, nq, 1> optimized_solution(nq);
266 nlopt_to_eigen<Scalar, nq>(x_initial, optimized_solution);
267 return optimized_solution;
268 }
269
281 template <typename Scalar, int nq>
282 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics_jacobian(
283 Model<Scalar, nq>& model,
284 const std::string& target_link_name,
285 const std::string& source_link_name,
286 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
287 const Eigen::Matrix<Scalar, nq, 1> q0,
289
290 // Set the initial guess
291 Eigen::Matrix<Scalar, nq, 1> q_current = q0;
292
293 // Iterate until the maximum number of iterations is reached
294 for (int iteration = 0; iteration < options.max_iterations; ++iteration) {
295
296 // Compute the current pose
297 Eigen::Transform<Scalar, 3, Eigen::Isometry> current_pose =
298 forward_kinematics(model, q_current, target_link_name, source_link_name);
299
300 // Compute the pose error vector
301 Eigen::Matrix<Scalar, 6, 1> pose_error = homogeneous_error(current_pose, desired_pose);
302
303 // Check if the error is within tolerance
304 if (pose_error.norm() < options.tolerance) {
305 break;
306 }
307
308 // Compute the Jacobian matrix
309 Eigen::Matrix<Scalar, 6, nq> J = jacobian(model, q_current, target_link_name);
310
311 // Compute the change in configuration
312 Eigen::Matrix<Scalar, nq, 1> delta_q =
313 J.completeOrthogonalDecomposition().pseudoInverse() * (-options.step_size * pose_error);
314
315 // Update the current configuration
316 q_current += delta_q;
317 }
318
319 // Return the final configuration
320 return q_current;
321 }
322
334 template <typename Scalar, int nq>
335 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics_levenberg_marquardt(
336 Model<Scalar, nq>& model,
337 const std::string& target_link_name,
338 const std::string& source_link_name,
339 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
340 const Eigen::Matrix<Scalar, nq, 1> q0,
342
343 // Set the initial guess
344 Eigen::Matrix<Scalar, nq, 1> q_current = q0;
345
346 // Initialize the damping factor
347 Scalar lambda = options.initial_damping;
348
349 // Iterate until the maximum number of iterations is reached
350 for (int iteration = 0; iteration < options.max_iterations; ++iteration) {
351
352 // Compute the current pose
353 Eigen::Transform<Scalar, 3, Eigen::Isometry> current_pose =
354 forward_kinematics(model, q_current, target_link_name, source_link_name);
355
356 // Compute the pose error vector
357 Eigen::Matrix<Scalar, 6, 1> pose_error = homogeneous_error(current_pose, desired_pose);
358
359 // Check if the error is within tolerance
360 if (pose_error.norm() < options.tolerance) {
361 break;
362 }
363
364 // Compute the Jacobian matrix
365 Eigen::Matrix<Scalar, 6, nq> J = jacobian(model, q_current, target_link_name);
366
367 // Compute the Hessian approximation and the gradient
368 Eigen::Matrix<Scalar, nq, nq> H = J.transpose() * J;
369 Eigen::Matrix<Scalar, nq, 1> g = J.transpose() * pose_error;
370
371 // Levenberg-Marquardt update
372 Eigen::Matrix<Scalar, nq, 1> delta_q =
373 (H + lambda * Eigen::Matrix<Scalar, nq, nq>(H.diagonal().asDiagonal())).ldlt().solve(-g);
374
375 // Test the new configuration
376 Eigen::Matrix<Scalar, nq, 1> q_new = q_current + delta_q;
377 Eigen::Transform<Scalar, 3, Eigen::Isometry> new_pose =
378 forward_kinematics(model, q_new, target_link_name, source_link_name);
379
380 // Compute the new error vector
381 Eigen::Matrix<Scalar, 6, 1> new_pose_error;
382 new_pose_error.head(3) = new_pose.translation() - desired_pose.translation();
383 Eigen::AngleAxis<Scalar> new_rot_error(new_pose.rotation().transpose() * desired_pose.rotation());
384 new_pose_error.tail(3) = new_rot_error.angle() * new_rot_error.axis();
385
386 // Check if the new error is smaller than the old error
387 if (new_pose_error.norm() < pose_error.norm()) {
388 // Accept the new configuration
389 q_current = q_new;
390 lambda *= options.damping_decrease_factor;
391 }
392 else {
393 // Reject the new configuration and increase the damping factor
394 lambda *= options.damping_increase_factor;
395 }
396 }
397
398 // Return the final configuration
399 return q_current;
400 }
401
413 template <typename Scalar, int nq>
414 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics_pso(
415 Model<Scalar, nq>& model,
416 const std::string& target_link_name,
417 const std::string& source_link_name,
418 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
419 const Eigen::Matrix<Scalar, nq, 1> q0,
421 // Particle Swarm Optimization parameters
422 int num_particles = options.num_particles;
423 Scalar omega = options.omega;
424 Scalar c1 = options.c1;
425 Scalar c2 = options.c2;
426
427 // Initialize particles and velocities
428 std::vector<Eigen::Matrix<Scalar, nq, 1>> particles(num_particles, q0);
429 std::vector<Eigen::Matrix<Scalar, nq, 1>> velocities(num_particles, Eigen::Matrix<Scalar, nq, 1>::Zero());
430 std::vector<Scalar> fitness_values(num_particles, std::numeric_limits<Scalar>::max());
431 Eigen::Matrix<Scalar, nq, 1> best_global_position = q0;
432 Scalar best_global_fitness = std::numeric_limits<Scalar>::max();
433
434 // Initialize particles
435 for (int i = 0; i < num_particles; ++i) {
436 particles[i] = q0 + options.init_position_scale * Eigen::Matrix<Scalar, nq, 1>::Random();
437 }
438
439 // Main optimization loop
440 for (int iteration = 0; iteration < options.max_iterations; ++iteration) {
441 for (int i = 0; i < num_particles; ++i) {
442 // Evaluate the fitness of the particle
443 Eigen::Transform<Scalar, 3, Eigen::Isometry> current_pose =
444 forward_kinematics(model, particles[i], target_link_name, source_link_name);
445 Scalar fitness_value = homogeneous_error(current_pose, desired_pose).squaredNorm();
446
447 // Update the best position of the particle
448 if (fitness_value < fitness_values[i]) {
449 fitness_values[i] = fitness_value;
450 }
451
452 // Update the best global position
453 if (fitness_value < best_global_fitness) {
454 best_global_fitness = fitness_value;
455 best_global_position = particles[i];
456 }
457 }
458
459 // Update the particles' velocities and positions
460 for (int i = 0; i < num_particles; ++i) {
461 // Update the velocity
462 velocities[i] =
463 omega * velocities[i]
464 + c1 * Eigen::Matrix<Scalar, nq, 1>::Random().cwiseProduct(particles[i] - best_global_position)
465 + c2 * Eigen::Matrix<Scalar, nq, 1>::Random().cwiseProduct(best_global_position - particles[i]);
466
467 // Update the position
468 particles[i] += velocities[i];
469 }
470
471 // Check if the error is within tolerance
472 if (best_global_fitness < options.tolerance) {
473 break;
474 }
475 }
476
477 // Return the best global position
478 return best_global_position;
479 }
480
492 template <typename Scalar, int nq>
493 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics_bfgs(
494 Model<Scalar, nq>& model,
495 const std::string& target_link_name,
496 const std::string& source_link_name,
497 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
498 const Eigen::Matrix<Scalar, nq, 1> q0,
500
501 Eigen::Matrix<Scalar, nq, 1> q = q0;
502 Eigen::Matrix<Scalar, nq, 1> grad;
503 Eigen::Matrix<Scalar, nq, nq> inverse_hessian = Eigen::Matrix<Scalar, nq, nq>::Identity();
504
505 for (int iteration = 0; iteration < options.max_iterations; ++iteration) {
506 // Compute the gradient and cost using the provided cost function
507 Scalar cost_value = cost(q, model, target_link_name, source_link_name, desired_pose, q0, grad, options);
508
509 if (grad.norm() < options.tolerance) {
510 break;
511 }
512
513 Eigen::Matrix<Scalar, nq, 1> direction = -inverse_hessian * grad;
514 Scalar alpha = 1.0;
515 Eigen::Matrix<Scalar, nq, 1> grad_new;
516 Scalar cost_new;
517 // Line search with backtracking
518 do {
519 alpha *= 0.5;
520 Eigen::Matrix<Scalar, nq, 1> q_new = q + alpha * direction;
521 cost_new = cost(q_new, model, target_link_name, source_link_name, desired_pose, q0, grad_new, options);
522 } while (cost_new > cost_value + options.step_size * alpha * grad.dot(direction));
523
524 Eigen::Matrix<Scalar, nq, 1> q_new = q + alpha * direction;
525
526 Eigen::Matrix<Scalar, nq, 1> s = q_new - q;
527 Eigen::Matrix<Scalar, nq, 1> y = grad_new - grad;
528 Scalar rho = 1.0 / y.dot(s);
529
530 Eigen::Matrix<Scalar, nq, nq> I = Eigen::Matrix<Scalar, nq, nq>::Identity();
531 inverse_hessian = (I - rho * s * y.transpose()) * inverse_hessian * (I - rho * y * s.transpose())
532 + rho * s * s.transpose();
533
534 q = q_new;
535 grad = grad_new;
536 }
537
538 return q;
539 }
540
552 template <typename Scalar, int nq>
553 Eigen::Matrix<Scalar, nq, 1> inverse_kinematics(Model<Scalar, nq>& model,
554 const std::string& target_link_name,
555 const std::string& source_link_name,
556 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& desired_pose,
557 const Eigen::Matrix<Scalar, nq, 1> q0,
559 switch (options.method) {
560 case InverseKinematicsMethod::NLOPT:
561 return inverse_kinematics_nlopt(model, target_link_name, source_link_name, desired_pose, q0, options);
562 case InverseKinematicsMethod::JACOBIAN:
563 return inverse_kinematics_jacobian(model,
564 target_link_name,
565 source_link_name,
566 desired_pose,
567 q0,
568 options);
569 case InverseKinematicsMethod::LEVENBERG_MARQUARDT:
571 target_link_name,
572 source_link_name,
573 desired_pose,
574 q0,
575 options);
576 case InverseKinematicsMethod::PARTICLE_SWARM:
577 return inverse_kinematics_pso(model, target_link_name, source_link_name, desired_pose, q0, options);
578 case InverseKinematicsMethod::BFGS:
579 return inverse_kinematics_bfgs(model, target_link_name, source_link_name, desired_pose, q0, options);
580 default: throw std::runtime_error("Unknown inverse kinematics method");
581 }
582 }
583} // namespace tinyrobotics
584#endif
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics_jacobian(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using the Jacobian method.
Definition: inversekinematics.hpp:282
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using user specified method.
Definition: inversekinematics.hpp:553
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics_bfgs(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using Broyden-Fletcher-Goldfarb-Shanno (BFGS)...
Definition: inversekinematics.hpp:493
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics_levenberg_marquardt(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using the Levenberg-Marquardt method.
Definition: inversekinematics.hpp:335
void nlopt_to_eigen(const std::vector< Scalar > &nlopt_vec, Eigen::Matrix< Scalar, n, 1 > &eigen_vec)
Converts an std::vector to an Eigen vector.
Definition: inversekinematics.hpp:42
std::function< Scalar(const Eigen::Matrix< Scalar, nv, 1 > &, Eigen::Matrix< Scalar, nv, 1 > &, void *)> ObjectiveFunction
Type definition for an objective function that takes an Eigen vector as input and returns a scalar va...
Definition: inversekinematics.hpp:57
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics_pso(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using Particle Swarm Optimization.
Definition: inversekinematics.hpp:414
void eigen_to_nlopt(const Eigen::Matrix< Scalar, n, 1 > &eigen_vec, std::vector< Scalar > &nlopt_vec)
Converts an Eigen vector to an std::vector.
Definition: inversekinematics.hpp:26
Scalar cost(const Eigen::Matrix< Scalar, nq, 1 > &q, Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > &q0, Eigen::Matrix< Scalar, nq, 1 > &gradient, const InverseKinematicsOptions< Scalar, nq > &options)
Cost function for general inverse kinematics with analytical jacobian.
Definition: inversekinematics.hpp:179
InverseKinematicsMethod
Solver methods for inverse kinematics.
Definition: inversekinematics.hpp:94
@ LEVENBERG_MARQUARDT
Levenberg-Marquardt method.
@ PARTICLE_SWARM
Particle swarm optimization method.
Scalar eigen_objective_wrapper(unsigned n, const Scalar *x, Scalar *grad, void *data)
Wrapper function that converts input and output between NLopt and Eigen formats for an objective func...
Definition: inversekinematics.hpp:70
Eigen::Matrix< Scalar, nq, 1 > inverse_kinematics_nlopt(Model< Scalar, nq > &model, const std::string &target_link_name, const std::string &source_link_name, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &desired_pose, const Eigen::Matrix< Scalar, nq, 1 > q0, const InverseKinematicsOptions< Scalar, nq > &options)
Solves the inverse kinematics problem between two links using NLopt.
Definition: inversekinematics.hpp:219
Contains functions for computing various kinematic quantities of a tinyrobotics model.
Eigen::Matrix< Scalar, 6, nq > jacobian(Model< Scalar, nq > &model, const Eigen::Matrix< Scalar, nq, 1 > &q, const TargetLink &target_link)
Computes the geometric jacobian of the target link from the base link, in the base link frame.
Definition: kinematics.hpp:175
std::vector< Eigen::Transform< Scalar, 3, Eigen::Isometry > > forward_kinematics(Model< Scalar, nq > &model, const Eigen::Matrix< Scalar, nq, 1 > &q)
Computes the transform to all the links in the tinyrobotics model.
Definition: kinematics.hpp:47
Contains various math related functions.
Eigen::Matrix< Scalar, 6, 1 > homogeneous_error(const Eigen::Transform< Scalar, 3, Eigen::Isometry > &H1, const Eigen::Transform< Scalar, 3, Eigen::Isometry > &H2)
Computes the error between two homogeneous transformation matrices.
Definition: math.hpp:132
Contains struct for representing a tinyrobotics model.
Options for inverse kinematics solver.
Definition: inversekinematics.hpp:113
Scalar init_position_scale
Scale for initializing particle positions around the initial guess.
Definition: inversekinematics.hpp:164
InverseKinematicsMethod method
Inverse kinematics solver method.
Definition: inversekinematics.hpp:124
Eigen::Matrix< Scalar, nq, nq > W
Weighting matrix for joint displacement from initial configuration.
Definition: inversekinematics.hpp:138
nlopt::algorithm algorithm
NLopt optimization algorithm to use.
Definition: inversekinematics.hpp:132
int max_iterations
Maximum number of iterations for optimization.
Definition: inversekinematics.hpp:121
Scalar xtol_rel
Relative tolerance for NLopt optimization variables.
Definition: inversekinematics.hpp:118
Scalar damping_decrease_factor
Damping decrease factor for Levenberg-Marquardt.
Definition: inversekinematics.hpp:145
Scalar damping_increase_factor
Damping increase factor for Levenberg-Marquardt.
Definition: inversekinematics.hpp:148
Scalar c1
Cognitive weight (c1) for updating particle velocities.
Definition: inversekinematics.hpp:158
Scalar initial_damping
Inital damping factor for Levenberg-Marquardt.
Definition: inversekinematics.hpp:142
int num_particles
Number of particles in the swarm.
Definition: inversekinematics.hpp:152
Scalar omega
Inertia weight (omega) for updating particle velocities.
Definition: inversekinematics.hpp:155
Scalar tolerance
Relative tolerance for cost function value.
Definition: inversekinematics.hpp:115
Scalar step_size
Step size.
Definition: inversekinematics.hpp:128
Eigen::Matrix< Scalar, 6, 6 > K
Weighting matrix for pose error.
Definition: inversekinematics.hpp:135
Scalar c2
Social weight (c2) for updating particle velocities.
Definition: inversekinematics.hpp:161
A tinyrobotics model.
Definition: model.hpp:25