@@ -17,10 +17,6 @@ JoystickGripperInterface::JoystickGripperInterface(const JoystickGripperInterfac
1717 this ->gripperWristAnglePublisher = source.gripperWristAnglePublisher ;
1818 this ->gripperFingerAnglePublisher = source.gripperFingerAnglePublisher ;
1919
20- // QTimer state
21- this ->joystickGripperWristControlTimer = source.joystickGripperWristControlTimer ;
22- this ->joystickGripperFingerControlTimer = source.joystickGripperFingerControlTimer ;
23-
2420 // Wrist state
2521 this ->wristAngle = source.wristAngle ;
2622 this ->wristAngleChangeRate = source.wristAngleChangeRate ;
@@ -35,10 +31,6 @@ JoystickGripperInterface::JoystickGripperInterface(const JoystickGripperInterfac
3531 this ->fingerAngleMin = source.fingerAngleMin ;
3632 this ->fingerJoystickVector = source.fingerJoystickVector ;
3733
38- // Other
39- this ->commandReapplyRate = source.commandReapplyRate ;
40- this ->stickCenterTolerance = source.stickCenterTolerance ;
41-
4234 this ->nh = source.nh ;
4335}
4436
@@ -49,19 +41,6 @@ JoystickGripperInterface::JoystickGripperInterface(ros::NodeHandle nh, string ro
4941
5042 this ->nh = nh;
5143
52- // Joystick auto repeat for gripper control
53- joystickGripperWristControlTimer = new QTimer (this );
54- joystickGripperFingerControlTimer = new QTimer (this );
55-
56- // Connect the command timers to their handlers
57- connect (joystickGripperWristControlTimer, SIGNAL (timeout ()), this , SLOT (joystickGripperWristControlTimerEventHandler ()));
58- connect (joystickGripperFingerControlTimer, SIGNAL (timeout ()), this , SLOT (joystickGripperFingerControlTimerEventHandler ()));
59-
60- connect (this , SIGNAL (sendJoystickGripperWristControlTimerStart (int )), joystickGripperWristControlTimer, SLOT (start (int )));
61- connect (this , SIGNAL (sendJoystickGripperWristControlTimerStop ()), joystickGripperWristControlTimer, SLOT (stop ()));
62- connect (this , SIGNAL (sendJoystickGripperFingerControlTimerStart (int )), joystickGripperFingerControlTimer, SLOT (start (int )));
63- connect (this , SIGNAL (sendJoystickGripperFingerControlTimerStop ()), joystickGripperFingerControlTimer, SLOT (stop ()));
64-
6544 // Initialize gripper angles in radians
6645 wristAngle = 0 ;
6746 fingerAngle = 0 ;
@@ -83,12 +62,7 @@ JoystickGripperInterface::JoystickGripperInterface(ros::NodeHandle nh, string ro
8362 // Representation of the desired movement speed and direction generated by the joystick
8463 fingerJoystickVector = 0.0 ;
8564 wristJoystickVector = 0.0 ;
86-
87- commandReapplyRate = 100 ; // in milliseconds
88-
89- stickCenterTolerance = 0.05 ; // How close to zero does output from the joystick have to be for
90- // us to consider the user to have centered the stick
91-
65+
9266 // Setup the gripper angle command publishers
9367 gripperWristAnglePublisher = nh.advertise <std_msgs::Float32>(" /" +roverName+" /wristAngle/cmd" , 10 , this );
9468 gripperFingerAnglePublisher = nh.advertise <std_msgs::Float32>(" /" +roverName+" /fingerAngle/cmd" , 10 , this );
@@ -106,15 +80,20 @@ void JoystickGripperInterface::moveWrist(float vec) {
10680
10781 wristJoystickVector = -vec; // negate to make down the positive angle
10882
109- // Check whether the stick is near the center deadzone - if so stop issuing movement commands
110- // if not apply the movement indicated by vec
111- if (fabs (wristJoystickVector) < stickCenterTolerance) {
112- emit sendJoystickGripperWristControlTimerStop ();
113- } else {
114- // The event handler calculates the new angle for the wrist and sends it to the gripper wrist control topic
115- emit sendJoystickGripperWristControlTimerStart (commandReapplyRate);
116- }
83+ // Calculate the new wrist angle to request
84+ wristAngle += wristJoystickVector*wristAngleChangeRate;
11785
86+ // Don't exceed the min and max angles
87+ if (wristAngle > wristAngleMax) wristAngle = wristAngleMax;
88+ else if (wristAngle < wristAngleMin) wristAngle = wristAngleMin;
89+
90+ // If the wrist angle is small enough to use negative exponents set to zero
91+ // negative exponents confuse the downstream conversion to string
92+ if (fabs (wristAngle) < 0.001 ) wristAngle = 0 .0f ;
93+
94+ std_msgs::Float32 angleMsg;
95+ angleMsg.data = wristAngle;
96+ gripperWristAnglePublisher.publish (angleMsg);
11897
11998}
12099
@@ -127,45 +106,26 @@ void JoystickGripperInterface::moveFingers(float vec){
127106
128107 fingerJoystickVector = vec;
129108
130- // Check whether the stick is near the center deadzone - if so stop issuing movement commands
131- // if not apply the movement indicated by vec
132- if (fabs (fingerJoystickVector) < stickCenterTolerance) {
133- emit sendJoystickGripperFingerControlTimerStop ();
134- } else {
135- // The event handler calculates the new angle for the wrist and sends it to the gripper wrist control topic
136- emit sendJoystickGripperFingerControlTimerStart (commandReapplyRate);
137- }
138-
139-
140- }
141-
142- // Update and broadcast gripper wrist commands
143- // Called by event timer so the commands continue to be generated even when the joystick
144- // is not moving
145- void JoystickGripperInterface::joystickGripperWristControlTimerEventHandler (){
146-
147109 // Calculate the new wrist angle to request
148- wristAngle += wristJoystickVector*wristAngleChangeRate ;
110+ fingerAngle += fingerJoystickVector*fingerAngleChangeRate ;
149111
150112 // Don't exceed the min and max angles
151- if (wristAngle > wristAngleMax) wristAngle = wristAngleMax ;
152- else if (wristAngle < wristAngleMin) wristAngle = wristAngleMin ;
113+ if (fingerAngle > fingerAngleMax) fingerAngle = fingerAngleMax ;
114+ else if (fingerAngle < fingerAngleMin) fingerAngle = fingerAngleMin ;
153115
154- // If the wrist angle is small enough to use negative exponents set to zero
116+ // If the finger angle is small enough to use negative exponents set to zero
155117 // negative exponents confuse the downstream conversion to string
156- if (fabs (wristAngle ) < 0.001 ) wristAngle = 0 .0f ;
118+ if (fabs (fingerAngle ) < 0.001 ) fingerAngle = 0 .0f ;
157119
120+ // Publish the finger angle commands
158121 std_msgs::Float32 angleMsg;
159- angleMsg.data = wristAngle;
160- gripperWristAnglePublisher.publish (angleMsg);
161-
122+ angleMsg.data = fingerAngle;
123+ gripperFingerAnglePublisher.publish (angleMsg);
162124}
163125
164126void JoystickGripperInterface::changeRovers (string roverName)
165127{
166128 ready = false ;
167- joystickGripperWristControlTimer->stop ();
168- joystickGripperFingerControlTimer->stop ();
169129
170130 gripperWristAnglePublisher.shutdown ();
171131 gripperFingerAnglePublisher.shutdown ();
@@ -187,36 +147,10 @@ void JoystickGripperInterface::changeRovers(string roverName)
187147 ready = true ;
188148}
189149
190- // Update and broadcast gripper commands for the fingers
191- // Called by event timer so the commands continue to be generated even when the joystick
192- // is not moving
193- void JoystickGripperInterface::joystickGripperFingerControlTimerEventHandler (){
194- // Calculate the new wrist angle to request
195- fingerAngle += fingerJoystickVector*fingerAngleChangeRate;
196-
197- // Don't exceed the min and max angles
198- if (fingerAngle > fingerAngleMax) fingerAngle = fingerAngleMax;
199- else if (fingerAngle < fingerAngleMin) fingerAngle = fingerAngleMin;
200-
201-
202- // If the finger angle is small enough to use negative exponents set to zero
203- // negative exponents confuse the downstream conversion to string
204- if (fabs (fingerAngle) < 0.001 ) fingerAngle = 0 .0f ;
205-
206- // Publish the finger angle commands
207- std_msgs::Float32 angleMsg;
208- angleMsg.data = fingerAngle;
209- gripperFingerAnglePublisher.publish (angleMsg);
210-
211- }
212-
213150// Clean up the publishers when this object is destroyed
214151JoystickGripperInterface::~JoystickGripperInterface (){
215152 ready = false ;
216153
217- if (joystickGripperWristControlTimer) delete joystickGripperWristControlTimer;
218- if (joystickGripperFingerControlTimer) delete joystickGripperFingerControlTimer;
219-
220154 gripperWristAnglePublisher.shutdown ();
221155 gripperFingerAnglePublisher.shutdown ();
222156}
0 commit comments