Changed return command to extend rotateTo command
This commit is contained in:
parent
54d39e7901
commit
8bceaab70b
3 changed files with 16 additions and 31 deletions
|
@ -21,7 +21,9 @@ import com.builtbroken.assemblyline.ALRecipeLoader;
|
||||||
import com.builtbroken.assemblyline.api.IArmbot;
|
import com.builtbroken.assemblyline.api.IArmbot;
|
||||||
import com.builtbroken.assemblyline.api.coding.IProgram;
|
import com.builtbroken.assemblyline.api.coding.IProgram;
|
||||||
import com.builtbroken.assemblyline.api.coding.ProgramHelper;
|
import com.builtbroken.assemblyline.api.coding.ProgramHelper;
|
||||||
|
import com.builtbroken.assemblyline.armbot.command.TaskDrop;
|
||||||
import com.builtbroken.assemblyline.armbot.command.TaskGOTO;
|
import com.builtbroken.assemblyline.armbot.command.TaskGOTO;
|
||||||
|
import com.builtbroken.assemblyline.armbot.command.TaskGrabItem;
|
||||||
import com.builtbroken.assemblyline.armbot.command.TaskReturn;
|
import com.builtbroken.assemblyline.armbot.command.TaskReturn;
|
||||||
import com.builtbroken.assemblyline.armbot.command.TaskRotateBy;
|
import com.builtbroken.assemblyline.armbot.command.TaskRotateBy;
|
||||||
import com.builtbroken.assemblyline.armbot.command.TaskRotateTo;
|
import com.builtbroken.assemblyline.armbot.command.TaskRotateTo;
|
||||||
|
@ -69,9 +71,11 @@ public class TileEntityArmbot extends TileEntityAssembly implements IMultiBlock,
|
||||||
super(20);
|
super(20);
|
||||||
programHelper = new ProgramHelper(this).setMemoryLimit(20);
|
programHelper = new ProgramHelper(this).setMemoryLimit(20);
|
||||||
Program program = new Program();
|
Program program = new Program();
|
||||||
program.setTaskAt(0, 0, new TaskRotateTo(90, 0));
|
program.setTaskAt(0, 0, new TaskDrop());
|
||||||
program.setTaskAt(0, 1, new TaskReturn());
|
program.setTaskAt(0, 1, new TaskRotateTo(180, 0));
|
||||||
program.setTaskAt(0, 2, new TaskGOTO(0, 0));
|
program.setTaskAt(0, 2, new TaskGrabItem());
|
||||||
|
program.setTaskAt(0, 3, new TaskReturn());
|
||||||
|
program.setTaskAt(0, 4, new TaskGOTO(0, 0));
|
||||||
programHelper.setProgram(program);
|
programHelper.setProgram(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,12 @@
|
||||||
package com.builtbroken.assemblyline.armbot.command;
|
package com.builtbroken.assemblyline.armbot.command;
|
||||||
|
|
||||||
import com.builtbroken.assemblyline.armbot.TaskBaseArmbot;
|
|
||||||
import com.builtbroken.assemblyline.armbot.TaskBaseProcess;
|
import com.builtbroken.assemblyline.armbot.TaskBaseProcess;
|
||||||
|
|
||||||
public class TaskReturn extends TaskBaseArmbot
|
public class TaskReturn extends TaskRotateTo
|
||||||
{
|
{
|
||||||
public static final float IDLE_ROTATION_PITCH = 0;
|
|
||||||
public static final float IDLE_ROTATION_YAW = 0;
|
|
||||||
|
|
||||||
private TaskRotateTo rotateToCommand;
|
|
||||||
|
|
||||||
public TaskReturn()
|
public TaskReturn()
|
||||||
{
|
{
|
||||||
super("Return");
|
super("Return", 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProcessReturn onUpdate()
|
|
||||||
{
|
|
||||||
if (this.rotateToCommand == null)
|
|
||||||
{
|
|
||||||
this.rotateToCommand = new TaskRotateTo(0, 0);
|
|
||||||
this.rotateToCommand.setProgram(this.program);
|
|
||||||
this.rotateToCommand.onMethodCalled();
|
|
||||||
}
|
|
||||||
return this.rotateToCommand.onUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void terminated()
|
|
||||||
{
|
|
||||||
this.rotateToCommand.terminated();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,7 +26,12 @@ public class TaskRotateTo extends TaskBaseArmbot
|
||||||
|
|
||||||
public TaskRotateTo(int yaw, int pitch)
|
public TaskRotateTo(int yaw, int pitch)
|
||||||
{
|
{
|
||||||
super("RotateTo");
|
this("RotateTo", yaw, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskRotateTo(String string, int yaw, int pitch)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
this.args.add(new ArgumentIntData("yaw", yaw, 360, 0));
|
this.args.add(new ArgumentIntData("yaw", yaw, 360, 0));
|
||||||
this.args.add(new ArgumentIntData("pitch", pitch, 360, 0));
|
this.args.add(new ArgumentIntData("pitch", pitch, 360, 0));
|
||||||
this.UV = new Vector2(100, 80);
|
this.UV = new Vector2(100, 80);
|
||||||
|
@ -52,7 +57,7 @@ public class TaskRotateTo extends TaskBaseArmbot
|
||||||
((IArmbot) this.program.getMachine()).moveArmTo(this.targetRotationYaw, this.targetRotationPitch);
|
((IArmbot) this.program.getMachine()).moveArmTo(this.targetRotationYaw, this.targetRotationPitch);
|
||||||
int deltaYaw = Math.abs(((IArmbot) this.program.getMachine()).getRotation().intY() - this.targetRotationPitch);
|
int deltaYaw = Math.abs(((IArmbot) this.program.getMachine()).getRotation().intY() - this.targetRotationPitch);
|
||||||
int deltaPitch = Math.abs(((IArmbot) this.program.getMachine()).getRotation().intX() - this.targetRotationYaw);
|
int deltaPitch = Math.abs(((IArmbot) this.program.getMachine()).getRotation().intX() - this.targetRotationYaw);
|
||||||
return deltaYaw > 0 && deltaPitch > 0 ? ProcessReturn.CONTINUE : ProcessReturn.DONE;
|
return deltaYaw != 0 && deltaPitch != 0 ? ProcessReturn.CONTINUE : ProcessReturn.DONE;
|
||||||
}
|
}
|
||||||
return ProcessReturn.GENERAL_ERROR;
|
return ProcessReturn.GENERAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue