seekGrip

abstract fun seekGrip(channel: Int, vacuum: Int, gripTimeout: Float = 3.0f, cmdTimeout: Long? = null, popupMsg: Boolean = true, onChange: (VGToolSeekState) -> Unit? = null, onFinished: (VGToolSeekState) -> Unit? = null): VGToolSeekState

Seek and grip an object using the vacuum VG gripper by moving along the Z-axis.

This method represents the seek grip operation of the OnRobot VGC10 and VG10 vacuum gripper. The gripper moves downward along the Z-axis for a defined path length and searches for an object. When a resistance is detected, the gripper automatically applies the specified vacuum to grip the object. This is useful for locating and picking up objects that may not be precisely positioned.

Return

VGToolSeekState continuously updated execution state of the URScript command.

Parameters

channel

vacuum channel to activate (0 = A; 1 = B; 2 = AB).

vacuum

target vacuum level (kPa) to apply once contact is detected.

gripTimeout

maximum time (seconds) to wait for the object to be gripped.

cmdTimeout

maximum time (milliseconds) to wait for the command to complete.

popupMsg

enable/disable popup messages on Polyscope.

onChange

⚠️ Experimental: optional callback invoked whenever the VGToolSeekState changes during execution. This API may change or be removed in future versions.

onFinished

optional callback that is invoked once when the VGToolSeekState is final. The state is final when runningState assumes the following value: RunningState.END, RunningState.TIMEOUT, RunningState.CANCELED

Samples

import com.wolfscowl.ur_client.UR
import com.wolfscowl.ur_client.examples.Examples.ur
import com.wolfscowl.ur_client.interfaces.state.await
import com.wolfscowl.ur_client.interfaces.state.awaitBlocking
import com.wolfscowl.ur_client.interfaces.state.awaitBlockingUntil
import com.wolfscowl.ur_client.interfaces.state.awaitUntil
import com.wolfscowl.ur_client.model.element.JointPosition
import com.wolfscowl.ur_client.model.element.Pose
import com.wolfscowl.ur_client.model.element.RunningState
import com.wolfscowl.ur_client.model.element.Vec3
import com.wolfscowl.ur_client.model.robot_state.mode.RobotMode
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlin.system.exitProcess

fun main() { 
   //sampleStart 
   val ur = UR("192.168.2.1")
val vg = ur.attachToolOnRobotVG(host = "192.168.2.2", toolIndex = 0)

runBlocking {
    ur.connect()
    ur.isConnectedFlow.first { it }
    val state = vg.seekGrip(
        channel = 2,
        vacuum = 80,
        gripTimeout = 2.0f,
        cmdTimeout = 5000,
        popupMsg = false,
        onChange = null,
        onFinished = { state -> /* do something */}
    ).await() // await for the finale state
    println(state)
} 
   //sampleEnd
}