Skip to content

Commit

Permalink
Added capability for print bed rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
davepollard authored May 2, 2018
1 parent cb93fa5 commit 97fa80a
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 8 deletions.
6 changes: 6 additions & 0 deletions RESET_POSITION.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
elif modeSelection == 0:
R = abb.Robot("192.168.125.1")
print("Robot resetting now")
elif modeSelection == 2:
R = abb.Robot("192.168.125.1")
print("Robot moving backwards and then resetting")
currPos = R.get_cartesian()
currPos[0][0] -= 100
R.set_cartesian(currPos)
else:
R = abb.Robot("192.168.125.1")
print("---- WARNING ----")
Expand Down
79 changes: 79 additions & 0 deletions Robot_Config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import copy

class robot_config:
#
# Base parameters
#
Tool = [[-44.51, 9.9, 113.95],[1,0,0,0]]
FauxTool = [[-47.7913, 12.961, 103.954],[1,0,0,0]]

# Initialise
WObjData = []
ExtAxData = []
InitJointData = []


# Flat plate
WObjData.append([[563.1723, -92.69622, 290.004],[1,0,0,0]])
ExtAxData.append([0,0])
InitJointData.append([0,17,8,0,65,0])

# 45 degrees
WObjData.append([[555.8, -127.3, 383.6],[0.9235949, -0.38097291, 0.005997098517, 0.013148388823]])
ExtAxData.append([45,0])
InitJointData.append([16, 31, -8, -43, 84, 26])

# 90 degrees
WObjData.append([[564.949, -73.7138, 475.236],[0.70710678118654757, -0.70710678118654746, 0.0, 0.0]])
ExtAxData.append([90,0])
InitJointData.append([21, 29, -1, 90, -90, -70])


# 135 degrees
WObjData.append([[540.0918, -382.8466, 767.9519],[0.27059805007309851, -0.65328148243818829, -0.65328148243818829, -0.27059805007309845]])
ExtAxData.append([45,0])
InitJointData.append([-11.3, 30, -35, -130, 78, 5])

# 180 degrees
WObjData.append([[543.6473, -0.8785222, 925.7554],[0,0.707106781,0.707106781,0]])
ExtAxData.append([90,0])
InitJointData.append([18.8, 10, -5, -166, 66.9, 8])

# Rotated toolplate
WObjData.append([[633.5, 9.87, 380],[1,0,0,0]])
ExtAxData.append([0,0])
InitJointData.append([30,20,30,90,-80,60])

#
# Return functions
#
@classmethod
def get_tool(robot_config, UseFauxNozzle = False):
if UseFauxNozzle:
print("Using nozzle model")
return robot_config.FauxTool
else:
print("Using actual printhead")
return robot_config.Tool

@classmethod
def get_wobj(robot_config,z_offset = 0, WObjNumber = 0):
if WObjNumber < len(robot_config.WObjData):
return robot_config.WObjData[WObjNumber]
else:
raise Exception("Unrecognised WObj Number")


@classmethod
def get_extax(robot_config,WObjNumber = 0):
if WObjNumber < len(robot_config.ExtAxData):
return robot_config.ExtAxData[WObjNumber]
else:
raise Exception("Unrecognised external axis")

@classmethod
def get_initJoint(robot_config, WObjNumber = 0):
if WObjNumber <len(robot_config.InitJointData):
return robot_config.InitJointData[WObjNumber]
else:
raise Exception("Unrecognised initial joint position number")
38 changes: 30 additions & 8 deletions SERVER.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ MODULE SERVER
!////////////////

