For this learning module, you will need:
______________________________________________________________________
Sunrise work bench is an IDE (integrated development environment) for programming KUKA’s range of collaborative robots. We use Sunrise to configure and manage the robots. It also provides tools for coding applications to run on the robots.
Sunrise supports the Java programming language. Writing Java is a direct way of programming the Collaborative Robots, and we recommend it for Pick and Place applications.
Whilst writing Java code can be tricky for non programmers (not to mention, experienced programmers also find Java quite tricky!) you don’t need a lot to get going with the basics.
Whilst the only place you can compile and test your code is in Sunrise, it is possible to compose your code in any text editor, we recommend using visual studio code . For undertaking a major programming project though it would be best to try using an IDE. We would recommend using Eclipse IDE to write your Java code as it it the IDE that Sunrise is based on.
This module only shows you the basics needed for a simple application, if you are confused, something isn't working for you, or you would like to use more advanced programming language features like creating your own variables or using an IF statements we recommend learning the basics of Java programming. You would be surprised what progress you can make in an hour and how much of a professional benefit programming skills can be. UNSW students have access to linked in learning, and you get get a 30 Day trial of Code Academy
Comments are messages you leave yourself and other programmers in the code. They have no impact on the code itself. There are single line comments (indicated with a //)
// I am a single line comment!
Multi line comments are useful when you have a lot to say, but even more so when you want to temporarily disable some code without deleting it, in case you want to re enable it later.
/*
And I am a
multi-line comment!
*/
Print line will pass a message to the Kuka Controller and display whilst your application is running. We like to include this for everything we do, it helps us determine what’s going on in the code as we run our programs.
System.out.println("Hello, world!");
White space in the code is completely ignored. So do not worry about the way your code is visually structured on the screen. Try and keep it organised though using indenting and line breaks to help you see the different parts of your code
Here is a sample application for a basic 'Pick and Place' application using the Robotiq Gripper 2F85 and the Vacuum Picker. You can use one of these as the basis of your application. See below for a description of the structure.
This is the name of the package (or folder) of which your application is located.
package application;
This section references the code (various classes and APIs etc ) used by the application. The robot needs this information to move, operate the gripper, send information to the controller etc. It's best not to take anything away from this list. If it's not needed in your application it will tell you but it doesn't effect the application.
If you are planning to utilise more advanced classes and methods, you may need to import code here.
In many editors, you will see + and - signs to the left of your text that will allow you to expand and collapse the content. You can do this to avoid accidentally editing content.
import javax.inject.Inject;
import robotiq.gripper.twoFingerF85.RobotiqGripper2F85;
import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
import static com.kuka.roboticsAPI.motionModel.BasicMotions.*;
import com.kuka.roboticsAPI.controllerModel.Controller;
import com.kuka.roboticsAPI.deviceModel.LBR;
import com.kuka.roboticsAPI.geometricModel.ObjectFrame;
This is the application header. This needs to exactly match your file name.
{ Notice the squiggly brackets? These encapsulate the entire class (and every class within this class) its important to ensure these brackets and the content get put in the correct place. Notice there's another bracket at the end of your application. }
public class PickAndPlace2FF85Gripper extends RoboticsAPIApplication {
This is where new variables can be declared.
This is where we set and initial values for variables needed throughout the application.
(for basic pick and place applications you wont need to use this generally)
@Inject
private Controller kukaController;
private LBR lBR_iiwa_14_R820_1;
private RobotiqGripper2F85 robotiqGripper;
@Override
public void initialize() {
kukaController = (Controller) getContext().getControllers().toArray()[0];
lBR_iiwa_14_R820_1 = (LBR) kukaController.getDevices().toArray()[0];
robotiqGripper = new RobotiqGripper2F85(kukaController);
Finally! This is where the sequence of the program takes place. For beginners, this is the main section of code you will work in.
Have a look at one of the blocks of code surrounded by white space, this is the basic structure we recommend:
System.out.println("Move To Pickup Position");
// Move to Pickup position
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/PickAndPlace1/Pickup/PickupSafe")).setJointVelocityRel(0.4));
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/PickAndPlace1/Pickup")).setJointVelocityRel(0.25));
You can see here the code is directing the iiwa robot to move point to point (ptp) to a frame (or point) you have created. The.setJointVelocityRel(0.4)
on the end means the robot will complete this motion at 40% of it's full speed.
public void run() {
robotiqGripper.activate();
robotiqGripper.waitForInitialization();
robotiqGripper.fullyOpen();
//Can be used to Fully open the gripper
lBR_iiwa_14_R820_1.move(ptpHome());
System.out.println("Move To Start Position");
// Move to Start position
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/PickAndPlace1/Start")).setBlendingRel(.5).setJointVelocityRel(0.4));
System.out.println("Move To Pickup Position");
// Move to Pickup position
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/PickAndPlace1/Pickup/PickupSafe")).setJointVelocityRel(0.4));
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/PickAndPlace1/Pickup")).setJointVelocityRel(0.25));
System.out.println("Gripper Closing");
// Grip Box
robotiqGripper.moveToCM(65, 10, 1);
robotiqGripper.waitForMoveEnd();
System.out.println("Point to Point motion");
// This is an example ptp motion
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/yourframe/inserthere"));
System.out.println("Linear Motion");
// This is an example Linear Motion
lBR_iiwa_14_R820_1.move(lin(getApplicationData().getFrame("/yourframe/inserthere")));
System.out.println("Circular Motion");
// This is an example circular motion
lBR_iiwa_14_R820_1.move(circ(getApplicationData().getFrame("/yourframe/inserthere"), getApplicationData().getFrame("/yourframe/inserthere")));
System.out.println("Spline Motion");
// Example spline motion
Spline mySpline = new Spline(
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")));
lBR_iiwa_14_R820_1.move(mySpline);
System.out.println("Spline Motion with circular and linear motions");
// Example Spline Motion with circular and linear motions included
Spline mySpline2 = new Spline (
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
circ(getApplicationData().getFrame("/yourframe/inserthere"),
getApplicationData().getFrame("/yourframe/inserthere")),
spl(getApplicationData().getFrame("/yourframe/inserthere")),
lin(getApplicationData().getFrame("/yourframe/inserthere")));
lBR_iiwa_14_R820_1.move(mySpline2);
System.out.println("Example Linear Motion with Velocity set to 0.4");
// Example linear motion at 40% joint velocity
lBR_iiwa_14_R820_1.move(lin(getApplicationData().getFrame("/yourframe/inserthere")).setJointVelocityRel(0.4));
System.out.println("Example Point to Point Motion with Blend set to 0.5");
//Example Linear motion with a blend of 50% at a velocity of 25%
lBR_iiwa_14_R820_1.move(ptp(getApplicationData().getFrame("/yourframe/inserthere")).setBlendingRel(.5).setJointVelocityRel(0.25));
______________________________________________________________________
The International Association for Robots in Architecture has created a plug in for Grasshopper called KUKA|prc. The aim of the association and KUKA|prc is to make the programming of KUKA Industrial robots and now also KUKA collaborative robots accessible to the creative industry. PRC stands for Procedural Robot Control.
KUKA|prc builds upon Grasshoppers accessible visual programming system which is part of the CAD software Rhino. It allows for parametric control with accurate simulation and quick optimisation.
Rhino must always be configured for the metric system using millimetres when using KUKA|prc. The easiest way to do this is when starting a new file select “Small Objects – Millimeters” template.
Once in Rhino select the Grasshopper icon from the right of the menu bar.
If you have the KUKA|prc plug in loaded it will be appear as a tab in Grasshopper.
The KUKA|prc menu is broken up into 5 shelves. These shelves are where the objects are listed by categories. Each shelf has sub tabs which show a limited numbers of items. To access all available components /parameters you may sometimes need to click on the black title bar at the bottom.
There are six shelves which organise the components in KUKA|prc, they are:
The component you always use in every definition is called the Core. It is what generates the KUKA Robot Language (KRL) code that runs on the robot. It also provides the graphical simulation of the robot motion inside Rhino. Everything else gets wired into this component.
The Core component takes five inputs. These are:
There are two output as well:
The gray KUKA|prc Settings label at the bottom of the Core component gives you access to its settings. Simply left click on the label and the dialog will appear.
The settings are organised into pages which you select from along the top edge of the dialog (Settings, Advanced, and Analysis). The dialog is modeless which means you can operate Rhino while it is open. To see the effect of your changes in the viewport click the Apply button.
There is a common set of components used in nearly all definitions for use with the robots. Here is an example of a very typical setup
The save your file ready to export to the robot. Under settings name the project and select a usb to save your file to. You should keep your name simple with no spaces
Make sure under advanced > code that sunrise is the export code and that the create frames is not ticked if you want to run straight on the robot. Ticked if you want the info to create frames in java.
Plug the USB straight into the robot and run the application PRCRun_Xml
______________________________________________________________________
______________________________________________________________________
This module is coming later next year.
In the meantime here's an introductory video about SprutCAM
______________________________________________________________________
This module is coming later next year.
In the meantime here's a video explaining ROS