@@ -45,6 +45,8 @@ FHState *FrankaHand::get_state() {
4545 state->temperature = gripper_state.temperature ;
4646 state->max_unnormalized_width = this ->max_width ;
4747 state->last_commanded_width = this ->last_commanded_width ;
48+ state->bool_state = this ->last_commanded_width > 0 ;
49+ state->is_moving = this ->is_moving ;
4850 return state;
4951}
5052
@@ -74,7 +76,7 @@ void FrankaHand::m_stop(){
7476 this ->control_thread ->join ();
7577 this ->control_thread .reset ();
7678 }
77-
79+ this -> is_moving = false ;
7880}
7981
8082void FrankaHand::m_reset () {
@@ -83,7 +85,9 @@ void FrankaHand::m_reset() {
8385 franka::GripperState gripper_state = this ->gripper .readOnce ();
8486 this ->max_width = gripper_state.max_width - 0.001 ;
8587 this ->last_commanded_width = this ->max_width ;
88+ this ->is_moving = true ;
8689 this ->gripper .move (this ->max_width , this ->cfg .speed );
90+ this ->is_moving = false ;
8791}
8892void FrankaHand::reset () { this ->m_reset (); }
8993
@@ -95,36 +99,57 @@ bool FrankaHand::is_grasped() {
9599bool FrankaHand::homing () {
96100 // Do a homing in order to estimate the maximum
97101 // grasping width with the current fingers.
98- return this ->gripper .homing ();
102+ this ->is_moving = true ;
103+ bool success = this ->gripper .homing ();
104+ this ->is_moving = false ;
105+ return success;
99106}
100107
101108void FrankaHand::grasp () {
102109 this ->last_commanded_width = 0 ;
103110 if (!this ->cfg .async_control ) {
111+ this ->is_moving = true ;
104112 this ->gripper .grasp (0 , this ->cfg .speed , this ->cfg .force , 1 , 1 );
113+ this ->is_moving = false ;
105114 return ;
106115 }
107116 this ->m_stop ();
108- this ->control_thread = std::thread ([&](){this ->gripper .grasp (0 , this ->cfg .speed , this ->cfg .force , 1 , 1 );});
117+ this ->control_thread = std::thread ([&](){
118+ this ->is_moving = true ;
119+ this ->gripper .grasp (0 , this ->cfg .speed , this ->cfg .force , 1 , 1 );
120+ this ->is_moving = false ;
121+ });
109122}
110123
111124void FrankaHand::open () {
112125 this ->last_commanded_width = this ->max_width ;
113126 if (!this ->cfg .async_control ) {
127+ this ->is_moving = true ;
114128 this ->gripper .move (this ->max_width , this ->cfg .speed );
129+ this ->is_moving = false ;
115130 return ;
116131 }
117132 this ->m_stop ();
118- this ->control_thread = std::thread ([&](){this ->gripper .move (this ->max_width , this ->cfg .speed );});
133+ this ->control_thread = std::thread ([&](){
134+ this ->is_moving = true ;
135+ this ->gripper .move (this ->max_width , this ->cfg .speed );
136+ this ->is_moving = false ;
137+ });
119138}
120139void FrankaHand::shut () {
121140 this ->last_commanded_width = 0 ;
122141 if (!this ->cfg .async_control ) {
142+ this ->is_moving = true ;
123143 this ->gripper .move (0 , this ->cfg .speed );
144+ this ->is_moving = false ;
124145 return ;
125146 }
126147 this ->m_stop ();
127- this ->control_thread = std::thread ([&](){this ->gripper .move (0 , this ->cfg .speed );});
148+ this ->control_thread = std::thread ([&](){
149+ this ->is_moving = true ;
150+ this ->gripper .move (0 , this ->cfg .speed );
151+ this ->is_moving = false ;
152+ });
128153}
129154} // namespace hw
130155} // namespace rcs
0 commit comments