! Robot configuration
PERS tooldata currentTool := [TRUE,[[0,0,50],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PERS wobjdata currentWobj := [FALSE,TRUE,"",[[0,0,0],[1,0,0,0]],[[600,0,300],[1,0,0,0]]];
PERS tooldata currentTool := [TRUE,[[-44.5,9.9,114],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PERS wobjdata currentWobj := [FALSE,TRUE,"",[[0,0,0],[1,0,0,0]],[[633.5,9.9,380],[1,0,0,0]]];
PERS speeddata currentSpeed;
PERS zonedata currentZone;

Expand Down Expand Up @@ -69,6 +69,8 @@ VAR robtarget circPoint;
VAR num ok;
CONST num SERVER_BAD_MSG := 0;
CONST num SERVER_OK := 1;
TASK PERS tooldata testNozzle:=[TRUE,[[-47.7913,12.961,103.954],[1,0,0,0]],[0.5,[0,0,0],[1,0,0,0],0,0,0]];
TASK PERS tooldata nozzle:=[TRUE,[[-44.5058,10.7853,113.761],[1,0,0,0]],[1,[0,0,0],[1,0,0,0],0,0,0]];
!////////////////
Expand Down Expand Up @@ -159,6 +161,7 @@ PROC Initialize()
currentZone := [FALSE, 0.3, 0.3,0.3,0.03,0.3,0.03]; !z0
!Find the current external axis values so they don't move when we start
ActUnit STN1;
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;
ENDPROC
Expand Down Expand Up @@ -207,14 +210,18 @@ PROC ServerMain()
IF nParams = 1 THEN
IF params{1} = -1 THEN
ChangeExtruderState (0);
DeactUnit STN1;
ELSEIF params{1} = 0 THEN
ResetRobotPosition;
ChangeExtruderState(0);
DeactUnit STN1;
ELSEIF params{1} = 1 THEN
ResetRobotPosition;
ChangeExtruderState(1);
ActUnit STN1;
ELSEIF params{1} = 2 THEN
ChangeExtruderState(1);
ActUnit STN1;
ENDIF
ok := SERVER_OK;
ELSE
Expand All @@ -231,6 +238,9 @@ PROC ServerMain()

CASE 1: !Cartesian Move
IF nParams = 8 THEN
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;

cartesianTarget :=[[params{2},params{3},params{4}],
[params{5},params{6},params{7},params{8}],
[0,0,0,0],
Expand All @@ -249,6 +259,9 @@ PROC ServerMain()

CASE 2: !Joint Move
IF nParams = 6 THEN
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;

jointsTarget:=[[params{1},params{2},params{3},params{4},params{5},params{6}], externalAxis];
ok := SERVER_OK;
moveCompleted := FALSE;
Expand Down Expand Up @@ -289,11 +302,9 @@ PROC ServerMain()

CASE 5: !Get external axis positions
IF nParams=0 THEN
ActUnit STN1;
jointsTarget:=CJointT();
addString:=ValToStr(jointsTarget.extax.eax_b)+" ";
addString:=addString + ValToStr(jointsTarget.extax.eax_c);
DeactUnit STN1;
ok:=SERVER_OK;
ELSE
ok:=SERVER_BAD_MSG;
Expand Down Expand Up @@ -407,7 +418,14 @@ PROC ServerMain()
ENDIF

CASE 30: !Add Cartesian Coordinates to buffer
IF nParams = 7 THEN
IF nParams = 7 OR nParams = 8 THEN
! If external axis is necessary
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;
IF nParams = 8 THEN
externalAxis.eax_c := params{8};
ENDIF

cartesianTarget :=[[params{1},params{2},params{3}],
[params{4},params{5},params{6},params{7}],
[0,0,0,0],
Expand Down Expand Up @@ -487,16 +505,17 @@ PROC ServerMain()
jointsTarget.extax.eax_c := params{2};
ok := SERVER_OK;
moveCompleted := FALSE;
ActUnit STN1;
MoveAbsJ jointsTarget, currentSpeed, fine, currentTool \Wobj:=currentWobj;
DeactUnit STN1;
moveCompleted := TRUE;
ELSE
ok :=SERVER_BAD_MSG;
ENDIF

CASE 35: !Specify circPoint for circular move, and then wait on toPoint
IF nParams = 7 THEN
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;

circPoint :=[[params{1},params{2},params{3}],
[params{4},params{5},params{6},params{7}],
[0,0,0,0],
Expand All @@ -509,6 +528,9 @@ PROC ServerMain()

CASE 36: !specify toPoint, and use circPoint specified previously
IF nParams = 7 THEN
jointsTarget := CJointT();
externalAxis := jointsTarget.extax;

cartesianTarget :=[[params{1},params{2},params{3}],
[params{4},params{5},params{6},params{7}],
[0,0,0,0],
Expand Down Expand Up @@ -785,4 +807,4 @@ ERROR
ENDIF
ENDFUNC

ENDMODULE
ENDMODULE
Binary file added abb.pyc
Binary file not shown.

0 comments on commit 97fa80a

Please sign in to comment.