Skip to content

Commit d6cf156

Browse files
committed
add angle wrapping to IK
1 parent 80ff3bc commit d6cf156

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

roboticstoolbox/core/ik.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ extern "C"
9191
{
9292
// We have arrived
9393

94+
// wrap q to +- pi
95+
for (int i = 0; i < ets->n; i++)
96+
{
97+
q(i) = std::fmod(q(i), PI);
98+
}
99+
94100
// Check for joint limit violation
95101
if (reject_jl)
96102
{
@@ -107,9 +113,6 @@ extern "C"
107113
// Jacobian Matric J
108114
_ETS_jacob0(ets, q.data(), (double *)NULL, J);
109115

110-
// g = J.T @ We @ e
111-
// robot.q += np.linalg.inv(J.T @ We @ J) @ g
112-
113116
g = J.transpose() * We * e;
114117
Jw = J.transpose() * We * J;
115118

@@ -222,6 +225,12 @@ extern "C"
222225
{
223226
// We have arrived
224227

228+
// wrap q to +- pi
229+
for (int i = 0; i < ets->n; i++)
230+
{
231+
q(i) = std::fmod(q(i), PI);
232+
}
233+
225234
// Check for joint limit violation
226235
if (reject_jl)
227236
{
@@ -339,6 +348,12 @@ extern "C"
339348
{
340349
// We have arrived
341350

351+
// wrap q to +- pi
352+
for (int i = 0; i < ets->n; i++)
353+
{
354+
q(i) = std::fmod(q(i), PI);
355+
}
356+
342357
// Check for joint limit violation
343358
if (reject_jl)
344359
{
@@ -447,6 +462,12 @@ extern "C"
447462
{
448463
// We have arrived
449464

465+
// wrap q to +- pi
466+
for (int i = 0; i < ets->n; i++)
467+
{
468+
q(i) = std::fmod(q(i), PI);
469+
}
470+
450471
// Check for joint limit violation
451472
if (reject_jl)
452473
{
@@ -553,6 +574,12 @@ extern "C"
553574
{
554575
// We have arrived
555576

577+
// wrap q to +- pi
578+
for (int i = 0; i < ets->n; i++)
579+
{
580+
q(i) = std::fmod(q(i), PI);
581+
}
582+
556583
// Check for joint limit violation
557584
if (reject_jl)
558585
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy