Skip to content
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

[math7] Tidy up unused variables #372

Merged
merged 4 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/ignition/math/Quaternion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace ignition
/// \deprecated Use SetFromAxisAngle(T, T, T, T)
public: void IGN_DEPRECATED(7) Axis(T _ax, T _ay, T _az, T _aa)
{
this->SetFromAxisAngle(_ax, _ay, _ax, _aa);
this->SetFromAxisAngle(_ax, _ay, _az, _aa);
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved
}

/// \brief Set the quaternion from an axis and angle.
Expand Down Expand Up @@ -716,7 +716,6 @@ namespace ignition
/// \param[in] _scale Amount to scale this quaternion
public: void Scale(T _scale)
{
Quaternion<T> b;
Vector3<T> axis;
T angle;

Expand Down
27 changes: 17 additions & 10 deletions src/PID_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ TEST(PidTest, EqualOperatorCornerCase)
EXPECT_DOUBLE_EQ(pid.CmdOffset(), 1.23);
EXPECT_DOUBLE_EQ(pid.Cmd(), 0.0);

#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wself-assign-overloaded"
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved
#endif
pid = pid;
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif

EXPECT_DOUBLE_EQ(pid.PGain(), 1.0);
EXPECT_DOUBLE_EQ(pid.IGain(), 2.1);
Expand Down Expand Up @@ -336,14 +343,14 @@ TEST(PidTest, Pcontrol)
for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i);
EXPECT_DOUBLE_EQ(-d, pid.Update(d, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-d, pid.Update(d, dt));
}

pid.SetPGain(2);
for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i);
EXPECT_DOUBLE_EQ(-2*d, pid.Update(d, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-2*d, pid.Update(d, dt));
}
}

Expand All @@ -356,7 +363,7 @@ TEST(PidTest, Icontrol)
for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i+1);
EXPECT_DOUBLE_EQ(-d, pid.Update(1, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-d, pid.Update(1, dt));
}

pid.SetIGain(2);
Expand All @@ -369,13 +376,13 @@ TEST(PidTest, Icontrol)
}

// confirm that changing gain doesn't cause jumps in integral control
EXPECT_DOUBLE_EQ(-I0, pid.Update(0, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-I0, pid.Update(0, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-I0, pid.Update(0, dt));
EXPECT_DOUBLE_EQ(-I0, pid.Update(0, dt));

for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i+1);
EXPECT_DOUBLE_EQ(-I0-2*d, pid.Update(1, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-I0-2*d, pid.Update(1, dt));
}
}

Expand All @@ -384,19 +391,19 @@ TEST(PidTest, Dcontrol)
{
math::PID pid(0, 0, 1);
std::chrono::duration<double> dt(1);
EXPECT_DOUBLE_EQ(1, pid.Update(-1, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(1, pid.Update(-1, dt));
const int N = 5;
for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i);
EXPECT_DOUBLE_EQ(-1, pid.Update(d, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-1, pid.Update(d, dt));
}

pid.SetDGain(2);
EXPECT_DOUBLE_EQ(10, pid.Update(-1, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(10, pid.Update(-1, dt));
for (int i = 0; i < N; ++i)
{
double d = static_cast<double>(i);
EXPECT_DOUBLE_EQ(-2, pid.Update(d, std::chrono::duration<double>(1)));
EXPECT_DOUBLE_EQ(-2, pid.Update(d, dt));
}
}
15 changes: 15 additions & 0 deletions src/Quaternion_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,21 @@ TEST(QuaternionTest, MathAxis)
{
math::Quaterniond q(IGN_PI*0.1, IGN_PI*0.5, IGN_PI);

#ifndef _WIN32
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
// Deprecated in ign-math7
q.Axis(0, 1, 0, IGN_PI);
EXPECT_EQ(q, math::Quaterniond(6.12303e-17, 0, 1, 0));

// Deprecated in ign-math7
q.Axis(1, 0, 0, IGN_PI);
EXPECT_EQ(q, math::Quaterniond(0, 1, 0, 0));
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif

q.SetFromAxisAngle(0, 1, 0, IGN_PI);
EXPECT_EQ(q, math::Quaterniond(6.12303e-17, 0, 1, 0));

Expand Down
2 changes: 0 additions & 2 deletions src/SphericalCoordinates_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ TEST(SphericalCoordinatesTest, CoordinateTransforms)
ignition::math::Vector3d osrf_e(
-2693701.91434394, -4299942.14687992, 3851691.0393571);
ignition::math::Vector3d goog_s(37.4216719, -122.0821853, 30.0);
ignition::math::Vector3d goog_e(
-2693766.71906146, -4297199.59926038, 3854681.81878812);

// Local tangent plane coordinates (ENU = GLOBAL) coordinates of
// Google when OSRF is taken as the origin:
Expand Down