Skip to content

Commit 0cfc11e

Browse files
committed
add method: sendActionToAgent()
1 parent 9118906 commit 0cfc11e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

controller-application/Police/app/src/main/java/io/github/xei/police/joystick/JoystickContract.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface JoystickContract {
3030

3131
interface Presenter : BasePresenter {
3232
fun makePolicy(state: State)
33+
fun sendActionToAgent(action: Action)
3334
fun performVoiceCommand(recognizedCommand: String)
3435
}
3536
}

controller-application/Police/app/src/main/java/io/github/xei/police/joystick/JoystickPresenter.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.xei.police.joystick
22

3+
import io.github.xei.police.app.Action
34
import io.github.xei.police.app.State
45
import io.github.xei.police.exception.BluetoothNotSupportException
56

@@ -30,9 +31,23 @@ class JoystickPresenter(private val model: JoystickContract.Model, private val v
3031

3132
override fun makePolicy(state: State) {
3233
// TODO: make policy based on the sensors state
34+
val action = Action()
35+
sendActionToAgent(action)
36+
}
37+
38+
override fun sendActionToAgent(action: Action) {
39+
if (view.isActive) {
40+
view.sendActionToAgent(action)
41+
}
3342
}
3443

3544
override fun performVoiceCommand(recognizedCommand: String) {
45+
46+
when (recognizedCommand) {
47+
"Go straight" -> sendActionToAgent(Action())
48+
"Come back" -> sendActionToAgent(Action())
49+
}
50+
3651
if (view.isActive) {
3752
view.showToast(recognizedCommand)
3853
}

0 commit comments

Comments
 (0)