Learn Environment
task_executor.hpp
Go to the documentation of this file.
1 #ifndef TASK_EXECUTOR_HPP
2 #define TASK_EXECUTOR_HPP
3 
4 #include "common/task.hpp"
5 
6 #include <QObject>
7 #include <QString>
8 #include <QSharedPointer>
9 
10 class ScriptWorker;
11 
19 class TaskExecutor : public QObject {
20  Q_OBJECT
21 
22 public:
27  explicit TaskExecutor(QObject *parent = nullptr);
28 
33  void executeTask(const Subtask &subtask, bool startSolution = false);
34 
38  void forceStop();
39 
43  void resetRobot();
44 
45 Q_SIGNALS:
49  void taskExecutionStarted();
50 
54  void taskExecutionFinished();
55 
60  void taskExecutionFailed(const QString &error);
61 
65  void resetRobotStarted();
66 
70  void resetRobotFinished();
71 
76  void resetRobotFailed(const QString &error);
77 
78 private:
88  bool constructPath(const QString &basePath, const QString &addition, QString &result, const QString &errorMsg, bool checkExists = true);
89 
90  QList<ScriptWorker*> scriptWorkers;
91 };
92 
93 #endif // TASK_EXECUTOR_HPP
QObject
TaskExecutor::resetRobotStarted
void resetRobotStarted()
Signal emitted when robot reset starts.
Subtask::evaluationFilePath
QString evaluationFilePath
The file path to the evaluation script of the subtask.
Definition: task.hpp:37
task.hpp
ScriptWorker::finished
void finished()
Signal emitted when the script execution finishes.
ScriptWorker::executePythonScript
void executePythonScript(const QString &scriptPath, const QString &name)
Executes a given Python script.
Definition: script_worker.cpp:172
TaskExecutor::forceStop
void forceStop()
Forces the stop of all currently running tasks.
Definition: task_executor.cpp:62
task_executor.hpp
folder_structure_constants.hpp
ScriptWorker::failed
void failed(const QString &error)
Signal emitted when the script execution fails.
TaskExecutor
Executes tasks and manages their execution state.
Definition: task_executor.hpp:19
Subtask::timeoutSeconds
int timeoutSeconds
The timeout for the subtask execution in seconds.
Definition: task.hpp:40
FolderStructureConstants::RESET_ROBOT_SCRIPT_PATH
const QString RESET_ROBOT_SCRIPT_PATH
Path to the reset robot script.
Definition: folder_structure_constants.hpp:27
TaskExecutor::resetRobotFinished
void resetRobotFinished()
Signal emitted when robot reset finishes.
Subtask::solutionFilePath
QString solutionFilePath
The file path to the solution of the subtask.
Definition: task.hpp:36
FolderStructureConstants::getPackagePath
QString getPackagePath()
Retrieves the path of the package.
Definition: folder_structure_constants.hpp:80
Subtask::parentTask
QWeakPointer< Task > parentTask
Weak pointer to the parent task.
Definition: task.hpp:45
TaskExecutor::taskExecutionFinished
void taskExecutionFinished()
Signal emitted when task execution finishes.
TaskExecutor::taskExecutionStarted
void taskExecutionStarted()
Signal emitted when task execution starts.
Subtask::filePath
QString filePath
The file path of the subtask.
Definition: task.hpp:35
TaskExecutor::executeTask
void executeTask(const Subtask &subtask, bool startSolution=false)
Executes a given subtask.
Definition: task_executor.cpp:10
TaskExecutor::taskExecutionFailed
void taskExecutionFailed(const QString &error)
Signal emitted when task execution fails.
TaskExecutor::resetRobotFailed
void resetRobotFailed(const QString &error)
Signal emitted when robot reset fails.
FolderStructureConstants::CONVERTED_SCRIPT_PATH
const QString CONVERTED_SCRIPT_PATH
Path to the converted script.
Definition: folder_structure_constants.hpp:21
script_worker.hpp
ScriptWorker::startExecution
void startExecution()
Starts the execution of the scripts.
Definition: script_worker.cpp:38
Subtask::parallelizedEvaluationRequired
bool parallelizedEvaluationRequired
Whether parallelized evaluation is required.
Definition: task.hpp:41
Subtask
Represents a subtask within a task.
Definition: task.hpp:31
TaskExecutor::TaskExecutor
TaskExecutor(QObject *parent=nullptr)
Constructs a TaskExecutor object.
Definition: task_executor.cpp:8
ScriptWorker
Manages the execution of scripts for tasks.
Definition: script_worker.hpp:21
TaskExecutor::resetRobot
void resetRobot()
Triggers python script to reset the robot to its initial state and removes all objects from the scene...
Definition: task_executor.cpp:68