File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ struct Joint {
6767 // / be controlled.
6868 ControlMethod control_method = POSITION;
6969
70+ // / The currently CLAMPED applied command from the controller acting on this joint either in \f$N\f$ or
71+ // / \f$Nm\f$ without gravity.
72+ // / NOTE: Clamped to zero when the joint is in its limits.
73+ double clamped_command = 0 ;
74+
7075 // / The currently acting gravity force or torque acting on this joint in \f$N\f$ or \f$Nm\f$
7176 double gravity = 0 ;
7277
Original file line number Diff line number Diff line change @@ -585,7 +585,9 @@ void FrankaHWSim::updateRobotState(ros::Time time) {
585585 }
586586
587587 if (this ->robot_initialized_ ) {
588- double tau_ext = joint->effort - joint->command + joint->gravity ;
588+ // NOTE: Here we use the clamped command to filter out the internal controller
589+ // force when the joint is in its limits.
590+ double tau_ext = joint->effort - joint->clamped_command + joint->gravity ;
589591
590592 // Exponential moving average filter from tau_ext -> tau_ext_hat_filtered
591593 this ->robot_state_ .tau_ext_hat_filtered [i] =
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ void Joint::update(const ros::Duration& dt) {
5050 }
5151 this ->jerk = (this ->acceleration - this ->lastAcceleration ) / dt.toSec ();
5252 this ->lastAcceleration = this ->acceleration ;
53+
54+ // Store the clamped command
55+ // NOTE: Clamped to zero when joint is in its joint limits.
56+ this ->clamped_command =
57+ (this ->position > this ->limits .min_position && this ->position < this ->limits .max_position )
58+ ? this ->command
59+ : 0.0 ;
5360}
5461
5562double Joint::getLinkMass () const {
@@ -64,10 +71,10 @@ double Joint::getLinkMass() const {
6471}
6572
6673bool Joint::isInCollision () const {
67- return std::abs (this ->effort - this ->command ) > this ->collision_threshold ;
74+ return std::abs (this ->effort - this ->clamped_command + this -> gravity ) > this ->collision_threshold ;
6875}
6976
7077bool Joint::isInContact () const {
71- return std::abs (this ->effort - this ->command ) > this ->contact_threshold ;
78+ return std::abs (this ->effort - this ->clamped_command + this -> gravity ) > this ->contact_threshold ;
7279}
7380} // namespace franka_gazebo
You can’t perform that action at this time.
0 commit comments