File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed
Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Requires `libfranka` >= 0.8.0
1414 * ` franka_description ` : ` <xacro:franka_robot/> ` macro now supports to customize the ` parent ` frame and its ` xyz ` + ` rpy ` offset
1515 * ` franka_hw ` : Fix the bug where the previous controller is still running after switching the controller. ([ #326 ] ( https://github.com/frankaemika/franka_ros/issues/326 ) )
1616 * ` franka_gazebo ` : Add ` set_franka_model_configuration ` service.
17+ * ` franka_gazebo ` : Fix external torque calculation by accounting for internal joint limits
1718
1819## 0.10.1 - 2022-09-15
1920
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ struct Joint {
5555 // / \f$Nm\f$ without gravity
5656 double command = 0 ;
5757
58+ // / The clamped applied command from a controller acting on this joint either in \f$N\f$ or
59+ // / \f$Nm\f$ without gravity. Set to zero when joint command is saturated due to joint limits.
60+ double clamped_command = 0 ;
61+
5862 // / The current desired position that is used for the PID controller when the joints control
5963 // / method is "POSITION". When the control method is not "POSITION", this value will only be
6064 // / updated once at the start of the controller and stay the same until a new controller is
Original file line number Diff line number Diff line change @@ -679,7 +679,8 @@ void FrankaHWSim::updateRobotState(ros::Time time) {
679679 }
680680
681681 if (this ->robot_initialized_ ) {
682- double tau_ext = joint->effort - joint->command + joint->gravity ;
682+ // NOTE: Use clamped_command to account for internal joint saturation.
683+ double tau_ext = joint->effort - joint->clamped_command + joint->gravity ;
683684
684685 // Exponential moving average filter from tau_ext -> tau_ext_hat_filtered
685686 this ->robot_state_ .tau_ext_hat_filtered [i] =
Original file line number Diff line number Diff line change @@ -59,6 +59,12 @@ void Joint::update(const ros::Duration& dt) {
5959 }
6060 this ->jerk = (this ->acceleration - this ->lastAcceleration ) / dt.toSec ();
6161 this ->lastAcceleration = this ->acceleration ;
62+
63+ // / Store the clamped command, clamped to zero when joint is at its limits.
64+ this ->clamped_command =
65+ (this ->position > this ->limits .min_position && this ->position < this ->limits .max_position )
66+ ? this ->command
67+ : 0.0 ;
6268}
6369
6470double Joint::getDesiredPosition (const franka::RobotMode& mode) const {
@@ -114,11 +120,13 @@ double Joint::getLinkMass() const {
114120}
115121
116122bool Joint::isInCollision () const {
117- return std::abs (this ->effort - this ->command ) > this ->collision_threshold ;
123+ // NOTE: Clamped_command used to handle internal collisions.
124+ return std::abs (this ->effort - this ->clamped_command ) > this ->collision_threshold ;
118125}
119126
120127bool Joint::isInContact () const {
121- return std::abs (this ->effort - this ->command ) > this ->contact_threshold ;
128+ // NOTE: Clamped_command used to handle internal contacts.
129+ return std::abs (this ->effort - this ->clamped_command ) > this ->contact_threshold ;
122130}
123131
124132void Joint::setJointPosition (const double joint_position) {
You can’t perform that action at this time.
0 commit comments