My issue does not really stem from any error in my code, but rather i do not understand the code my school is teaching me on a fundamental level. So if any of you work close with kuka robots or sunrise workbench I would really appreciate if you could help me with thes
package server;//where the application is located
import javax.inject.Inject;//for @inject functions
import com.kuka.nav.Location;
import com.kuka.nav.OrientationMode;
import com.kuka.nav.Orientations;
import com.kuka.nav.Pose;
import com.kuka.nav.XYTheta;
import com.kuka.nav.data.LocationData;
import com.kuka.nav.line.VirtualLine;
import com.kuka.nav.line.VirtualLineMotion;
import com.kuka.nav.rel.RelativeMotion;
import com.kuka.nav.robot.MobileRobot;
import com.kuka.nav.robot.MobileRobotManager;
import com.kuka.nav.task.NavTaskCategory;
import com.kuka.resource.locking.LockException;
import com.kuka.task.ITaskLogger;
import com.kuka.task.RoboticsAPITask;
@NavTaskCategory // the function dictates the nav server codes.
public class P01S_DMRO3A01_IsaiahYeong extends RoboticsAPITask {
// the roboticsapi task super class is used to create the public class called ex01relative motion
@Inject//inject is for a method
private MobileRobotManager _robMan; //for the sever, you need smth to manage it
private MobileRobot _rob;// To create a mobilerobot object called _ rob, also has a mobilerobot datatype
@Inject
private LocationData _locDat;
@Inject
private ITaskLogger _log;//communicates to console
private int _robotId;
// -------------------------------------------------------------------
@Override//meant for object
public void initialize() throws Exception {
// real robot ID 1
// a place to store variables
_robotId = 1; //tagging the robot with id number 1
_rob = _robMan.getRobot(_robotId);
_log.info("Initialize finished.");//to indicate in console that initialising is done
}
// -------------------------------------------------------------------
@Override
public void run() throws Exception {
_log.info("Starting application...");
try {
_rob.lock();//when the robot is locked you have control
executeViLiMoToPose();
} catch (LockException e) {
_log.error("Already locked.", e);
} catch (InterruptedException e) {
_log.error("Interrupted.", e);
} finally {
_rob.unlock();
}
_log.info("Application finished.");
}
// -------------------------------------------------------------------
private void executeViLiMoToPose() {
_log.info("Method executeApplication started.");
//Get locations
Location Home = _locDat.get(278); //get home location ID
Location goalLoc2 = _locDat.get(280); //get goal 2 location ID
//setting velocity
XYTheta vel = new XYTheta(0.2, 0.2, Math.toRadians(10));//setting velocity for x,y, theta
//move to home
VirtualLineMotion MotionHome = new VirtualLineMotion(_rob.getPose(),Home.getPose());
MotionHome.setVelocityOverride(vel);
_rob.execute(MotionHome);
//GOALPOSE 1
Pose StartPos = _rob.getPose();
Pose goalPose1 = new Pose(_rob.getPose().getX()+0.7, _rob.getPose().getY(),
_rob.getPose().getTheta());//gets its current position, when retrieving its x axis adds 0.8m and makes it goalPose1
//orientations
Orientations ori1 = Orientations.map(Math.toRadians(-30));//Creates a variable called ori1 that moves the robot -30 degrees theta
VirtualLine VirtLi1 = VirtualLine.from(StartPos.toPosition()).to(goalPose1.toPosition());// VirtLi1 is set to move to goalpose 1 from starting position using virtual line
VirtualLineMotion Motion1 = new VirtualLineMotion(VirtLi1,ori1 , OrientationMode.VARIABLE);//Motion 1 is created with Orientation and VirtLi data
Motion1.setVelocityOverride(vel);//velocity for Motion 1 is set
_rob.execute(Motion1);//Motion 1 is executed
//GOALPOSE 2
VirtualLineMotion Motion2 = new VirtualLineMotion(_rob.getPose(),goalLoc2.getPose());//gets its current position and gets the location of goalpose and figures out how to navigate the way there
Motion2.setVelocityOverride(vel);//velocity for Motion 2 is set
_rob.execute(Motion2);//Motion 2 is executed
//GOALPOSE 3
RelativeMotion Motion3 = new RelativeMotion(-0.7, 0, Math.toRadians(30));//moves the robot -0.8m on the x axis relative to where it currently is and rotates it 30 degrees relative to its prior orientation
Motion3.setVelocityOverride(vel);//velocity for Motion 3 is set
_rob.execute(Motion3);//Motion 3 is executed
//move back to home
VirtualLineMotion MotionHome2 = new VirtualLineMotion(_rob.getPose(),Home.getPose());//gets its current position and gets the location of Home and figures out how to navigate the way there
MotionHome2.setVelocityOverride(vel);//velocity for motionHome2 is set
_rob.execute(MotionHome2);//executes the command motionHome2
_log.info("program finished");
}
// -------------------------------------------------------------------
@Override
public void dispose() throws Exception {
_log.info("Dispose finished.");
}
}
The main things that will need explanation is Virtuallinemotion and //orientations part. feel free to correct any misunderstandings that you might see in the code above
I have tried looking for documentation on the libraries and functions and i could only find documentation for the iiwa arm hence why i am asking here instead. if documentation exists out there I would really appreciate if you could link them below. Thank you so much for your patience and kindness!
bap bop is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.