UnderAutomation
¿Una pregunta?

[email protected]

Contactos
UnderAutomation
⌘Q
Esta página solo está disponible en inglés.

Motion

Power the arm, set the motion descriptor, send MoveJJ, MoveJC, MoveL and MoveC moves, then stop, restart or cancel them.

  • Prerequisites
  • Power
  • Motion descriptor
  • Moves
  • Stop, restart and cancel
  • Try it in the demo application
  • Reference

This page shows how to move a Staubli robot from a PC with the SDK: power the arm, describe the motion, send joint, linear and circular moves, then stop, restart or cancel them. The moves are executed by the motion planner of the CS8 or CS9 controller.

A robot is dangerous machinery. Test your code on the emulator of Staubli Robotics Suite first, then on the real robot with low speeds and a person at the emergency stop.

Prerequisites

  • The controller is in remote mode. Otherwise the power and the moves are refused.
  • The user of the connection has the right to move the arm.
  • The arm is powered: see below.

Power

SetPower(true) powers the arm, SetPower(false) switches it off. The answer tells if the controller accepted the request.

var controller = new StaubliController();
controller.Connect("192.168.0.254");
// The controller must be in remote mode
PowerReturnCode code = controller.Soap.SetPower(true);
if (code != PowerReturnCode.Success)
Console.WriteLine($"Arm not powered: {code}"); // OnlyInRemoteMode, EnableTimeout...
// Power off at the end
controller.Soap.SetPower(false);
controller.Disconnect();
}
Click to see the full code
PowerReturnCodeMeaning
SuccessDone
OnlyInRemoteModeThe controller is not in remote mode
RobotNotStoppedThe power cannot change while the arm moves
EnableTimeoutThe arm was not powered in time
DisableTimeoutThe arm was not switched off in time

Motion descriptor

Every move takes a MotionDesc: the speed limits, the blending, the tool, the reference frame and the configuration of the arm.

double[] joints = controller.Soap.GetCurrentJointPosition(robot: 0);
IForwardKinematics fk = controller.Soap.ForwardKinematics(robot: 0, joints);
var mdesc = new MotionDesc
{
// Limits of the joint speed, acceleration and deceleration
Velocity = 0.5,
Acceleration = 0.5,
Deceleration = 0.5,
// Limits of the speed of the tool center point
TranslationVelocity = 0.1,
RotationVelocity = 0.1,
// Stop at each point, no blending
BlendType = BlendType.BlendOff,
// Absolute target, flange as tool, world as reference frame
AbsRel = MoveType.Absolute,
Tool = new Frame(),
Frame = new Frame(),
// Keep the configuration of the arm (shoulder, elbow, wrist)
Config = fk.Config,
};
controller.Disconnect();
}
Click to see the full code
  • Velocity, Acceleration, Deceleration: limits of the joints.
  • TranslationVelocity, RotationVelocity: limits of the tool center point.
  • BlendType: BlendOff stops at each point. BlendJoint and BlendCartesian join the moves without a stop, from DistanceBlendPrevious before the point to DistanceBlendNext after it.
  • Tool and Frame: the tool center point and the reference frame of the Cartesian targets. new Frame() is the identity: the flange, and the world frame.
  • AbsRel: Absolute targets, or Relative to the current position.
  • Config: the configuration of the arm. See Kinematics.

Start with low values and increase them step by step. Check on the emulator that the speeds and distances are the ones you expect before the first move of a real robot.

Moves

MethodPathTarget
MoveJJ(robot, joints, mdesc)joint interpolationjoint values, in radians
MoveJC(robot, frame, mdesc)joint interpolationa Cartesian frame
MoveL(robot, frame, mdesc)straight linea Cartesian frame
MoveC(robot, frameB, frameC, mdesc)circle through frameBthe Cartesian frame frameC
Frame intermediate = controller.Soap.ForwardKinematics(robot: 0, joints).Position;
intermediate.Py += 0.05;
controller.Soap.SetPower(true);
// Joint move to joint values, in radians
IMoveResult result = controller.Soap.MoveJJ(robot: 0, joints, mdesc);
// Joint move to a Cartesian frame
result = controller.Soap.MoveJC(robot: 0, target, mdesc);
// Straight line to a Cartesian frame
result = controller.Soap.MoveL(robot: 0, target, mdesc);
// Circle through an intermediate frame, to a target frame
result = controller.Soap.MoveC(robot: 0, intermediate, target, mdesc);
// The controller accepted the move, or tells why not
if (result.ReturnCode != MotionReturnCode.Success)
Console.WriteLine($"Move {result.Id} refused: {result.ReturnCode}");
controller.Disconnect();
}
Click to see the full code

A move method returns the answer of the controller to the request. It does not tell that the arm has reached the target. IMoveResult.ReturnCode tells if the move was accepted, and Id identifies it:

MotionReturnCodeMeaning
SuccessThe move is accepted
NotReadyThe arm is not ready to move, for example not powered
ParameterErrorA value of the target or of the descriptor is wrong
MisuseErrorThe request is not allowed in this state
UnexpectedErrorAnother error of the controller

To wait for the end of a move, read the position until it reaches the target: see Position.

