@@ -8,7 +8,7 @@ import { calculateDesiredMotion } from "./rovUtil";
8
8
import type { buttonChangeDetails } from "virtual-gamepad-lib" ;
9
9
import { ConnectionStates } from "./shared/consts" ;
10
10
import type { FlightMode } from "./shared/mavlink2RestMessages" ;
11
- import { GPAD_STANDARD_BUTTON_INDEX , GPAD_STANDARD_BUTTON_INDEX_TO_MAVLINK_INDEX , MOVE_MSG_TIMEOUT } from "./frontendConsts" ;
11
+ import { GPAD_STANDARD_BUTTON_INDEX , GPAD_STANDARD_BUTTON_INDEX_TO_MAVLINK_INDEX , MOVE_MSG_TIMEOUT , PING_INTERVAL } from "./frontendConsts" ;
12
12
13
13
class RovActionsClass {
14
14
@@ -32,6 +32,8 @@ class RovActionsClass {
32
32
const BTN_Y = GPAD_STANDARD_BUTTON_INDEX . Y
33
33
const BTN_LT = GPAD_STANDARD_BUTTON_INDEX . LT
34
34
const BTN_RT = GPAD_STANDARD_BUTTON_INDEX . RT
35
+ const BTN_RB = GPAD_STANDARD_BUTTON_INDEX . RB
36
+ const BTN_LB = GPAD_STANDARD_BUTTON_INDEX . LB
35
37
36
38
if ( buttonsChangedMask [ BTN_A ] && buttonsChangedMask [ BTN_A ] . released ) {
37
39
this . takeControl ( )
@@ -47,7 +49,8 @@ class RovActionsClass {
47
49
// do something with throttle
48
50
}
49
51
50
- const rawExcludedButtons = [ BTN_A , BTN_B , BTN_LT , BTN_RT ] ;
52
+ // FIXME: this is a hack to get the buttons to work with the mavlink message
53
+ const rawExcludedButtons = [ BTN_A , BTN_B , BTN_LT , BTN_RT , BTN_LB , BTN_RB ] ;
51
54
const pressedButtons = buttonsChangedMask . map ( ( val , index ) => {
52
55
if ( val === false ) return false ;
53
56
if ( rawExcludedButtons . includes ( index ) ) return false ;
@@ -90,7 +93,7 @@ class RovActionsClass {
90
93
this . requiredMsgsLoopIntervalId = Number ( setInterval ( ( ) => {
91
94
if ( frontendConnMngr . connectionState . get ( ) != ConnectionStates . connected ) return ;
92
95
const now = Date . now ( ) ;
93
- if ( now - this . lastPingTime > MOVE_MSG_TIMEOUT ) {
96
+ if ( now - this . lastPingTime > PING_INTERVAL ) {
94
97
frontendRovMsgHandler . sendRovMessage ( { Ping : { Time : Date . now ( ) } } , null ) ;
95
98
this . lastPingTime = now ;
96
99
}
@@ -132,13 +135,15 @@ class RovActionsClass {
132
135
}
133
136
134
137
moveRov ( VelocityX , VelocityY , VelocityZ , AngularVelocityYaw , btnBitmask : number = - 1 ) {
138
+ // FIXME: this is a hack to get the buttons to work with the mavlink message
135
139
const ButtonBitmask = btnBitmask === - 1 ? this . lastMove . ButtonBitmask : btnBitmask ;
136
140
const movementDelta = ( VelocityX - this . lastMove . VelocityX ) + ( VelocityY - this . lastMove . VelocityY ) + ( VelocityZ - this . lastMove . VelocityZ ) + ( AngularVelocityYaw - this . lastMove . AngularVelocityYaw ) ;
137
141
const totalMovement = Math . abs ( VelocityX ) + Math . abs ( VelocityY ) + Math . abs ( VelocityZ ) + Math . abs ( AngularVelocityYaw ) ;
138
- const timeSinceLastMoveCmd = Date . now ( ) - this . lastMovementTime ;
139
- if ( totalMovement > 0.1 && movementDelta < 0.01 && timeSinceLastMoveCmd < 400 ) return ;
140
- frontendRovMsgHandler . sendRovMessage ( { Move : { VelocityX, VelocityY, VelocityZ, AngularVelocityYaw } } , null ) ;
141
- this . lastMove = { VelocityX, VelocityY, VelocityZ, AngularVelocityYaw, ButtonBitmask } ;
142
+ // const timeSinceLastMoveCmd = Date.now() - this.lastMovementTime;
143
+ // if (totalMovement > 0.1 && movementDelta < 0.01 && timeSinceLastMoveCmd < 400) return;
144
+ const move = { VelocityX : VelocityY * 2 , VelocityY : VelocityX , VelocityZ, AngularVelocityYaw, ButtonBitmask }
145
+ frontendRovMsgHandler . sendRovMessage ( { Move : move } , null ) ;
146
+ this . lastMove = move ;
142
147
this . lastMovementTime = Date . now ( ) ;
143
148
}
144
149
0 commit comments