Skip to content

Commit f03afab

Browse files
Talbot, Fletcher (Data61, Pullenvale)Talbot, Fletcher (Data61, Pullenvale)
Talbot, Fletcher (Data61, Pullenvale)
authored and
Talbot, Fletcher (Data61, Pullenvale)
committed
Added actual tip pose to legState message which is generated using FK from motor joint position outputs
1 parent 73191e5 commit f03afab

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

include/syropod_highlevel_controller/model.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ class Leg : public enable_shared_from_this<Leg>
545545
* Updates joint transforms and applies forward kinematics to calculate a new tip pose.
546546
* Sets leg current tip pose to new pose if requested.
547547
* @param[in] set_current Flag denoting of the calculated tip pose should be set as the current tip pose.
548+
* @param[in] use_actual Flag denoting if the joint position values used for FK come from actual motor outputs
548549
*/
549-
Pose applyFK(const bool& set_current = true);
550+
Pose applyFK(const bool& set_current = true, const bool& use_actual = false);
550551

551552
private:
552553
shared_ptr<Model> model_; ///< A pointer to the parent robot model object.

msg/LegState.msg

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ geometry_msgs/PoseStamped walker_tip_pose
55
geometry_msgs/PoseStamped target_tip_pose
66
geometry_msgs/PoseStamped poser_tip_pose
77
geometry_msgs/PoseStamped model_tip_pose
8+
geometry_msgs/PoseStamped actual_tip_pose
89

910
geometry_msgs/TwistStamped model_tip_velocity
1011

src/model.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,10 @@ double Leg::applyIK(const bool& simulation)
10161016
/*******************************************************************************************************************//**
10171017
* Updates joint transforms and applies forward kinematics to calculate a new tip pose.
10181018
* Sets leg current tip pose to new pose if requested.
1019-
* @param[in] set_current Flag denoting of the calculated tip pose should be set as the current tip pose.
1019+
* @param[in] set_current Flag denoting if the calculated tip pose should be set as the current tip pose.
1020+
* @param[in] use_actual Flag denoting if the joint position values used for FK come from actual motor outputs
10201021
***********************************************************************************************************************/
1021-
Pose Leg::applyFK(const bool& set_current)
1022+
Pose Leg::applyFK(const bool& set_current, const bool& use_actual)
10221023
{
10231024
//Update joint transforms - skip first joint since it's transform is constant
10241025
JointContainer::iterator joint_it;
@@ -1027,21 +1028,29 @@ Pose Leg::applyFK(const bool& set_current)
10271028
shared_ptr<Joint> joint = joint_it->second;
10281029
const shared_ptr<Link> reference_link = joint->reference_link_;
10291030
double joint_angle = reference_link->actuating_joint_->desired_position_;
1031+
if (use_actual)
1032+
{
1033+
joint_angle = reference_link->actuating_joint_->current_position_;
1034+
}
10301035
joint->current_transform_ = createDHMatrix(reference_link->dh_parameter_d_,
10311036
reference_link->dh_parameter_theta_ + joint_angle,
10321037
reference_link->dh_parameter_r_,
10331038
reference_link->dh_parameter_alpha_);
10341039
}
10351040
const shared_ptr<Link> reference_link = tip_->reference_link_;
10361041
double joint_angle = reference_link->actuating_joint_->desired_position_;
1042+
if (use_actual)
1043+
{
1044+
joint_angle = reference_link->actuating_joint_->current_position_;
1045+
}
10371046
tip_->current_transform_ = createDHMatrix(reference_link->dh_parameter_d_,
10381047
reference_link->dh_parameter_theta_ + joint_angle,
10391048
reference_link->dh_parameter_r_,
10401049
reference_link->dh_parameter_alpha_);
10411050

10421051
//Get world frame position of tip
10431052
Pose tip_pose = tip_->getPoseRobotFrame();
1044-
if (set_current)
1053+
if (set_current && !use_actual)
10451054
{
10461055
if (current_tip_pose_ != Pose::Undefined())
10471056
{

src/state_controller.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,10 @@ void StateController::publishLegState(void)
853853
msg.model_tip_pose.header.stamp = ros::Time::now();
854854
msg.model_tip_pose.header.frame_id = "base_link";
855855
msg.model_tip_pose.pose = leg->getCurrentTipPose().toPoseMessage();
856+
857+
msg.actual_tip_pose.header.stamp = ros::Time::now();
858+
msg.actual_tip_pose.header.frame_id = "base_link";
859+
msg.actual_tip_pose.pose = leg->applyFK(false, true).toPoseMessage();
856860

857861
// Tip velocities
858862
msg.model_tip_velocity.header.stamp = ros::Time::now();

0 commit comments

Comments
 (0)