-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demonstrates the use of client code with an actual service. Also upgrade Gradle and Android SDK version.
- Loading branch information
1 parent
51a0ddb
commit 46982cb
Showing
61 changed files
with
800 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.softbankrobotics.pddlplanning.example.client"> | ||
|
||
<!-- To be allowed to bind the planner service --> | ||
<uses-permission android:name="com.softbankrobotics.planning.SEARCH_PLANS" /> | ||
|
||
<!-- To see the planner service --> | ||
<queries> | ||
<package android:name="com.commonsware.android.r.embed.server" /> | ||
<intent> | ||
<action android:name="com.softbankrobotics.planning.action.SEARCH_PLANS_FROM_PDDL" /> | ||
</intent> | ||
<package android:name="com.softbankrobotics.pddlplanning.example.service" /> | ||
</queries> | ||
|
||
<application | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.Planning"> | ||
<activity | ||
android:name=".ExampleClientActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
75 changes: 75 additions & 0 deletions
75
...e/src/main/java/com/softbankrobotics/pddlplanning/example/client/ExampleClientActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.softbankrobotics.pddlplanning.example.client | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.softbankrobotics.pddlplanning.IPDDLPlannerService | ||
import com.softbankrobotics.pddlplanning.PermissionCheckFunction | ||
import com.softbankrobotics.pddlplanning.createPlanSearchFunctionFromService | ||
import com.softbankrobotics.pddlplanning.createPlannerPermissionChecker | ||
import com.softbankrobotics.pddlplanning.utils.createAsyncCoroutineScope | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
|
||
private const val plannerServicePackage = "com.softbankrobotics.pddlplanning.example.service" | ||
|
||
class ExampleClientActivity : AppCompatActivity() { | ||
|
||
private val coroutineScope = createAsyncCoroutineScope() | ||
private lateinit var permissionCheckFunction: PermissionCheckFunction | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_example_main) | ||
permissionCheckFunction = createPlannerPermissionChecker(this, plannerServicePackage) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
val mainText = findViewById<TextView>(R.id.mainText) | ||
mainText.text = "Searching plan..." | ||
val checkingPermission = permissionCheckFunction() | ||
coroutineScope.launch { | ||
checkingPermission.await() | ||
val plannerServiceIntent = Intent(IPDDLPlannerService.ACTION_SEARCH_PLANS_FROM_PDDL) | ||
plannerServiceIntent.`package` = plannerServicePackage | ||
val planSearchFunction = | ||
createPlanSearchFunctionFromService( | ||
this@ExampleClientActivity, | ||
plannerServiceIntent | ||
) | ||
val domain = "(define (domain hello_domain)\n" + | ||
" (:requirements :adl :negative-preconditions :universal-preconditions)\n" + | ||
" (:types)\n" + | ||
" (:constants)\n" | ||
" (:predicates\n" + | ||
" (was_greeted ?o)\n" + | ||
" )\n" + | ||
" (:action hello\n" + | ||
" :parameters (?o)\n" + | ||
" :precondition ()\n" + | ||
" :effect (was_greeted ?o)\n" + | ||
" )\n" + | ||
")" | ||
|
||
val problem = "(define (problem hello_problem)\n" + | ||
" (:domain hello_domain)\n" + | ||
" (:requirements :adl :negative-preconditions :universal-preconditions)\n" + | ||
" (:objects\n" + | ||
" world\n" + | ||
" )\n" + | ||
" (:init)\n" | ||
" (:goal\n" + | ||
" (forall (?o) (was_greeted ?o))\n" + | ||
" )\n" + | ||
")" | ||
|
||
val plan = planSearchFunction(domain, problem, null) | ||
|
||
runOnUiThread { | ||
mainText.text = "Found plan:\n${plan.joinToString("\n")}" | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Planning Client Example</string> | ||
</resources> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.pddl_planning_test"> | ||
|
||
</manifest> | ||
<manifest package="com.softbankrobotics.pddlplanning.test" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.