|
NASA Astrobee Robot Software
0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
|
Go to the documentation of this file.
19 #ifndef MSG_CONVERSIONS_MSG_CONVERSIONS_H_
20 #define MSG_CONVERSIONS_MSG_CONVERSIONS_H_
24 #include <eigen3/Eigen/Core>
25 #include <eigen3/Eigen/Geometry>
27 #include <geometry_msgs/Pose.h>
28 #include <geometry_msgs/PoseWithCovarianceStamped.h>
29 #include <geometry_msgs/Point.h>
30 #include <geometry_msgs/Quaternion.h>
31 #include <geometry_msgs/Transform.h>
32 #include <geometry_msgs/TransformStamped.h>
33 #include <geometry_msgs/Vector3.h>
36 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
43 #define LOAD_PARAM(val, config, prefix) \
44 msg_conversions::Load((config), (val), std::string(#val).substr(std::string(#val).find_last_of(".") + 1), (prefix))
82 Eigen::Quaterniond* quat);
84 geometry_msgs::Quaternion* quat);
98 const std::string& prefix =
"");
104 const std::string& prefix =
"");
107 const std::string& prefix =
"");
109 const std::string& prefix =
"");
111 const std::string& prefix =
"");
113 const std::string& prefix =
"");
115 const std::string& prefix =
"");
122 geometry_msgs::PoseWithCovarianceStamped& pose_cov_msg);
124 geometry_msgs::PoseWithCovariance& pose_cov_msg);
126 template <
typename VectorType,
typename MsgVectorType>
128 return VectorType(msg_vector.x, msg_vector.y, msg_vector.z);
131 template <
typename VectorType,
typename MsgVectorType>
133 return VectorType(msg_vector.x, msg_vector.y);
136 template <
typename VectorType,
typename MsgVectorType>
137 void VectorToMsg(
const VectorType& vector, MsgVectorType& msg_vector) {
138 msg_vector.x = vector.x();
139 msg_vector.y = vector.y();
140 msg_vector.z = vector.z();
143 template <
typename VectorType,
typename MsgVectorType>
145 msg_vector.x = vector.x();
146 msg_vector.y = vector.y();
149 template <
typename RotationType,
typename MsgRotationType>
151 return RotationType(msg_rotation.w, msg_rotation.x, msg_rotation.y, msg_rotation.z);
154 template <
typename RotationType,
typename MsgRotationType>
155 void RotationToMsg(
const RotationType& rotation, MsgRotationType& msg_rotation) {
156 msg_rotation.w = rotation.w();
157 msg_rotation.x = rotation.x();
158 msg_rotation.y = rotation.y();
159 msg_rotation.z = rotation.z();
162 template <
typename ArrayType,
int Dim>
164 for (
int i = 0; i < Dim; ++i) {
165 for (
int j = 0; j < Dim; ++j) {
166 covariance_array[i*Dim + j] = covariance(i, j);
171 template <
int Dim,
typename ArrayType>
173 Eigen::Matrix<double, Dim, Dim> covariance;
174 for (
int i = 0; i < Dim; ++i) {
175 for (
int j = 0; j < Dim; ++j) {
176 covariance(i, j) = covariance_array[i*Dim + j];
183 #endif // MSG_CONVERSIONS_MSG_CONVERSIONS_H_
geometry_msgs::Pose tf2_transform_to_ros_pose(const tf2::Transform &p)
Definition: msg_conversions.cc:266
void Load(config_reader::ConfigReader &config, float &val, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:361
bool config_read_matrix(config_reader::ConfigReader *config, const char *name, int rows, int cols, float *dest)
Definition: msg_conversions.cc:138
void EigenPoseCovarianceToMsg(const Eigen::Isometry3d &pose, const Eigen::Matrix< double, 6, 6 > &covariance, geometry_msgs::PoseWithCovarianceStamped &pose_cov_msg)
Definition: msg_conversions.cc:398
void ros_to_array_vector(const geometry_msgs::Vector3 &v, float *array)
Definition: msg_conversions.cc:86
geometry_msgs::Quaternion tf2_quat_to_ros_quat(const tf2::Quaternion &q)
Definition: msg_conversions.cc:260
void Vector2dToMsg(const VectorType &vector, MsgVectorType &msg_vector)
Definition: msg_conversions.h:144
Definition: msg_conversions.h:46
geometry_msgs::Vector3 array_to_ros_vector(float *array)
Definition: msg_conversions.cc:61
VectorType Vector2dFromMsg(const MsgVectorType &msg_vector)
Definition: msg_conversions.h:132
std::string LoadString(config_reader::ConfigReader &config, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:355
Eigen::Vector3d ros_to_eigen_vector(const geometry_msgs::Vector3 &v)
Definition: msg_conversions.cc:27
RotationType RotationFromMsg(const MsgRotationType &msg_rotation)
Definition: msg_conversions.h:150
float LoadFloat(config_reader::ConfigReader &config, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:328
void EigenCovarianceToMsg(const Eigen::Matrix< double, Dim, Dim > &covariance, ArrayType &covariance_array)
Definition: msg_conversions.h:163
geometry_msgs::Quaternion eigen_to_ros_quat(const Eigen::Quaterniond &q)
Definition: msg_conversions.cc:49
Eigen::Quaterniond ros_to_eigen_quat(const geometry_msgs::Quaternion &q)
Definition: msg_conversions.cc:45
Eigen::Affine3d ros_pose_to_eigen_transform(const geometry_msgs::Pose &p)
Definition: msg_conversions.cc:236
tf2::Transform ros_tf_to_tf2_transform(const geometry_msgs::Transform &p)
Definition: msg_conversions.cc:287
geometry_msgs::Point array_to_ros_point(float *array)
Definition: msg_conversions.cc:69
geometry_msgs::Quaternion array_to_ros_quat(float *array)
Definition: msg_conversions.cc:77
Eigen::Isometry3d Isometry3d(const Eigen::Vector3d &translation, const RotationType &rotation)
Definition: utilities.h:226
std::vector< T > Transform(const std::vector< T > &a_T_elements, const Eigen::Isometry3d &b_T_a)
Definition: utilities.h:252
std::string name
Definition: eps_simulator.cc:48
void VectorToMsg(const VectorType &vector, MsgVectorType &msg_vector)
Definition: msg_conversions.h:137
Eigen::Vector3d Vector3d(const PointType &point)
Definition: utilities.h:328
bool config_read_quat(config_reader::ConfigReader *config, const char *name, Eigen::Quaterniond *quat)
Definition: msg_conversions.cc:118
tf2::Transform ros_pose_to_tf2_transform(const geometry_msgs::Pose &p)
Definition: msg_conversions.cc:301
void eigen_to_array_quat(const Eigen::Quaterniond &q, float *array)
Definition: msg_conversions.cc:111
double LoadDouble(config_reader::ConfigReader &config, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:335
void eigen_to_array_vector(const Eigen::Vector3d &v, float *array)
Definition: msg_conversions.cc:105
int LoadInt(config_reader::ConfigReader &config, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:342
Eigen::Vector3d ros_point_to_eigen_vector(const geometry_msgs::Point &p)
Definition: msg_conversions.cc:25
Eigen::Affine3d ros_to_eigen_transform(const geometry_msgs::Transform &p)
Definition: msg_conversions.cc:244
bool LoadBool(config_reader::ConfigReader &config, const std::string &config_name, const std::string &prefix="")
Definition: msg_conversions.cc:348
VectorType VectorFromMsg(const MsgVectorType &msg_vector)
Definition: msg_conversions.h:127
Definition: config_reader.h:48
Eigen::Isometry3d LoadEigenTransform(config_reader::ConfigReader &config, const std::string &transform_config_name, const std::string &prefix="")
Definition: msg_conversions.cc:315
bool config_read_array(config_reader::ConfigReader *config, const char *name, int length, float *dest)
Definition: msg_conversions.cc:128
Eigen::Matrix< double, Dim, Dim > EigenCovarianceFromMsg(const ArrayType &covariance_array)
Definition: msg_conversions.h:172
geometry_msgs::Pose eigen_transform_to_ros_pose(const Eigen::Affine3d &p)
Definition: msg_conversions.cc:273
geometry_msgs::Pose ros_transform_to_ros_pose(const geometry_msgs::Transform &p)
Definition: msg_conversions.cc:251
bool config_read_transform(config_reader::ConfigReader *config, const char *name, Eigen::Vector3d *vec, Eigen::Quaterniond *quat)
Definition: msg_conversions.cc:153
Eigen::Affine3d Affine3d(const Eigen::Matrix< double, 7, 1 > &affine_vector)
Definition: utilities.cc:43
void ros_to_array_quat(const geometry_msgs::Quaternion &q, float *array)
Definition: msg_conversions.cc:98
Definition: config_reader.h:54
bool config_read_vector(config_reader::ConfigReader *config, const char *name, Eigen::Vector3d *vec)
Definition: msg_conversions.cc:123
geometry_msgs::Vector3 eigen_to_ros_vector(const Eigen::Vector3d &v)
Definition: msg_conversions.cc:29
void RotationToMsg(const RotationType &rotation, MsgRotationType &msg_rotation)
Definition: msg_conversions.h:155
geometry_msgs::Transform eigen_transform_to_ros_transform(const Eigen::Affine3d &p)
Definition: msg_conversions.cc:280
geometry_msgs::Point eigen_to_ros_point(const Eigen::Vector3d &v)
Definition: msg_conversions.cc:37
void EigenPoseToMsg(const Eigen::Isometry3d &pose, geometry_msgs::Pose &msg_pose)
Definition: msg_conversions.cc:378
Eigen::Vector3d CovDiagToVariances(const float *const cov_diag)
Definition: msg_conversions.cc:394
void ros_to_array_point(const geometry_msgs::Point &p, float *array)
Definition: msg_conversions.cc:92
void VariancesToCovDiag(const Eigen::Vector3d &variances, float *const cov_diag)
Definition: msg_conversions.cc:388
bool SingleBoolTrue(const std::initializer_list< bool > &bools)
Definition: msg_conversions.cc:227