public void DoNextTask(bool force = false) { if (_currentTaskIsFinished) { _currentTask = _tasks.Dequeue(); } }
void Awake() { signalControl = new ControlSignal(); path = "Save/DroneSession/" + "Task-" + task + "/Seed-" + fromSeed + "/"; rndGenerator = new SystemRandomSource(fromSeed); taskObject = (DroneTask)Activator.CreateInstance(Type.GetType("Lexmou.MachineLearning.Drone" + task), rndGenerator, task); mlp = new MultiLayerMathsNet(fromSeed, null, taskObject.shapes, 1, 0); float[] floatArr = new float[taskObject.individualSize]; //float[] floatArr = new float[] {0,-0.33f,0,0,-0.33f,0,0,0,0,0,0.5f,0,0,-1,0,0,-1,0,0,0.5f,0,1,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0.5f}; Genetic.LoadBest(path, fromGeneration, floatArr); BuildCustomWeights(mlp.weights, taskObject.shapes, Vector <float> .Build.DenseOfArray(floatArr)); //Debug.Log(mlp.weights[0]); /*if (stabilizationGeneration != 0) * { * Debug.Log("Gene Move"); * gene = new Genetic(stabilizationSeed, null, 100, 40, 1.0f, 0.1f, 0.1f, 0.1f, 0.1f, "Save/DroneSession/Task-stabilization/", false); * } * if (moveGeneration != 0) * { * Debug.Log("Gene Move"); * gene = new Genetic(moveSeed, null, 100, 52, 1.0f, 0.1f, 0.1f, 0.1f, 0.1f, "Save/DroneSession/Task-move/", false); * } * deltaDistribution = new ContinuousUniform(-2, 2); * tmpBuildCustomWeights = new List<Matrix<float>>();*/ Restart(); }
public static DroneTaskHandlerNotFoundException Get(DroneTask task) { if(task == null) throw new ArgumentNullException("task"); var ex = new DroneTaskHandlerNotFoundException("unable to find handler for task"); ex.Data["task-type"] = task == null ? string.Empty : task.GetType().FullName; return ex; }
public virtual Option<DroneTaskHandler> TryGetHandler(DroneTask task) { if (task == null) throw new ArgumentNullException("task"); if (!this.handlerTypes.HasValue) { this.handlerTypes = Option.From(DroneTaskHandler.GetHandlerTypes()); if (!this.handlerTypes.HasValue) throw DroneTaskHandlerNotFoundException.Get(task); } var handlerType = null as Type; this.handlerTypes.Value.TryGetValue(task.GetType(), out handlerType); if (handlerType == null) throw DroneTaskHandlerNotFoundException.Get(task); var handler = Activator.CreateInstance(handlerType) as DroneTaskHandler; return handler; }
private DroneTaskResult Run(DroneModule module, DroneTask task, DroneEnv env, bool logErrors) { var taskLog = DroneLogManager.GetTaskLog(task.Name); var taskContext = new DroneTaskContext(module, task, env, taskLog, (t, e) => { var childTaskResult = this.Run(module, t, e, false); if(!childTaskResult.IsSuccess) { this.log.Debug("child task '{0}' has failed", t.Name); throw childTaskResult.Exception.Value; } }); this.log.Info("running '{0}'", task.Name); var handler = this.factory.TryGetHandler(task); var result = FuncStopwatch.Run(() => { if(handler.HasValue) { handler.Value.Handle(taskContext); } else { throw DroneTaskHandlerNotFoundException.Get(task); } }); if (result.IsSuccess) { this.log.Info("task '{0}' completed ({1})", task.Name, HumanTime.Format(result.TimeElapsed)); return new DroneTaskResult(Option.From(task), DroneTaskState.Completed, result.TimeElapsed, Option.None<Exception>()); } else { var state = DroneTaskState.Faulted; var stateName = "failed"; this.log.Info("task '{0}' {1} ({2})", task.Name, stateName, HumanTime.Format(result.TimeElapsed)); if(logErrors) this.log.ExceptionAndData(result.Exception); return new DroneTaskResult(Option.From(task), state, result.TimeElapsed, Option.From(result.Exception)); } }
public void ExecuteTask(DroneTask task) { string service_name = "/dji_sdk/drone_task_control"; ros.CallService(HandleTaskResponse, service_name, string.Format("{0} {1}", client_id, service_name), string.Format("[{0}]", (int)task)); }
public void SetTask(DroneTask task) { _drone.SetTask(task); }
public void AddTask(DroneTask task) { _drone.AddTask(task); }
public void SetTask(DroneTask task) { _currentTask = task; }
public void AddTask(DroneTask task) { _tasks.Enqueue(task); Log("received task: " + task.Type); }
public void SetTask(DroneTask droneTask, Drone drone) // check method { }
public IEnumerable<DroneTask> GetTasks(DroneEnv env) { DroneEnv.Set(env); var module = this.CompileAndLoadModule(env, LogLevel.Debug); foreach (var task in module.Tasks) { var taskCopy = new DroneTask(task.Name, task.Dependencies); yield return taskCopy; } }