set Target Payload
Sets the mass, center of gravity (abbr. CoG) and the inertia matrix of the active payload. This function must be called when the payload mass,the mass displacement (CoG) or the inertia matrix changes - (i.e. when the robot picks up or puts down a workpiece)
Return
ArmState representing the current URScript command execution state, which is continuously updated.
Parameters
mass in kilograms
Center of Gravity, a vectorCoGx,CoGy,CoGz specifying the displacement (in meters) from the tool mount.
payload inertia matrix (in kg*m^2), as a vector with six elements Ixx,Iyy,Izz,Ixy,Ixz,Iyz with origin in the CoG and the axes aligned with the tool flange axes. Default is a sphere with 1g/cm3.
maximum time (in milliseconds) to wait for the command to complete. If this time is exceeded, the command is considered failed and the ArmState will no longer be updated.
⚠️ Experimental: optional callback that is invoked whenever the ArmState changes during execution. Can be used to track progress or react to state transitions in real time.
optional callback that is invoked once when the ArmState 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")
runBlocking {
ur.connect()
ur.isConnectedFlow.first { it }
val state = ur.arm.setTargetPayload(
m = 0.20f,
cog = Vec3(0.00, 0.00, 0.00),
inertia = null, // null corresponds to a sphere with 1g/cm3.
cmdTimeout = 5000,
onChange = null,
onFinished = { state -> /* Do something */ }
).await() // await for the finale state
println(state)
}
//sampleEnd
}