Created
July 13, 2023 15:24
-
-
Save AdoHaha/6a9c0d6559d082b239b1256cbb845f3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import com.kuka.roboticsAPI.geometricModel.Frame; | |
import com.kuka.roboticsAPI.geometricModel.Tool; | |
import com.kuka.roboticsAPI.geometricModel.math.CoordinateAxis; | |
import com.kuka.roboticsAPI.geometricModel.math.Transformation; | |
import com.kuka.roboticsAPI.motionModel.CartesianImpedanceControlMode; | |
// Assuming you've already set up the robot object | |
private LBR robot; | |
private Tool plastik1; | |
@Override | |
public void initialize() { | |
// Initialize the robot and tool | |
robot = getContext().getDeviceFromType(LBR.class); | |
plastik1 = getApplicationData().createFromTemplate("plastik1"); | |
} | |
@Override | |
public void run() { | |
plastik1.attachTo(robot.getFlange()); | |
while (true) { | |
// Get external wrench (force and torque) at the robot's flange | |
Wrench flangeWrench = robot.getExternalWrench(); | |
// Get transformation between flange and tool | |
Frame flangeToTool = plastik1.getLoadData().getCenterOfMass().copyWithRedundancy(); | |
// Transform the wrench to the tool frame | |
Wrench toolWrench = flangeWrench.changeSystem(flangeToTool); | |
// Get force and torque components | |
double[] toolForce = toolWrench.getForce().getArray(); | |
double[] toolTorque = toolWrench.getTorque().getArray(); | |
// Use or store these values as you like | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment