-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpose_spline.cpp
More file actions
79 lines (63 loc) · 2.52 KB
/
pose_spline.cpp
File metadata and controls
79 lines (63 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <bitbots_splines/pose_spline.hpp>
namespace bitbots_splines {
tf2::Transform PoseSpline::getTfTransform(double time) {
tf2::Transform trans;
trans.setOrigin(getPositionPos(time));
trans.setRotation(getOrientation(time));
return trans;
}
geometry_msgs::msg::Pose PoseSpline::getGeometryMsgPose(double time) {
geometry_msgs::msg::Pose msg;
msg.position = getGeometryMsgPosition(time);
msg.orientation = getGeometryMsgOrientation(time);
return msg;
}
geometry_msgs::msg::Point PoseSpline::getGeometryMsgPosition(double time) {
geometry_msgs::msg::Point msg;
tf2::Vector3 tf_vec = getPositionPos(time);
msg.x = tf_vec.x();
msg.y = tf_vec.y();
msg.z = tf_vec.z();
return msg;
}
geometry_msgs::msg::Quaternion PoseSpline::getGeometryMsgOrientation(double time) {
geometry_msgs::msg::Quaternion msg;
tf2::convert(getOrientation(time), msg);
return msg;
}
tf2::Vector3 PoseSpline::getPositionPos(double time) { return tf2::Vector3(x_.pos(time), y_.pos(time), z_.pos(time)); }
tf2::Vector3 PoseSpline::getPositionVel(double time) { return tf2::Vector3(x_.vel(time), y_.vel(time), z_.vel(time)); }
tf2::Vector3 PoseSpline::getPositionAcc(double time) { return tf2::Vector3(x_.acc(time), y_.acc(time), z_.acc(time)); }
tf2::Vector3 PoseSpline::getEulerAngles(double time) {
return tf2::Vector3(roll_.pos(time), pitch_.pos(time), yaw_.pos(time));
}
tf2::Vector3 PoseSpline::getEulerVel(double time) {
return tf2::Vector3(roll_.vel(time), pitch_.vel(time), yaw_.vel(time));
}
tf2::Vector3 PoseSpline::getEulerAcc(double time) {
return tf2::Vector3(roll_.acc(time), pitch_.acc(time), yaw_.acc(time));
}
tf2::Quaternion PoseSpline::getOrientation(double time) {
tf2::Quaternion quat;
tf2::Vector3 rpy = getEulerAngles(time);
quat.setRPY(rpy[0], rpy[1], rpy[2]);
quat.normalize();
return quat;
}
SmoothSpline *PoseSpline::x() { return &x_; }
SmoothSpline *PoseSpline::y() { return &y_; }
SmoothSpline *PoseSpline::z() { return &z_; }
SmoothSpline *PoseSpline::roll() { return &roll_; }
SmoothSpline *PoseSpline::pitch() { return &pitch_; }
SmoothSpline *PoseSpline::yaw() { return &yaw_; }
std::string PoseSpline::getDebugString() {
std::string output;
output += "x:\n" + x_.getDebugString() + "\n";
output += "y:\n" + y_.getDebugString() + "\n";
output += "z:\n" + z_.getDebugString() + "\n";
output += "roll:\n" + roll_.getDebugString() + "\n";
output += "pitch:\n" + pitch_.getDebugString() + "\n";
output += "yaw:\n" + yaw_.getDebugString() + "\n";
return output;
}
} // namespace bitbots_splines