Skip to content

Commit

Permalink
Merge pull request #485 from robotemi/dev_sprint_135
Browse files Browse the repository at this point in the history
Sprint 135
  • Loading branch information
zjn0505 authored Dec 2, 2024
2 parents 7705723 + 3ac7d2e commit 337649b
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android.enableJetifier=true
kotlin.code.style=official

GROUP=com.robotemi
VERSION_NAME=1.134.1
VERSION_NAME=1.135.1
POM_URL=https://github.com/robotemi/sdk/
POM_SCM_URL=https://github.com/robotemi/sdk/
POM_SCM_CONNECTION=scm:git:git://github.com/robotemi/sdk.git
Expand Down
42 changes: 38 additions & 4 deletions sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import com.robotemi.sdk.telepresence.LinkBasedMeeting
import com.robotemi.sdk.telepresence.Participant
import com.robotemi.sdk.tourguide.TourModel
import com.robotemi.sdk.voice.ITtsService
import com.robotemi.sdk.voice.WakeupOrigin
import com.robotemi.sdk.voice.model.TtsVoice
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.group_app_and_permission.*
Expand Down Expand Up @@ -331,6 +332,10 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,

btnStopMovement.setOnClickListener { stopMovement() }
btnFollow.setOnClickListener { followMe() }
btnFollow.setOnLongClickListener {
followMe(SpeedLevel.HIGH)
true
}
btnskidJoy.setOnClickListener { skidJoy() }
btnskidJoyDialog.setOnClickListener {
val alert = AlertDialog.Builder(it.context)
Expand Down Expand Up @@ -470,6 +475,7 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
mediaPlayer.reset()
}
btnSetGoToSpeed.setOnClickListener { setGoToSpeed() }
btnSetFollowSpeed.setOnClickListener { setFollowSpeed() }
btnSetGoToSafety.setOnClickListener { setGoToSafety() }
btnToggleTopBadge.setOnClickListener { toggleTopBadge() }
btnToggleDetectionMode.setOnClickListener { toggleDetectionMode() }
Expand Down Expand Up @@ -586,6 +592,7 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
true
}
btnIsKioskModeOn.setOnClickListener { isKioskModeOn() }
btnCurrentHomeScreenMode.setOnClickListener { currentHomeScreenMode() }
btnEnabledLatinKeyboards.setOnClickListener { enabledLatinKeyboards() }
btnGetSupportedKeyboard.setOnClickListener { getSupportedLatinKeyboards() }
btnToggleGroundDepthCliff.setOnClickListener { toggleGroundDepthCliff() }
Expand Down Expand Up @@ -850,6 +857,10 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
printLog("Is kiosk mode on: ${robot.isKioskModeOn()}")
}

private fun currentHomeScreenMode() {
printLog("Current home screen mode: ${robot.getHomeScreenMode()}")
}

private fun toggleKiosk() {
robot.setKioskModeOn(!robot.isKioskModeOn())
}
Expand Down Expand Up @@ -1089,8 +1100,8 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
/**
* Simple follow me example.
*/
private fun followMe() {
robot.beWithMe()
private fun followMe(speedLevel: SpeedLevel? = null) {
robot.beWithMe(speedLevel)
hideKeyboard()
}

Expand Down Expand Up @@ -1298,9 +1309,9 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
robot.showTopBar()
}

