Skip to content

Commit 5e3456d

Browse files
Jayasinghe, Oshada (Data61, Pullenvale)Jayasinghe, Oshada (Data61, Pullenvale)
authored andcommitted
Removed Eigen namespace from standard includes header
1 parent 57f29c9 commit 5e3456d

File tree

13 files changed

+444
-445
lines changed

13 files changed

+444
-445
lines changed

include/syropod_highlevel_controller/debug_visualiser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DebugVisualiser
3737
/// Publishes visualisation markers which represent the estimated walking plane.
3838
/// @param[in] walk_plane A Vector representing the walk plane
3939
/// @param[in] walk_plane_normal A Vector of the normal to the walk plane
40-
void generateWalkPlane(const Vector3d& walk_plane, const Vector3d& walk_plane_normal);
40+
void generateWalkPlane(const Eigen::Vector3d& walk_plane, const Eigen::Vector3d& walk_plane_normal);
4141

4242
/// Publishes visualisation markers which represent the trajectory of the tip of the input leg.
4343
/// @param[in] leg A pointer to the leg associated with the tip trajectory that is to be published
@@ -84,7 +84,7 @@ class DebugVisualiser
8484

8585
/// Publishes visualisation markers which represent the estimate of the gravitational acceleration vector.
8686
/// @param[in] gravity_estimate An estimate of the gravitational acceleration vector
87-
void generateGravity(const Vector3d& gravity_estimate);
87+
void generateGravity(const Eigen::Vector3d& gravity_estimate);
8888

8989
private:
9090
ros::Publisher robot_model_publisher_; ///< Publisher for topic "/shc/visualisation/robot_model"

include/syropod_highlevel_controller/model.h

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

