このページは英語でのみ提供されています。
Run a VAL 3 program
Load a VAL 3 project from the disk of the controller, start it, check its tasks and stop it, from C# or Python.
This article shows how to start and stop a VAL 3 program of a Staubli CS8 or CS9 controller from a PC, in C# or Python. It gives a complete program that loads a project from the disk of the controller, starts it, checks its tasks and stops it.
Prerequisites
- The SDK is connected to the controller: see Connect to your robot.
- The VAL 3 project is on the disk of the controller, for example
Disk://myProject/myProject.pjx. Copy it there with Staubli Robotics Suite or the pendant. - The user of the connection has the right to start applications. If the application moves the arm, the controller is in the mode that the application needs.
The calls
| Step | Method |
|---|---|
| See what is loaded and runs | GetValApplications() |
| Free the memory | StopAndUnloadAll() |
| Load a project | LoadProject(path) |
| Start it | StartApplication(path) |
| Check its tasks | GetTasks() |
| Pause or continue one task | TaskSuspend, TaskResume |
| Stop the application | StopApplication() |
Example
using UnderAutomation.Staubli;using UnderAutomation.Staubli.Soap.Data;using UnderAutomation.Staubli.Soap.Errors;public class HowToRunProgram{static void Main(){var controller = new StaubliController();controller.Connect("192.168.0.254");string project = "Disk://myProject/myProject.pjx";// 1. Stop what runs, and free the memorycontroller.Soap.StopAndUnloadAll();// 2. Load and start the applicationtry{controller.Soap.LoadProject(project);controller.Soap.StartApplication(project);}catch (CustomSoapException ex){// For example ApplicationNotFound or CannotStartApplicationConsole.WriteLine($"{ex.ErrorCode}: {ex.Description}");return;}// 3. Check that its tasks runThread.Sleep(500);foreach (ControllerTask task in controller.Soap.GetTasks())Console.WriteLine($"{task.Name}: {task.State}");// 4. Later, stop itcontroller.Soap.StopApplication();controller.Disconnect();}}
The program:
- stops and unloads what runs, so that the project loads in a known state;
- loads and starts the project, and prints the reason if the controller refuses;
- waits 500 ms and prints the state of each task;
- stops the application.
Follow the program
After the start, read the tasks with GetTasks(): State tells if a task runs, ProgramLine gives its current line, and RuntimeError is not 0 when the program stopped on an error. See Monitor the state of the robot.
Troubleshooting
CustomSoapExceptionwithApplicationNotFound: the path is wrong. Check the name of the folder and of the.pjxfile on the disk of the controller.CustomSoapExceptionwithCannotStartApplication: the controller cannot start the project in its current state, for example because another application runs. CallStopAndUnloadAll()first.- The task stops at once: read
RuntimeErrorandRuntimeErrorDescriptionof the task.
What to read next
- VAL 3 applications and VAL 3 tasks: the reference of these methods.