todo link to download the zip project.
#ifndef _ACTION_PICKPLACE_H_
#define _ACTION_PICKPLACE_H_
#include "Process.h"
#include "Gripper.h"
#include "RobotArm.h"
namespace Example
{
class ActionPickPlace : public Action
{
CONCEPT_BEGIN(ActionPickPlace,
"Example.ActionPickPlace", Action)
public:
void Execute() override
{
baseClass::Execute();
if (!GetGripper().IsValidReference() || !GetArm().IsValidReference())
{
System::GetConsole().WriteLine("Bad dependencies");
return;
}
GetGripper().GetReference()->Open();
GetArm().GetReference()->MoveTo(GetPointPick());
GetGripper().GetReference()->Close();
GetArm().GetReference()->MoveTo(GetPointPlace());
GetGripper().GetReference()->Open();
}
};
}
#endif
#include "ConceptRTOs.h"
#include "Machine.h"
#include "Gripper.h"
#include "RobotArm.h"
#include "Process.h"
#include "ActionGripper.h"
#include "ActionMove.h"
#include "ActionPickPlace.h"
using namespace Example;
void LoadMachine(Machine & machine)
{
{
Gripper & gripperA = machine.GetMachineElements().AddNew<Gripper>("GripperA");
gripperA.SetOpeningTimeout(
Seconds(2));
RobotArm & armA = machine.GetMachineElements().AddNew<RobotArm>("ArmA");
armA.SetMaxPositionX(45.6f);
armA.SetMaxPositionY(87.2f);
armA.SetMaxPositionZ(28.1f);
Gripper & gripperB = machine.GetMachineElements().AddNew<Gripper>("GripperB");
RobotArm & armB = machine.GetMachineElements().AddNew<RobotArm>("ArmB");
armB.SetMaxPositionX(34.7f);
armB.SetMaxPositionY(88.4f);
armB.SetMaxPositionZ(62.3f);
}
else
{
machine.Clear();
reader.
ReadValue(machine.GetName(), machine);
machine.ResolveLinks();
}
}
void LoadProcess(Process & process, Machine & machine)
{
{
RobotArm * arm = machine.GetMachineElements().FindByName<RobotArm>("ArmA");
else
Gripper * gripper = machine.GetMachineElements().FindByName<Gripper>("GripperA");
Gripper & gripperUsed = *gripper;
RobotArm & armUsed = *arm;
ActionOpen & action1 = process.GetActions().AddNew<ActionOpen>("Action1");
action1.GetGripper().SetReference(gripperUsed);
ActionPickPlace & action2 = process.GetActions().AddNew<ActionPickPlace>("Action2");
action2.GetGripper().SetReference(gripperUsed);
action2.GetArm().SetReference(armUsed);
action2.GetPointPick().x = 10;
action2.GetPointPick().y = 20;
action2.GetPointPick().z = 15;
action2.GetPointPlace().x = 30;
action2.GetPointPlace().y = -20;
action2.GetPointPlace().z = 0;
ActionMove & action3 = process.GetActions().AddNew<ActionMove>("Action3");
action3.GetArm().SetReference(armUsed);
action3.GetPoint().x = 0;
action3.GetPoint().y = 0;
action3.GetPoint().z = 0;
writer.WriteValue(process.GetName(), process);
processOutfile.Close();
}
else
{
process.Clear();
reader.SetFactories(processFactories);
reader.ReadValue(process.GetName(), process);
process.ResolveLinks();
processInfile.Close();
}
}
{
Machine machine;
machine.SetName("Machine");
LoadMachine(machine);
Process process;
process.SetName("Process");
LoadProcess(process, machine);
process.Execute();
}
{
}