include/syropod_highlevel_controller/pose.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Pose
2323
/// Pose class constructor.
2424
/// @param[in] position The vector input to be set as the position vector of the pose
2525
/// @param[in] rotation The vector input to be set as the rotation vector of the pose
26-
inline Pose(const Vector3d& position, const Quaterniond& rotation)
26+
inline Pose(const Eigen::Vector3d& position, const Eigen::Quaterniond& rotation)
2727
{
2828
position_ = position;
2929
rotation_ = rotation;
@@ -33,8 +33,8 @@ class Pose
3333
/// @param[in] pose The geometry_msgs/Pose input to be set as the pose
3434
inline Pose(const geometry_msgs::Pose& pose)
3535
{
36-
position_ = Vector3d(pose.position.x, pose.position.y, pose.position.z);
37-
rotation_ = Quaterniond(pose.orientation.w, pose.orientation.x, pose.orientation.y, pose.orientation.z);
36+
position_ = Eigen::Vector3d(pose.position.x, pose.position.y, pose.position.z);
37+
rotation_ = Eigen::Quaterniond(pose.orientation.w, pose.orientation.x, pose.orientation.y, pose.orientation.z);
3838
};
3939

4040
/// Checks for NaN values within pose elements.
@@ -54,8 +54,8 @@ class Pose
5454
/// @param[in] transform The geometry_msgs/Transform input to be used to construct the pose
5555
inline Pose(const geometry_msgs::Transform& transform)
5656
{
57-
position_ = Vector3d(transform.translation.x, transform.translation.y, transform.translation.z);
58-
rotation_ = Quaterniond(transform.rotation.w, transform.rotation.x, transform.rotation.y, transform.rotation.z);
57+
position_ = Eigen::Vector3d(transform.translation.x, transform.translation.y, transform.translation.z);
58+
rotation_ = Eigen::Quaterniond(transform.rotation.w, transform.rotation.x, transform.rotation.y, transform.rotation.z);
5959
};
6060

6161
/// Returns a conversion of this pose object into a geometry_msgs::Pose.
@@ -116,10 +116,10 @@ class Pose
116116
/// @return The transformed pose
117117
inline Pose transform(const geometry_msgs::Transform& transform) const
118118
{
119-
Vector3d position(position_ + Vector3d(transform.translation.x,
119+
Eigen::Vector3d position(position_ + Eigen::Vector3d(transform.translation.x,
120120
transform.translation.y,
121121
transform.translation.z));
122-
Quaterniond rotation(rotation_ * Quaterniond(transform.rotation.w,
122+
Eigen::Quaterniond rotation(rotation_ * Eigen::Quaterniond(transform.rotation.w,
123123
transform.rotation.x,
124124
transform.rotation.y,
125125
transform.rotation.z));
@@ -129,31 +129,31 @@ class Pose
129129
/// Transforms this pose according to an input transformation matrix constructed from DH matrices.
130130
/// @param[in] transform The input transformation matrix
131131
/// @return The transformed pose
132-
inline Pose transform(const Matrix4d& transform) const
132+
inline Pose transform(const Eigen::Matrix4d& transform) const
133133
{
134134
Pose return_pose;
135135
// Position
136-
Vector4d result(position_[0], position_[1], position_[2], 1);
136+
Eigen::Vector4d result(position_[0], position_[1], position_[2], 1);
137137
result = transform * result;
138-
return_pose.position_ = Vector3d(result[0], result[1], result[2]);
138+
return_pose.position_ = Eigen::Vector3d(result[0], result[1], result[2]);
139139
// Orientation
140-
Matrix3d rotation_matrix = transform.block<3, 3>(0, 0);
141-
return_pose.rotation_ = (Quaterniond(rotation_matrix) * rotation_).normalized();
140+
Eigen::Matrix3d rotation_matrix = transform.block<3, 3>(0, 0);
141+
return_pose.rotation_ = (Eigen::Quaterniond(rotation_matrix) * rotation_).normalized();
142142
return return_pose;
143143
}
144144

145145
/// Transforms an input vector into the reference frame of this pose.
146146
/// @param[in] vec The input vector to be transformed into this pose's reference frame
147147
/// @return The transformed vector
148-
inline Vector3d transformVector(const Vector3d& vec) const
148+
inline Eigen::Vector3d transformVector(const Eigen::Vector3d& vec) const
149149
{
150150
return position_ + rotation_._transformVector(vec);
151151
};
152152

153153
/// Transforms an input vector from the reference frame of this pose.
154154
/// @param[in] vec The input vector to be transformed from this pose's reference frame
155155
/// @return The inversly transformed vector
156-
inline Vector3d inverseTransformVector(const Vector3d& vec) const
156+
inline Eigen::Vector3d inverseTransformVector(const Eigen::Vector3d& vec) const
157157
{
158158
return (~*this).transformVector(vec);
159159
};
@@ -186,16 +186,16 @@ class Pose
186186
/// @return The resultant interpolated pose
187187
inline Pose interpolate (const double& control_input, const Pose& target_pose)
188188
{
189-
Vector3d position = control_input * target_pose.position_ + (1.0 - control_input) * (*this).position_;
190-
Quaterniond rotation = (*this).rotation_.slerp(control_input, target_pose.rotation_);
189+
Eigen::Vector3d position = control_input * target_pose.position_ + (1.0 - control_input) * (*this).position_;
190+
Eigen::Quaterniond rotation = (*this).rotation_.slerp(control_input, target_pose.rotation_);
191191
return Pose(position, rotation);
192192
};
193193

194194
/// Returns pose with position and rotation elements set to identity values.
195195
/// @return The Identity Pose
196196
inline static Pose Identity(void)
197197
{
198-
return Pose(Vector3d::Zero(), Quaterniond::Identity());
198+
return Pose(Eigen::Vector3d::Zero(), Eigen::Quaterniond::Identity());
199199
}
200200

201201
/// Returns pose with position and rotation elements all set to undefined values.
@@ -205,8 +205,8 @@ class Pose
205205
return Pose(UNDEFINED_POSITION, UNDEFINED_ROTATION);
206206
}
207207

208-
Vector3d position_; ///< The position element of the pose class
209-
Quaterniond rotation_; ///< The rotation element of the pose class
208+
Eigen::Vector3d position_; ///< The position element of the pose class
209+
Eigen::Quaterniond rotation_; ///< The rotation element of the pose class
210210

211211
public:
212212
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

include/syropod_highlevel_controller/pose_controller.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AutoPoser;
3737
/// requirements and methods. Generation of a user controlled 'manual' body pose and an IMU feedback based automatic
3838
/// body pose are examples of these sub-poses, which are combined and applied to the robot model body.
3939
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40-
typedef vector<shared_ptr<AutoPoser>, aligned_allocator<shared_ptr<AutoPoser>>> AutoPoserContainer;
40+
typedef vector<shared_ptr<AutoPoser>, Eigen::aligned_allocator<shared_ptr<AutoPoser>>> AutoPoserContainer;
4141
class PoseController : public enable_shared_from_this<PoseController>
4242
{
4343
public:
@@ -76,15 +76,15 @@ class PoseController : public enable_shared_from_this<PoseController>
7676

7777
/// Accessor for error in rotation absement - used in imu posing PID.
7878
/// @return The error in rotation absement (Difference between current and desired rotation absement for IMU posing PID)
79-
inline Vector3d getRotationAbsementError(void) { return rotation_absement_error_; };
79+
inline Eigen::Vector3d getRotationAbsementError(void) { return rotation_absement_error_; };
8080

8181
/// Accessor for error in rotation position - used in imu posing PID.
8282
/// @return The error in rotation position (Difference between current and desired rotation position for IMU posing PID)
83-
inline Vector3d getRotationPositionError(void) { return rotation_position_error_; };
83+
inline Eigen::Vector3d getRotationPositionError(void) { return rotation_position_error_; };
8484

8585
/// Accessor for error in rotation velocity - used in imu posing PID.
8686
/// @return The error in rotation velocity (Difference between current and desired rotation velocity for IMU posing PID)
87-
inline Vector3d getRotationVelocityError(void) { return rotation_velocity_error_; };
87+
inline Eigen::Vector3d getRotationVelocityError(void) { return rotation_velocity_error_; };
8888

8989
/// Modifier for pose phase length.
9090
/// @param[in] phase_length The phase length to be set as the phase length of the auto posing cycle
@@ -105,7 +105,7 @@ class PoseController : public enable_shared_from_this<PoseController>
105105
/// Modifier for manual pose velocity input.
106106
/// @param[in] translation The value to be set as the velocity input for controlling the translation component of manual pose
107107
/// @param[in] rotation The value to be set as the velocity input for controlling the rotational component of manual pose
108-
inline void setManualPoseInput(const Vector3d& translation, const Vector3d& rotation)
108+
inline void setManualPoseInput(const Eigen::Vector3d& translation, const Eigen::Vector3d& rotation)
109109
{
110110
translation_velocity_input_ = translation;
111111
rotation_velocity_input_ = rotation;
@@ -244,7 +244,7 @@ class PoseController : public enable_shared_from_this<PoseController>
244244

245245
/// Estimates the acceleration vector due to gravity.
246246
/// @return The estimated acceleration vector due to gravity.
247-
inline Vector3d estimateGravity(void) { return model_->estimateGravity(); };
247+
inline Eigen::Vector3d estimateGravity(void) { return model_->estimateGravity(); };
248248

249249
/// Attempts to generate a pose (x/y linear translation only) to position body such that there is a zero sum of moments
250250
/// from the force acting on the load bearing feet, allowing the robot to shift its centre of mass away from manually
@@ -258,8 +258,8 @@ class PoseController : public enable_shared_from_this<PoseController>
258258
shared_ptr<Leg> auto_pose_reference_leg_; ///< Reference leg for auto posing system
259259

260260
PoseResetMode pose_reset_mode_; ///< Mode for controlling which posing axes to reset to zero
261-
Vector3d translation_velocity_input_; ///< Velocity input for controlling the translation component of manual pose
262-
Vector3d rotation_velocity_input_; ///< Velocity input for controlling the rotational component of manual pose
261+
Eigen::Vector3d translation_velocity_input_; ///< Velocity input for controlling the translation component of manual pose
262+
Eigen::Vector3d rotation_velocity_input_; ///< Velocity input for controlling the rotational component of manual pose
263263

264264
int legs_completed_step_ = 0; ///< Number of legs having completed the required step in a sequence
265265
int current_group_ = 0; ///< The current leg group executing a stepping maneuver
@@ -303,9 +303,9 @@ class PoseController : public enable_shared_from_this<PoseController>
303303
int pose_phase_length_ = 0; ///< The phase length of the auto posing cycle
304304
int normaliser_ = 1; ///< The value used to scale base posing cycle start/end ratios
305305

306-
Vector3d rotation_absement_error_; ///< Difference between current and desired rotation absement for IMU posing PID
307-
Vector3d rotation_position_error_; ///< Difference between current and desired rotation position for IMU posing PID
308-
Vector3d rotation_velocity_error_; ///< Difference between current and desired rotation velocity for IMU posing PID
306+
Eigen::Vector3d rotation_absement_error_; ///< Difference between current and desired rotation absement for IMU posing PID
307+
Eigen::Vector3d rotation_position_error_; ///< Difference between current and desired rotation position for IMU posing PID
308+
Eigen::Vector3d rotation_velocity_error_; ///< Difference between current and desired rotation velocity for IMU posing PID
309309

310310
LegContainer::iterator leg_it_; ///< Leg iteration member variable used to minimise code
311311
JointContainer::iterator joint_it_; ///< Joint iteration member variable used to minimise code
@@ -576,7 +576,7 @@ class LegPoser
576576
Pose target_tip_pose_; ///< Target tip pose used in bezier curve equations
577577
ExternalTarget external_target_; ///< Externally set target tip pose object
578578

579-
vector<Pose, aligned_allocator<Pose>> transition_poses_; ///< Vector of transition target tip poses
579+
vector<Pose, Eigen::aligned_allocator<Pose>> transition_poses_; ///< Vector of transition target tip poses
580580

581581
bool leg_completed_step_ = false; ///< Flag denoting if leg has completed its required step in a sequence
582582

include/syropod_highlevel_controller/standard_includes.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@
5454
#define PROGRESS_COMPLETE 100 ///< Value denoting 100% and a completion of progress of various functions
5555
#define THROTTLE_PERIOD 5 ///< Default throttle period for all throttled rosconsole messages (seconds)
5656

57-
#define UNDEFINED_ROTATION Quaterniond(0,0,0,0)
58-
#define UNDEFINED_POSITION Vector3d(double(INT_MAX), double(INT_MAX), double(INT_MAX))
57+
#define UNDEFINED_ROTATION Eigen::Quaterniond(0,0,0,0)
58+
#define UNDEFINED_POSITION Eigen::Vector3d(double(INT_MAX), double(INT_MAX), double(INT_MAX))
5959

6060
#define GRAVITY_ACCELERATION -9.81 ///< Approximate gravitational acceleration (m/s/s)
6161

6262
using namespace std;
6363
using namespace ros;
6464
using namespace tf2_ros;
65-
using namespace Eigen;
6665

6766
/// Converts Degrees to Radians.
6867
/// @param[in] degrees Value in degrees to be converted to radians
@@ -132,7 +131,7 @@ inline T clamped(const T& value, const double& magnitude)
132131
template <class T>
133132
inline T clamped(const T& value, const T& limit)
134133
{
135-
VectorXd result(value.size());
134+
Eigen::VectorXd result(value.size());
136135
for (int i = 0; i < value.size(); ++i)
137136
{
138137
result[i] = clamped(value[i], -limit[i], limit[1]);
@@ -153,9 +152,9 @@ inline double setPrecision(const double& value, const int& precision)
153152
/// @param[in] vector The input vector
154153
/// @param[in] precision The required precision
155154
/// @return The input vector with a precision defined by the precision input
156-
inline Vector3d setPrecision(const Vector3d& vector, const int& precision)
155+
inline Eigen::Vector3d setPrecision(const Eigen::Vector3d& vector, const int& precision)
157156
{
158-
return Vector3d(roundToInt(vector[0] * pow(10, precision)) / pow(10, precision),
157+
return Eigen::Vector3d(roundToInt(vector[0] * pow(10, precision)) / pow(10, precision),
159158
roundToInt(vector[1] * pow(10, precision)) / pow(10, precision),
160159
roundToInt(vector[2] * pow(10, precision)) / pow(10, precision));
161160
}
@@ -174,11 +173,11 @@ inline double smoothStep(const double& control_input)
174173
/// @param[in] a The input vector
175174
/// @param[in] b The reference vector
176175
/// @return The resultant projection vector
177-
inline Vector3d getProjection(const Vector3d& a, const Vector3d& b)
176+
inline Eigen::Vector3d getProjection(const Eigen::Vector3d& a, const Eigen::Vector3d& b)
178177
{
179178
if (a.norm() == 0.0 || b.norm() == 0.0)
180179
{
181-
return Vector3d::Zero();
180+
return Eigen::Vector3d::Zero();
182181
}
183182
else
184183
{
@@ -191,7 +190,7 @@ inline Vector3d getProjection(const Vector3d& a, const Vector3d& b)
191190
/// @param[in] a The input vector
192191
/// @param[in] b The reference vector
193192
/// @return The resultant rejection vector
194-
inline Vector3d getRejection(const Vector3d& a, const Vector3d& b)
193+
inline Eigen::Vector3d getRejection(const Eigen::Vector3d& a, const Eigen::Vector3d& b)
195194
{
196195
return a - getProjection(a, b);
197196
}
@@ -212,11 +211,11 @@ inline T interpolate(const T& origin, const T& target, const double& control_inp
212211
/// @param[in] test The test rotation to check for shorter rotation path
213212
/// @param[in] reference The reference rotation for the target rotation
214213
/// @return Rotation with shorter path between identical rotations on quaternion
215-
inline Quaterniond correctRotation(const Quaterniond& test, const Quaterniond& reference)
214+
inline Eigen::Quaterniond correctRotation(const Eigen::Quaterniond& test, const Eigen::Quaterniond& reference)
216215
{
217216
if (test.dot(reference) < 0.0)
218217
{
219-
return Quaterniond(-test.w(), -test.x(), -test.y(), -test.z());
218+
return Eigen::Quaterniond(-test.w(), -test.x(), -test.y(), -test.z());
220219
}
221220
else
222221
{
@@ -228,19 +227,19 @@ inline Quaterniond correctRotation(const Quaterniond& test, const Quaterniond& r
228227
/// @param[in] euler Eigen Vector3d of Euler angles (roll, pitch, yaw) to be converted
229228
/// @param[in] intrinsic Defines whether conversion occurs intrinsically or extrinsically
230229
/// @return Eigen Quaternion generated using given Euler Angles
231-
inline Quaterniond eulerAnglesToQuaternion(const Vector3d& euler, const bool& intrinsic = false)
230+
inline Eigen::Quaterniond eulerAnglesToQuaternion(const Eigen::Vector3d& euler, const bool& intrinsic = false)
232231
{
233232
if (intrinsic)
234233
{
235-
return Quaterniond(AngleAxisd(euler[0], Vector3d::UnitX()) *
236-
AngleAxisd(euler[1], Vector3d::UnitY()) *
237-
AngleAxisd(euler[2], Vector3d::UnitZ()));
234+
return Eigen::Quaterniond(Eigen::AngleAxisd(euler[0], Eigen::Vector3d::UnitX()) *
235+
Eigen::AngleAxisd(euler[1], Eigen::Vector3d::UnitY()) *
236+
Eigen::AngleAxisd(euler[2], Eigen::Vector3d::UnitZ()));
238237
}
239238
else
240239
{
241-
return Quaterniond(AngleAxisd(euler[2], Vector3d::UnitZ()) *
242-
AngleAxisd(euler[1], Vector3d::UnitY()) *
243-
AngleAxisd(euler[0], Vector3d::UnitX()));
240+
return Eigen::Quaterniond(Eigen::AngleAxisd(euler[2], Eigen::Vector3d::UnitZ()) *
241+
Eigen::AngleAxisd(euler[1], Eigen::Vector3d::UnitY()) *
242+
Eigen::AngleAxisd(euler[0], Eigen::Vector3d::UnitX()));
244243
}
245244
}
246245

@@ -249,9 +248,9 @@ inline Quaterniond eulerAnglesToQuaternion(const Vector3d& euler, const bool& in
249248
/// @param[in] rotation Eigen Quaterniond of rotation to be converted
250249
/// @param[in] intrinsic Defines whether conversion occurs intrinsically or extrinsically
251250
/// @return Euler Angles generated using given Eigen Quaternoid
252-
inline Vector3d quaternionToEulerAngles(const Quaterniond& rotation, const bool& intrinsic = false)
251+
inline Eigen::Vector3d quaternionToEulerAngles(const Eigen::Quaterniond& rotation, const bool& intrinsic = false)
253252
{
254-
Vector3d result(0,0,0);
253+
Eigen::Vector3d result(0,0,0);
255254

256255
// Intrinsic rotation (roll, pitch, yaw order)
257256
if (intrinsic)
@@ -292,7 +291,7 @@ inline Vector3d quaternionToEulerAngles(const Quaterniond& rotation, const bool&
292291
}
293292
}
294293

295-
return intrinsic ? result : Vector3d(result[2], result[1], result[0]);
294+
return intrinsic ? result : Eigen::Vector3d(result[2], result[1], result[0]);
296295
}
297296

298297
/// Returns a string representation of the input value.
@@ -377,9 +376,9 @@ inline T quarticBezierDot(const T* points, const double& t)
377376
/// @param[in] r The DH parameter representing length of the common normal
378377
/// @param[in] alpha The DH parameter representing angle about common normal, form old z-axis to new z-axis
379378
/// @return Classical Denavit-Hartenberg (DH) matrix generated using the given DH parameters as input
380-
inline Matrix4d createDHMatrix(const double& d, const double& theta, const double& r, const double& alpha)
379+
inline Eigen::Matrix4d createDHMatrix(const double& d, const double& theta, const double& r, const double& alpha)
381380
{
382-
Matrix4d m;
381+
Eigen::Matrix4d m;
383382
m << cos(theta), -sin(theta)*cos(alpha), sin(theta)*sin(alpha), r* cos(theta),
384383
sin(theta), cos(theta)*cos(alpha), -cos(theta)*sin(alpha), r* sin(theta),
385384
0, sin(alpha), cos(alpha), d,

0 commit comments

Comments
 (0)