foot_pose_transformer.cpp
Go to the documentation of this file.
2 
4 {
6 {
7  // obtain left foot transformation
8  geometry_msgs::Vector3 left_origin;
9  getXYZ(nh, "foot/left/foot_frame", left_origin);
10  tf::Vector3 left_origin_tf;
11  tf::vector3MsgToTF(left_origin, left_origin_tf);
12  left_foot_frame_transform.setOrigin(left_origin_tf);
13 
14  geometry_msgs::Vector3 left_orientation;
15  getRPY(nh, "foot/left/foot_frame", left_orientation);
16  left_foot_frame_transform.setRotation(tf::createQuaternionFromRPY(left_orientation.x, left_orientation.y, left_orientation.z));
17 
18  // obtain right foot transformation
19  geometry_msgs::Vector3 right_origin;
20  getXYZ(nh, "foot/right/foot_frame", right_origin);
21  tf::Vector3 right_origin_tf;
22  tf::vector3MsgToTF(right_origin, right_origin_tf);
23  right_foot_frame_transform.setOrigin(right_origin_tf);
24 
25  geometry_msgs::Vector3 right_orientation;
26  getRPY(nh, "foot/right/foot_frame", right_orientation);
27  right_foot_frame_transform.setRotation(tf::createQuaternionFromRPY(right_orientation.x, right_orientation.y, right_orientation.z));
28 }
29 
31 {
32 }
33 
34 msgs::ErrorStatus FootPoseTransformer::transform(geometry_msgs::Pose& pose, const tf::Transform& transform) const
35 {
36  tf::Pose pose_tf;
37  tf::poseMsgToTF(pose, pose_tf);
38  pose_tf = pose_tf * transform;
39  tf::poseTFToMsg(pose_tf, pose);
40  return msgs::ErrorStatus();
41 }
42 
43 msgs::ErrorStatus FootPoseTransformer::transform(msgs::Foot& foot, const std::string& target_frame) const
44 {
45  if (foot.foot_index != msgs::Foot::LEFT && foot.foot_index != msgs::Foot::RIGHT)
46  return ErrorStatusError(msgs::ErrorStatus::ERR_UNKNOWN, "FootPoseTransformer", "Foot index '" + boost::lexical_cast<std::string>(foot.foot_index) + "' is unknown!");
47 
48  if (target_frame == "planner") // to sole frame
49  return transform(foot.pose, foot.foot_index == msgs::Foot::LEFT ? left_foot_frame_transform : right_foot_frame_transform);
50  else if (target_frame == "robot") // to tf "foot" frame
51  return transform(foot.pose, foot.foot_index == msgs::Foot::LEFT ? left_foot_frame_transform.inverse() : right_foot_frame_transform.inverse());
52  else
53  return ErrorStatusError(msgs::ErrorStatus::ERR_UNKNOWN, "FootPoseTransformer", "Target frame '" + target_frame + "' is unknown!");
54 }
55 
56 msgs::ErrorStatus FootPoseTransformer::transform(msgs::Feet& feet, const std::string& target_frame) const
57 {
58  msgs::ErrorStatus status;
59  status += transform(feet.left, target_frame);
60  status += transform(feet.right, target_frame);
61  return status;
62 }
63 
64 msgs::ErrorStatus FootPoseTransformer::transform(msgs::Step& step, const std::string& target_frame) const
65 {
66  return transform(step.foot, target_frame);
67 }
68 
69 msgs::ErrorStatus FootPoseTransformer::transform(msgs::StepPlan& step_plan, const std::string& target_frame) const
70 {
71  msgs::ErrorStatus status;
72  status += transform(step_plan.steps, target_frame);
73  status += transform(step_plan.start.left, target_frame);
74  status += transform(step_plan.start.right, target_frame);
75  status += transform(step_plan.goal.left, target_frame);
76  status += transform(step_plan.goal.right, target_frame);
77  return status;
78 }
79 }
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
TFSIMD_FORCE_INLINE void setRotation(const Quaternion &q)
static void poseMsgToTF(const geometry_msgs::Pose &msg, Pose &bt)
static void vector3MsgToTF(const geometry_msgs::Vector3 &msg_v, Vector3 &bt_v)
Transform inverse() const
static void poseTFToMsg(const Pose &bt, geometry_msgs::Pose &msg)
msgs::ErrorStatus transform(geometry_msgs::Pose &pose, const tf::Transform &transform) const
TFSIMD_FORCE_INLINE void setOrigin(const Vector3 &origin)


vigir_foot_pose_transformer
Author(s): Alexander Stumpf
autogenerated on Sun Nov 17 2019 03:29:57