keecker / services-api

Keecker Services API
Other
5 stars 1 forks source link

Disabling obstacle avoidance algorithm #2

Open daniploeger opened 4 years ago

daniploeger commented 4 years ago

Dear Cyril,

I am developing a (basic) Keecker app for an artwork I am making in collaboration with V2_Lab for the unstable media in Rotterdam. Jan Misker, who asked you a question previously, was also working on this.

You mentioned the following in your response to him: "If some obstacles are nearby, the obstacles avoidance algorithm will do strange things. [...] I think there was nothing in the public API allowing you to disable the obstacles avoidance, I can check for a way to do it if you need." Do you think you could still help us with this?

Very best and many thanks, Dani

cyril-L commented 4 years ago

Hello, I exposed the MovementClient.disableAvoidance() method in the dev/disable_avoidance branch. You can get this branch by using the following dependency:

implementation 'com.github.keecker:services-api:dev~disable_avoidance-SNAPSHOT'

I think you have to call disableAvoidance(true) before each movement command, and that it only has effects for relative movements. When enabled, the movement planner should no longer add obstacles in its map, but the low level safeties will remain enabled. I can also check how to disable those if you need.

Sorry for the delay!

daniploeger commented 4 years ago

Thanks for the response and the adjustments!

I have added the implementation to the build.gradle and am calling disableAvoidance as outlined below. But it gives me an 'unresolved reference.' Is this not the correct way to do it?

fun moveKeecker() {
        val mover = KeeckerServices.getMovementClient(applicationContext)
        GlobalScope.launch(Dispatchers.IO) {
            while (true) {
                mover.disableAvoidance(true)
                mover.goToRelative(0.0, 0.0, 0.1)
                delay(5000)
            }
        }
    }
cyril-L commented 4 years ago

Did the unresolved reference happen on compile or run? I can compile the following code, but I did not try it on keecker:

fun moveKeecker(context: Context) {
    val mover = KeeckerServices.getMovementClient(context)
    GlobalScope.launch(Dispatchers.IO) {
        while (true) {
            mover.disableAvoidance(true)
            mover.goToRelative(0.0, 0.0, 0.1)
            delay(5000)
        }
    }
}

Maybe you need to add the kotlin coroutines dependency like this:

dependencies {
    implementation 'com.github.keecker:services-api:dev~disable_avoidance-SNAPSHOT'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
    …
}
daniploeger commented 4 years ago

Hi,

Thanks for looking into this again. The unresolved reference appears in the compiler. I have added the dependencies exactly as you outlined.

Android Studio points out that a newer version of disable_avoidance-SNAPSHOT is available: 1.0.3

I tried adding it like this, to see if that would solve the problem: implementation 'com.github.keecker:services-api:dev~disable_avoidance-SNAPSHOT:1.0.3'

But that gives the following error:

Unable to build Kotlin project configuration Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':app:debugImplementationDependenciesMetadata'. Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find services-api-1.0.3.jar (com.github.keecker:services-api:1.0.3). Searched in the following locations: https://jitpack.io/com/github/keecker/services-api/1.0.3/services-api-1.0.3-1.0.3.jar

cyril-L commented 4 years ago

Hello, I tried it again and it compiles on my system, from a new Android TV app with the default activity. Are you sure that you added the JitPack repository in the top level build.gradle file ?

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

In a new sample app the dependencies in the app build.gradle looks like this for me. Can you check that you have the exact same two bottom lines?

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.leanback:leanback:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.github.bumptech.glide:glide:3.8.0'

    implementation 'com.github.keecker:services-api:dev~disable_avoidance-SNAPSHOT'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
}