Teaching Frames inside programs
In many applications, a robot should approach the same Frame multiple times and
maybe also from different starting points. As illustrated in Section 2.3.5, the robot
may choose different axis configurations each time this Frame is approached,
depending on the concrete starting point. This especially applies to LWRs, as their
elbow position may vary even for path motions.
To avoid that hint joints have to be specified each time a Frame is approached again,
those hint joints can be stored as TeachingInfo in the Frame itself in the following
way:
- Frame.addTeachingInfo(Device d, Frame mcp, double[] hint
stores the given hint array as hint joints in the Frame instance the method
is called on. This information is stored specifically for Device d and Motion
Center Point mcp that are supplied as further arguments. The information
will only be used if d is performing a motion to the augmented Frame
with the Frame mcp set as MCP.
- Frame.getTeachingInfo(Device d, Frame mcp queries a Frame for
TeachingInfo for a given Device d and Motion Center Point mcp. This is
done automatically by motion Activities that use a Frame as motion goal.
In cases where the current position of a robot should be memorized in a program to
be approached again later, the DeviceInterfaces PtpInterface, LinInterface and
MotionInterface provide a method touchup(). This method creates a new temporary
Frame that stores the current position of the robot’s default MCP relative to its base
Frame. The newly created Frame is furthermore augmented by the current robot’s
joint positions as TeachingInfo for the robot and its MCP. The overload
touchup(Frame mcp) can be used to do the same for the supplied MCP instead of
the robot’s default one.
Here is another Democode using the LWR:
public void demo_TeachingFrames() throws RoboticsException { // Generate an Interface, as usual // let the robot drive to a location first, to avoid singularity problems PtpInterface left = lwrLeft.use(PtpInterface.class); RtActivity leftOne = left.ptp(new double[] { -1.5, 0.8, 0, -1.5, 0, 0.8, 0 }); leftOne.execute(); // Create the Frame you want the Device to memorize // and just to be sure, take a snapshot... // Remember that we use the FingerCenter of the left arm as our // MotionCenterFrame. Frame finger = wsgLeft.getFingerCenter(); Frame fingerFixed = finger.snapshot(World.getOrigin()); // Now that we have a Frame, we need to link the Joints // of the robot to it. The best way to do this // is the .getJointAngles()-Method // It reads the current state of each Joint the Device has, // and returns an Array that is ready to use for the next step double[] memoryJoints = lwrLeft.getJointAngles(); // Take your Frame and link it to a Device, a Frame (most of the time itself) // and an Array that contains the position of the Joints (the one we created) fingerFixed.addTeachingInfo(lwrLeft, finger, memoryJoints); // Now we are ready to test it // Let the Robot drive around a bit RtActivity leftTwo = left.ptp(new double[] {-0.5,0.8,0,-1.5,0,-0.5,-1}); leftTwo.execute(); // And then create a RtActivity with our Frame. // It will drive to the memorized position and will // use the Array to adopt the exact same posture we saved RtActivity reEnter = left.ptp(fingerFixed); reEnter.execute(); // Once such a point is memorized, the robot // is even able to drive to the Frame // from its Home-Position without causing // a Singularity left.ptpHome().execute(); RtActivity reEnterSecondTime = left.ptp(fingerFixed); reEnterSecondTime.execute(); // repeat RtActivity leftThree = left.ptp(new double[] {-2,-0.4,0,1,0.5,-0.5,-1}); leftThree.execute(); RtActivity reEnterThirdTime = left.ptp(fingerFixed); reEnterThirdTime.execute(); RtActivity leftFour = left.ptp(new double[] {-2.5,1,0,0,0,0.8,0}); leftFour.execute(); RtActivity reEnterFourthTime = left.ptp(fingerFixed); reEnterFourthTime.execute(); }