File tree 3 files changed +17
-3
lines changed
3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ struct Joint {
67
67
// / be controlled.
68
68
ControlMethod control_method = POSITION;
69
69
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
+
70
75
// / The currently acting gravity force or torque acting on this joint in \f$N\f$ or \f$Nm\f$
71
76
double gravity = 0 ;
72
77
Original file line number Diff line number Diff line change @@ -585,7 +585,9 @@ void FrankaHWSim::updateRobotState(ros::Time time) {
585
585
}
586
586
587
587
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 ;
589
591
590
592
// Exponential moving average filter from tau_ext -> tau_ext_hat_filtered
591
593
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) {
50
50
}
51
51
this ->jerk = (this ->acceleration - this ->lastAcceleration ) / dt.toSec ();
52
52
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 ;
53
60
}
54
61
55
62
double Joint::getLinkMass () const {
@@ -64,10 +71,10 @@ double Joint::getLinkMass() const {
64
71
}
65
72
66
73
bool 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 ;
68
75
}
69
76
70
77
bool 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 ;
72
79
}
73
80
} // namespace franka_gazebo
You can’t perform that action at this time.
0 commit comments