@@ -30,7 +30,9 @@ import {
30
30
SERVO_JOINT_TOPIC_MSG ,
31
31
ACTIVATE_CONTROLLER_ACTION_NAME ,
32
32
ACTIVATE_CONTROLLER_ACTION_TYPE ,
33
- SET_PARAMETERS_SERVICE_NAME ,
33
+ SET_PARAMETERS_SERVICE_TYPE ,
34
+ RETARE_FT_SENSOR_SERVICE_NAME ,
35
+ RETARE_FT_SENSOR_SERVICE_TYPE ,
34
36
INCREASED_FORCE_THRESHOLD ,
35
37
DEFAULT_FORCE_THRESHOLD ,
36
38
FORCE_THRESHOLD_PARAM
@@ -561,7 +563,7 @@ const TeleopSubcomponent = (props) => {
561
563
const [ forceThresholdIsIncreased , setForceThresholdIsIncreased ] = useState ( false )
562
564
let changeForceThresholdService = useMemo ( ( ) => {
563
565
let activeController = teleopMode === JOINT_MODE ? JOINT_CONTROLLER_NAME : CARTESIAN_CONTROLLER_NAME
564
- return createROSService ( ros . current , activeController + '/set_parameters_atomically' , SET_PARAMETERS_SERVICE_NAME )
566
+ return createROSService ( ros . current , activeController + '/set_parameters_atomically' , SET_PARAMETERS_SERVICE_TYPE )
565
567
} , [ ros , teleopMode ] )
566
568
const setForceThreshold = useCallback (
567
569
( threshold ) => {
@@ -585,6 +587,21 @@ const TeleopSubcomponent = (props) => {
585
587
}
586
588
} , [ props . allowIncreasingForceThreshold , setForceThreshold ] )
587
589
590
+ /**
591
+ * Service and callback for retaring the force-torque sensor.
592
+ */
593
+ let reTareService = useMemo ( ( ) => {
594
+ return createROSService ( ros . current , RETARE_FT_SENSOR_SERVICE_NAME , RETARE_FT_SENSOR_SERVICE_TYPE )
595
+ } , [ ros ] )
596
+ const reTareFTSensor = useCallback ( ( ) => {
597
+ let service = reTareService
598
+ let request = createROSServiceRequest ( { data : true } )
599
+ console . log ( 'Calling reTareFTSensor with request' , request )
600
+ service . callService ( request , ( response ) => {
601
+ console . log ( 'For reTareFTSensor request' , request , 'received response' , response )
602
+ } )
603
+ } , [ reTareService ] )
604
+
588
605
// Render the component
589
606
return (
590
607
< View
@@ -727,6 +744,36 @@ const TeleopSubcomponent = (props) => {
727
744
) : (
728
745
< > </ >
729
746
) }
747
+ { /* If the props specify, show a button to re-tare the force-torque sensor */ }
748
+ { props . allowRetaringFTSensor ? (
749
+ < View
750
+ style = { {
751
+ flex : 1 ,
752
+ flexDirection : 'row' ,
753
+ justifyContent : 'center' ,
754
+ alignItems : 'center' ,
755
+ width : '100%'
756
+ } }
757
+ >
758
+ < Button
759
+ variant = 'warning'
760
+ className = 'mx-2 mb-2 btn-huge'
761
+ size = 'lg'
762
+ style = { {
763
+ fontSize : ( textFontSize * 1.0 ) . toString ( ) + sizeSuffix ,
764
+ paddingTop : 0 ,
765
+ paddingBottom : 0 ,
766
+ margin : '0 !important' ,
767
+ width : '100%'
768
+ } }
769
+ onClick = { reTareFTSensor }
770
+ >
771
+ ⚖ Re-Zero Force Sensor
772
+ </ Button >
773
+ </ View >
774
+ ) : (
775
+ < > </ >
776
+ ) }
730
777
{ /* Render the controls for the mode */ }
731
778
< View
732
779
style = { {
@@ -753,11 +800,14 @@ TeleopSubcomponent.propTypes = {
753
800
// A function to be called when one of the teleop buttons are released
754
801
teleopButtonOnReleaseCallback : PropTypes . func ,
755
802
// Whether to allow the user to increase the force threshold
756
- allowIncreasingForceThreshold : PropTypes . bool
803
+ allowIncreasingForceThreshold : PropTypes . bool ,
804
+ // Whether to allow the user to retare the force-torque sensor
805
+ allowRetaringFTSensor : PropTypes . bool
757
806
}
758
807
TeleopSubcomponent . defaultProps = {
759
808
unmountCallback : { current : ( ) => { } } ,
760
809
teleopButtonOnReleaseCallback : ( ) => { } ,
761
- allowIncreasingForceThreshold : false
810
+ allowIncreasingForceThreshold : false ,
811
+ allowRetaringFTSensor : false
762
812
}
763
813
export default TeleopSubcomponent
0 commit comments