Stop, restart and cancel

var controller = new StaubliController();
controller.Connect("192.168.0.254");
// Stop the arm now
MotionReturnCode code = controller.Soap.StopMotion();
// Continue the moves that were stopped
code = controller.Soap.RestartMotion();
// Or cancel all the moves that are not finished
code = controller.Soap.ResetMotion();
controller.Disconnect();
}
Click to see the full code
  • StopMotion() stops the arm on its path.
  • RestartMotion() continues the moves that were stopped.
  • ResetMotion() cancels every move that is not finished. Call it after an error, before new moves.

Try it in the demo application

Everything on this page can be tried without writing code, in the Move the robot page of the demo application.

Move the robot page of the Staubli SDK demo application

The demo application is open source. The C# source of this page is MotionControl.cs.

Reference

Methods of SoapClientBase :
C#
// Move the robot to a target position using a Cartesian path
IMoveResult MoveC(int robot, Frame frameB, Frame frameC, MotionDesc mdesc);
// Move the robot to a target position using a Cartesian path with joint constraints
IMoveResult MoveJC(int robot, Frame frame, MotionDesc mdesc);
// Move the robot to a target position using joint positions
IMoveResult MoveJJ(int robot, double[] joints, MotionDesc mdesc);
// Move the robot to a target position using a linear path in Cartesian space
IMoveResult MoveL(int robot, Frame frame, MotionDesc mdesc);
// Reset the motion of the robot
MotionReturnCode ResetMotion();
// Restart the motion of the robot
MotionReturnCode RestartMotion();
// Set the power state of the robot (controller mut be in remote mode)
PowerReturnCode SetPower(bool power);
// Stop the motion of the robot immediately
MotionReturnCode StopMotion();
Class
MotionDesc
C#Python

Describes the parameters of a robot motion, including tool, frame, velocity, acceleration, blending and configuration.

MemberTypeDescription
MotionDesc()
Constructor
Initializes a new instance of the MotionDesc class.
AbsRel
Property
MoveType
Specifies whether the motion is defined in absolute or relative terms.
Acceleration
Property
double
Maximum allowed joint acceleration, as a percentage of the robot's nominal acceleration.
BlendType
Property
BlendType
Specifies the type of blending to be applied when transitioning between motion segments.
Config
Property
Config
Contains additional configuration parameters specific to the robot type, such as anthropomorphic, SCARA, or VRBX configurations.
Deceleration
Property
double
Maximum allowed joint deceleration, as a percentage of the robot's nominal deceleration.
DistanceBlendNext
Property
double
In joint and Cartesian blending modes, the distance between the target point where blending ends and the next point, in millimeters or inches, depending on the length unit of the application.
DistanceBlendPrevious
Property
double
In the joint and Cartesian blending modes, the distance between the target point where blending begins and the next point, in millimeters or inches, depending on the length unit used in the application.
Frame
Property
Frame
Defines the frame in which the tool position is located, including both position and orientation.
Frequency
Property
double
Frequency of motion in Hz.
RotationVelocity
Property
double
Maximum permitted tool rotation speed, in degrees per second.
Tool
Property
Frame
Defines the pose of the robot's tool center point (TCP) in flange, including both position and orientation.
TranslationVelocity
Property
double
Maximum allowed feed rate of the tool center, in mm/s or inches/s depending on the length unit of the application.
Velocity
Property
double
Maximum allowable joint speed, as a percentage of the robot's nominal speed.
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Interface
IMoveResult
C#Python

Represents the result of a robot motion command.

MemberTypeDescription
Id
Property
read only
int
Identifier of the motion command.
ReturnCode
Property
read only
MotionReturnCode
Return code indicating the outcome of the motion command.
Enum
MotionReturnCode
C#Python

Return code for robot motion commands.

NameValueDescription
MisuseError
3
Motion command misuse error.
NotReady
1
The robot is not ready to execute motion.
ParameterError
2
Invalid parameter provided to the motion command.
Success
0
Success, no error occurred.
UnexpectedError
4
An unexpected error occurred during motion.
Enum
PowerReturnCode
C#Python

Return code for robot power commands.

NameValueDescription
DisableTimeout
3
Timeout while disabling power.
EnableTimeout
2
Timeout while enabling power.
OnlyInRemoteMode
4
Power can only be changed in remote mode.
RobotNotStopped
1
Cannot change power while the robot is not stopped.
Success
0
Success, no error occurred.
Enum
BlendType
C#Python

Blend mode used during motion transitions between segments.

NameValueDescription
BlendCartesian
2
Cartesian-space blending between motion segments.
BlendJoint
1
Joint-space blending between motion segments.
BlendOff
0
No blending; the robot stops at each target point.
Enum
MoveType
C#Python

Specifies whether the motion is absolute or relative.

NameValueDescription
Absolute
0
Absolute motion in the reference frame.
Relative
1
Relative motion from the current position.

Integre fácilmente robots Universal Robots, Fanuc, Yaskawa, ABB o Staubli en sus aplicaciones .NET, Python, LabVIEW o Matlab

UnderAutomation
ContactosLegal

© All rights reserved.