Text-based Programming¶
Within the graphical programming environment Text-based Programming is also possible. One can use the Function Node to write code within a flow. If the Function Node is wired within a robot flow, one can access the robot object:
The robot is able to execute the following functions:
/**
* Sends the robot the command to move to an absolute position in joint space, approaching the waypoint with the
* specified mode, velocity and acceleration.
* @param {Array<number>} values - The values specify the desired absolute joint values for the robot joints in
* Euler angels, starting at the joint mounted closest to the robot base.
* @param {1|2} mode - The mode specifies how to approach the waypoint specified in
* this message. Available values are 1 for a point-to-point motion and 2 for a linear motion.
* @param {number} vel - The velocity approaching the waypoint. 0 equals 0% of the maximum available
* velocity of the robot and 255 equals 100% of it.
* @param {number} acc - The acceleration approaching the waypoint. 0 equals 0% of the maximum available
* acceleration of the robot and 255 equals 100% of it.
* @returns {Promise} - Returns a promise, which resolves when the robot executed the movement.
*/
setJoints(values, mode, vel, acc);
/**
* Sends the robot the command to move its end-effector to an absolute pose in Cartesian space, approaching the
* waypoint with the specified velocity and acceleration.
* The function returns a promise, which resolves when the robot executed the movement.
* @param {Array<number>} values - Values consists out of 6 numbers, the first three define the x,y and z
* position in meters in Cartesian space. The next three define the x,y and z orientation given in Euler angles.
* @param {1|2} mode - The mode specifies how to approach the waypoint specified in
* this message. Available values are 1 for a point-to-point motion and 2 for a linear motion.
* @param {number} vel - The velocity approaching the waypoint. 0 equals 0% of the maximum available
* velocity of the robot and 255 equals 100% of it.
* @param {number} acc - The acceleration approaching the waypoint. 0 equals 0% of the maximum available
* acceleration of the robot and 255 equals 100% of it.
* @returns {Promise} - Returns a promise, which resolves when the robot executed the movement.
*/
setPose(values, mode, vel, acc);
/**
* Sends the robot the command to set an analog or digital output to a specified value.
* @param {number} address - The address of the robot output.
* @param {number} value - The value to witch the output will be set.
* @returns {Promise} - Returns a promise, which resolves when the robot set the output as specified.
*/
setOutput(address, value);
/**
* Sends the robot the command to switch into gravity compensation mode, by which the robot joints can be moved
* by hand.
* @param {boolean} activate - Set to true/false if gravity compensation should be turned on/off.
* @returns {Promise} - Returns true if the robot was able to enter into the state of gravity compensation.
*/
setGravityComp(activate);
/**
* Sends the robot the command to switch into stop mode, in which no further commands can be executed and the
* robot can not be moved by hand.
* @param {boolean} activate - Set to true/false if stop state should be turned on/off.
* @returns {Promise} - Returns true if the robot was able to enter stop mode.
*/
setStop(activate);
/**
* The function returns all Euler angles of the robot joints.
* @returns {Array<number>} - Returns all Euler angles of the robot joints, starting at the joint mounted
* closest to the robot base.
*/
getJointValues();
/**
* The function returns the current absolute pose of the robot’s endeffector in Cartesian space.
* @returns {Array<number>} - Returns the current absolute pose of the robot’s endeffector in Cartesian space.
* The first three values of the output define the x,y and z position in meters in Cartesian space.
* The next three define the x,y and z orientation given in Euler angles.
*/
getPoseValues();
/**
* The function returns information on the current values of the robot inputs.
* @returns {Array<number>} - Returns the current input values.
*/
getInputs();
/**
* The function returns true if the system is currently connected to the robot.
* @returns {boolean} - Returns true if the system is currently connected to the robot.
*/
robotConnected();
/**
* The function returns the name of the running flow, if one exists.
* @returns {string} - Returns the name of the running flow, if one exists.
*/
getRunningFlow();
/**
* The function returns true if the robot is in gravity compensation mode.
* @returns {boolean} - Returns true if the robot is in gravity compensation mode.
*/
isGCom();
/**
* The function returns true if the robot is in stop mode.
* @returns {boolean} - Returns true if the robot is in stop mode.
*/
isStopped();
/**
* The function returns a promise which resolves, if access to the robot is available and the robot is then
* occupied. When the robot is occupied it can not be accessed.
* @param {boolean} name - The name of the current flow which requires to get access.
* @returns {Promise<EventEmitter>} - Returns a promise, which resolves when access to the robot is given.
* Through the EventEmitter access can be released again.
*/
getAccess(name);
/**
* The function releases access from the robot and sets the robot idle.
* @param {boolean} name - The name of the current flow which requires to get access.
* @returns {Promise<EventEmitter>} - Returns a promise, which resolves when access to the robot is given.
* Through the EventEmitter access can be released again.
*/
releaseAccess(resolveId);
/**
* The function takes in a function which will be called with the robot inputs as a parameter if the robot
* inputs change.
* @param {Function} callback - The function which will be called with the robot inputs as a parameter if the
* robot inputs change.
*/
subscribeInputChanges(callback);
/**
* The function modifies the overall possible velocity and acceleration of the robot.
* @param {Function} velocity - The overall possible velocity of the robot. 0 equals 0% of the maximum velocity
* and 255 equals 100% of it.
* @param {Function} acceleration - The overall possible acceleration of the robot. 0 equals 0% of the maximum
* acceleration and 255 equals 100% of it.
*/
modGlobalSpeed(velocity, acceleration);
/**
* Sends the robot a command specific to its custom interface.
* @param {Array|Buffer} message - The address of the robot output.
* @returns {Promise} - Returns a promise, which resolves when the command has been send.
*/
sendCommand(message);