@@ -1016,9 +1016,10 @@ double Leg::applyIK(const bool& simulation)
1016
1016
/* ******************************************************************************************************************/ /* *
1017
1017
* Updates joint transforms and applies forward kinematics to calculate a new tip pose.
1018
1018
* 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
1020
1021
***********************************************************************************************************************/
1021
- Pose Leg::applyFK (const bool & set_current)
1022
+ Pose Leg::applyFK (const bool & set_current, const bool & use_actual )
1022
1023
{
1023
1024
// Update joint transforms - skip first joint since it's transform is constant
1024
1025
JointContainer::iterator joint_it;
@@ -1027,21 +1028,29 @@ Pose Leg::applyFK(const bool& set_current)
1027
1028
shared_ptr<Joint> joint = joint_it->second ;
1028
1029
const shared_ptr<Link> reference_link = joint->reference_link_ ;
1029
1030
double joint_angle = reference_link->actuating_joint_ ->desired_position_ ;
1031
+ if (use_actual)
1032
+ {
1033
+ joint_angle = reference_link->actuating_joint_ ->current_position_ ;
1034
+ }
1030
1035
joint->current_transform_ = createDHMatrix (reference_link->dh_parameter_d_ ,
1031
1036
reference_link->dh_parameter_theta_ + joint_angle,
1032
1037
reference_link->dh_parameter_r_ ,
1033
1038
reference_link->dh_parameter_alpha_ );
1034
1039
}
1035
1040
const shared_ptr<Link> reference_link = tip_->reference_link_ ;
1036
1041
double joint_angle = reference_link->actuating_joint_ ->desired_position_ ;
1042
+ if (use_actual)
1043
+ {
1044
+ joint_angle = reference_link->actuating_joint_ ->current_position_ ;
1045
+ }
1037
1046
tip_->current_transform_ = createDHMatrix (reference_link->dh_parameter_d_ ,
1038
1047
reference_link->dh_parameter_theta_ + joint_angle,
1039
1048
reference_link->dh_parameter_r_ ,
1040
1049
reference_link->dh_parameter_alpha_ );
1041
1050
1042
1051
// Get world frame position of tip
1043
1052
Pose tip_pose = tip_->getPoseRobotFrame ();
1044
- if (set_current)
1053
+ if (set_current && !use_actual )
1045
1054
{
1046
1055
if (current_tip_pose_ != Pose::Undefined ())
1047
1056
{
0 commit comments