override fun onWakeupWord(wakeupWord: String, direction: Int) {
override fun onWakeupWord(wakeupWord: String, direction: Int, origin: WakeupOrigin) {
// Do anything on wakeup. Follow, go to location, or even try creating dance moves.
printLog("onWakeupWord", "$wakeupWord, $direction")
printLog("onWakeupWord", "$wakeupWord, $direction, $origin")
}

override fun onTtsStatusChanged(ttsRequest: TtsRequest) {
Expand Down Expand Up @@ -1634,6 +1645,29 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
dialog.show()
}

private fun setFollowSpeed() {
if (requestPermissionIfNeeded(Permission.SETTINGS, REQUEST_CODE_NORMAL)) {
return
}
printLog("Current follow speed ${robot.getFollowSpeed()}")
val speedLevels: MutableList<String> = ArrayList()
speedLevels.add(SpeedLevel.HIGH.value)
speedLevels.add(SpeedLevel.MEDIUM.value)
speedLevels.add(SpeedLevel.SLOW.value)
val adapter = ArrayAdapter(this, R.layout.item_dialog_row, R.id.name, speedLevels)
val dialog = AlertDialog.Builder(this)
.setTitle("Select Follow Speed Level")
.setAdapter(adapter, null)
.create()
dialog.listView.onItemClickListener =
OnItemClickListener { _: AdapterView<*>?, _: View?, position: Int, _: Long ->
val resp = robot.setFollowSpeed(SpeedLevel.valueToEnum(adapter.getItem(position)!!))
printLog("Set follow speed to: ${adapter.getItem(position)}, response $resp")
dialog.dismiss()
}
dialog.show()
}

private fun setGoToSafety() {
if (requestPermissionIfNeeded(Permission.SETTINGS, REQUEST_CODE_NORMAL)) {
return
Expand Down
6 changes: 5 additions & 1 deletion sample/src/main/java/com/robotemi/sdk/sample/MapActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ class MapActivity : AppCompatActivity() {
val internalFiles = internalMapDirectory.listFiles()?.toList() ?: listOf()
val externalFiles = externalMapDirectory.listFiles()?.toList() ?: listOf()
val files = (internalFiles + externalFiles).filter {
it.isFile && it.path.endsWith("tar.gz", true)
it.isFile
&& (it.path.endsWith("tar.gz", true)
|| it.path.endsWith("zip", true)
|| it.path.endsWith("tgz", true)
|| it.path.endsWith("tar", true))
}

val builder = AlertDialog.Builder(this@MapActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.robotemi.sdk.SttLanguage
import com.robotemi.sdk.SttRequest
import com.robotemi.sdk.TtsRequest
import com.robotemi.sdk.constants.SequenceCommand
import com.robotemi.sdk.navigation.model.Position
import com.robotemi.sdk.voice.WakeupRequest

class TemiBroadcastReceiver : BroadcastReceiver() {
companion object {
Expand All @@ -23,6 +25,7 @@ class TemiBroadcastReceiver : BroadcastReceiver() {
private const val ACTION_MEETING = "temi.debug.meeting"
private const val ACTION_FACE = "temi.debug.face"
private const val ACTION_WAKE_UP = "temi.debug.wakeup"
private const val ACTION_GOTO = "temi.debug.goto"
}

override fun onReceive(context: Context?, intent: Intent?) {
Expand Down Expand Up @@ -168,8 +171,24 @@ class TemiBroadcastReceiver : BroadcastReceiver() {
)
15 -> Robot.getInstance().wakeup(listOf(SttLanguage.MS_MY, SttLanguage.RU_RU, SttLanguage.VI_VN))
16 -> Robot.getInstance().wakeup(listOf(SttLanguage.EL_GR))
17 -> Robot.getInstance().wakeup(listOf(SttLanguage.EL_GR), WakeupRequest(wakeupResponse = false))
18 -> Robot.getInstance().wakeup(listOf(SttLanguage.EL_GR), WakeupRequest(wakeupResponse = true))
}
}
ACTION_GOTO -> {
// adb shell am broadcast -a temi.debug.sdk --es action "temi.debug.goto" --ei test 1
val test = intent.getIntExtra("test", 1)
val robot = Robot.getInstance()
val position = robot.getPosition()
when (test) {
1 -> robot.goToPosition(position.copy(x = position.x + 0.5f))
2 -> robot.goToPosition(position.copy(x = position.x + 0.5f), highAccuracyArrival = true)
3 -> robot.goToPosition(position.copy(x = position.x + 0.5f, yaw = 999f), highAccuracyArrival = true)
4 -> robot.goTo("a")
5 -> robot.goTo("a", highAccuracyArrival = true)
6 -> robot.goTo("a", highAccuracyArrival = true, noRotationAtEnd = true)
7 -> robot.goTo("a", noRotationAtEnd = true)
}

}
}
}
Expand Down
5 changes: 5 additions & 0 deletions sample/src/main/res/layout/group_app_and_permission.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@
style="@style/ButtonCommon"
android:text="Is Kiosk Mode On" />

<Button
android:id="@+id/btnCurrentHomeScreenMode"
style="@style/ButtonCommon"
android:text="Current Home Screen Mode" />

</LinearLayout>
5 changes: 5 additions & 0 deletions sample/src/main/res/layout/group_settings_and_status.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@
style="@style/ButtonCommon"
android:text="Enable Hard Buttons" />

<Button
android:id="@+id/btnSetFollowSpeed"
style="@style/ButtonCommon"
android:text="Set Follow Speed" />

<Button
android:id="@+id/btnSetGoToSpeed"
style="@style/ButtonCommon"
Expand Down
15 changes: 11 additions & 4 deletions sdk/src/main/aidl/com/robotemi/sdk/ISdkService.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo;
import com.robotemi.sdk.ISdkServiceCallback;
import com.robotemi.sdk.SttRequest;
import com.robotemi.sdk.TtsRequest;
import com.robotemi.sdk.voice.WakeupRequest;
import com.robotemi.sdk.DisplayListRequest;
import com.robotemi.sdk.activitystream.ActivityStreamObject;
import com.robotemi.sdk.notification.AlertNotification;
Expand Down Expand Up @@ -96,7 +97,7 @@ interface ISdkService {
*
* @param location - Saved location name.
*/
void goTo(in String location, int backwards, int noBypass, in String speedLevel);
void goTo(in String location, int backwards, int noBypass, in String speedLevel, int highAccuracyArrival, int noRotationAtEnd);

/**
* Retrieve list of previously saved locations.
Expand All @@ -122,7 +123,7 @@ interface ISdkService {
/**
* Request robot to follow the user.
*/
void beWithMe();
void beWithMe(in String speedLevel);

void skidJoy(in float x, in float y, in boolean smart);

Expand Down Expand Up @@ -174,7 +175,7 @@ interface ISdkService {
*/
boolean deleteLocation(in String name);

void wakeup(in int[] languages, in SttRequest sttRequest);
void wakeup(in int[] languages, in SttRequest sttRequest, in WakeupRequest wakeupRequest);

String getWakeupWord();

Expand Down Expand Up @@ -247,7 +248,7 @@ interface ISdkService {

void playSequence(in String packageName, in String sequenceId, boolean withPlayer, int repeat);

void goToPosition(in Position position, int backwards, int noBypass, in String speedLevel);
void goToPosition(in Position position, int backwards, int noBypass, in String speedLevel, int highAccuracyArrival);

MapDataModel getMapData(in String packageName);

Expand Down Expand Up @@ -387,4 +388,10 @@ interface ISdkService {
String deleteMapLayer(in String packageName, in String layerId, int layerCategory);

String getHardButtonStatus(in String packageName, int type);

String setFollowSpeed(in String packageName, in String speedLevel);

String getFollowSpeed();

String getHomeScreenMode(in String packageName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.robotemi.sdk.exception.SdkException;

interface ISdkServiceCallback {

boolean onWakeupWord(in String wakeupWord, in int direction);
boolean onWakeupWord(in String wakeupWord, in int direction, in String origin);

boolean onTtsStatusChanged(in TtsRequest ttsRequest);

Expand Down
3 changes: 3 additions & 0 deletions sdk/src/main/aidl/com/robotemi/sdk/voice/WakeupRequest.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.robotemi.sdk.voice;

parcelable WakeupRequest;
Loading

0 comments on commit 337649b

Please sign in to comment.