Debug: breakpoints and step mode
Add and remove breakpoints, switch the step mode and continue a stopped program, for the controller or for one task, with robot.Debug. Brand support table, C# and Python examples.
robot.Debug debugs the programs of a robot controller from a PC: breakpoints, step mode and continue, for the whole controller or for one task. The support is partial and depends on the brand: some brands have a route for a few of these methods only, and some have none. See the table below.
Prerequisites
- A connected
RobotController. See Connect to your robot. - The license of the brand of the controller, or the 30 day trial. See Licensing.
- A program that runs or that you start with Program. A program is named with its native name, as the controller names it. Lines are counted from 1.
Brand support
Each cell gives the protocol that the method uses on this brand, in the default order. The page Routing explains how the library chooses it. The table is generated from the route data of the library. (manual) marks a route that you enable yourself. "n of m" is the number of methods of the service that have a route on this brand.
| Method | Fanuc | Yaskawa | Universal Robots | ABB | Stäubli |
|---|---|---|---|---|---|
| Debug.AddBreakpoint | CGTP (CgtpKcl), Telnet | Not available | Primary Interface (Primary) | Robot Web Services | Not available |
| Debug.RemoveBreakpoint | CGTP (CgtpKcl), Telnet | Not available | Primary Interface (Primary) | Not available | Not available |
| Debug.ReadBreakpoints | CGTP (CgtpKcl), Telnet | Not available | Not available | Robot Web Services | Not available |
| Debug.SetStepMode | CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Primary Interface (Primary) | Robot Web Services | Not available |
| Debug.Continue | CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Primary Interface (Primary) | Robot Web Services | Not available |
| Debug.SetTaskStepMode | CGTP (CgtpKcl), Telnet | Not available | Not available | Not available | Not available |
| Debug.ContinueTask | CGTP (CgtpKcl), Telnet | Not available | Not available | Not available | Not available |
| Debug | 7 of 7 | 2 of 7 | 4 of 7 | 4 of 7 | 0 of 7 |
A brand that has no route for a method throws FeatureNotSupportedException (see Errors). Ask robot.Debug.IsAvailable(DebugFeature.AddBreakpoint) before the call.
Example
Breakpoints
AddBreakpoint adds a breakpoint at a line of a program, RemoveBreakpoint removes it and ReadBreakpoints returns the lines of the breakpoints of a program.
RobotController robot = new RobotController();robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));robot.Debug.AddBreakpoint("MAIN", 12);foreach (int line in robot.Debug.ReadBreakpoints("MAIN"))Console.WriteLine($"Breakpoint at line {line}");robot.Debug.RemoveBreakpoint("MAIN", 12);robot.Disconnect();}
Step mode
In step mode, the program stops after each instruction and Continue runs the next one. Use these two methods for a debug session. Depending on the brand, SetStepMode sets the cycle mode of the controller (as Program.SetCycleMode with CycleMode.Step) or only changes how Continue runs. SetStepMode(false) goes back to the continuous execution.
A program paused by Program.Pause or Program.Hold continues with Program.Resume, not with Continue.
RobotController robot = new RobotController();robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));robot.Debug.SetStepMode(true);// A program stopped on a breakpoint or in step mode goes to the next linerobot.Debug.Continue();robot.Debug.SetStepMode(false);robot.Disconnect();}
One task
SetTaskStepMode and ContinueTask only have a route on Fanuc today: see the table. On a controller with several tasks, SetTaskStepMode switches the step mode of one task and the other tasks keep their mode. ContinueTask runs the next instruction of this task, and the other paused tasks stay paused. A brand can refuse SetTaskStepMode(task, false) with an ArgumentException when its controller turns the step mode off for every task only: use SetStepMode(false) then. Check IsAvailable(DebugFeature.SetTaskStepMode) first.
Reference
In Python, the names are in snake_case: robot.debug.add_breakpoint(...), robot.debug.read_breakpoints(...), robot.debug.set_step_mode(True), robot.debug.set_task_step_mode(...), robot.debug.continue_task(...). continue is a reserved word of Python: the method is robot.debug.continue_(). The enum members keep their names.
Methods of IDebugService
Debug service of a robot controller: breakpoints and step mode. The library implements this interface. A minor version of the library can add members to it: a class of the application that implements it, for example a test double, then needs the new methods. Errors of the methods other than IsAvailable: FeatureNotSupportedException when the brand has no route for the method, RouteUnavailableException when the method has routes but none of them can be used, ControllerRefusedException when the controller received the command and refused it, RobotControllerException when the route failed (the inner exception is the exception of the brand SDK), and ArgumentException or a derived exception for an invalid argument. IsAvailable only throws ArgumentOutOfRangeException, for a value that is not in the enum. Results: a text and an array are empty when there is no value, never null. The only null values are the Native properties when there is no object of the brand SDK, and Position when the variable is not a position.
| Member | Type | Description |
|---|---|---|
AddBreakpoint(string, int) Method | void | Adds a breakpoint
|
Continue() Method | void | Continues the program stopped on a breakpoint or in step mode. A program paused by Pause or Hold continues with Resume. |
ContinueTask(string) Method | void | Continues one task stopped on a breakpoint or in step mode. The other paused tasks stay paused.
|
IsAvailable(DebugFeature) Method | bool | Returns true when the method can be called on the connected controller. The answer depends on the brand, on the routing settings and on the protocols that answered at the connection, not on the state of the controller.
|
ReadBreakpoints(string) Method | int[] | Returns the lines of the breakpoints of a program
|
RemoveBreakpoint(string, int) Method | void | Removes a breakpoint
|
SetStepMode(bool) Method | void | Switches the step mode on or off. In step mode, the program stops after each instruction and Continue runs the next one. Use it for a debug session. Depending on the brand, it sets the cycle mode of the controller (as SetCycleMode(CycleMode) with Step) or only changes how Continue runs. False goes back to the continuous execution.
|
SetTaskStepMode(string, bool) Method | void | Switches the step mode of one task on or off. The other tasks keep their mode. ContinueTask(string) runs the next instruction of the task. A brand can refuse "off" with an ArgumentException when its controller turns the step mode off for every task only: use SetStepMode(bool) then.
|
Errors
The page Errors explains each exception and how to avoid it.
FeatureNotSupportedException: the brand has no route for the method.RouteUnavailableException: the method has routes, but none of them can be used, for example because the protocol did not answer at the connection.ControllerRefusedException: the controller received the command and refused it.RobotControllerException: the route failed. Its inner exception is the exception of the brand SDK.ArgumentException: an invalid argument, for example a task step mode that the controller refuses.
IsAvailable only throws ArgumentOutOfRangeException, for a value that is not in the enum.