Difference between revisions of "Program Examples: WorkSpace areas"

From SoftMC-Wiki
Jump to: navigation, search
(Introduction)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Introduction=
+
{{Languages|Program_Examples:_WorkSpace_areas}}
This feature limits robot movements inside defined WorkSpaces areas and at specific paths between them. Each WorkSpaces is modeled by users as a rectangular prism in 3D space with entry and exit points, which defined in '''*.XML''' file. <br>  
+
<div id="BackToTop"  class="noprint" style="background-color:; position:fixed; bottom:32px; left:95%; z-index:9999; padding:0; margin:0;">
Robot is considered to be '''inside''' WorkSpaces if its TCP (Tool Center Point) is within the prism and '''outside''' WorkSpaces if its TCP is outside the prism. <br>
+
<span style="color:blue; font-size:8pt; font-face:verdana,sans-serif; border:0.2em outset:#ceebf7; padding:0.1em; font-weight:bolder; -moz-border-radius:8px; ">
In case user tries to move the robot outside WorkSpaces using unauthorized path an error will raise and motion won't be started. <br>
+
[[Image:TOP2.png|50px|link=#top]] </span></div>
{{Note | Robot segments are not considered}}
 
  
=WorkSpace Properties=
+
=WorkSpace Example=
WorkSpaces are cuboids defined by its four vertex points:
+
{|class="wikitable" style="text-align: center"
* Origin (O)
+
|'''Description'''
* Width (W)
+
|'''Download'''
* Length (L)
+
|-
* Height (H)
+
|It's recommended to download the example '''ZIP''' file, extract all the project files, open project with ControlStudio, and run the example by yourself.
The cuboid can have any orientation in space. The coordinates of the cuboid are given in '''WorkPiece''' coordinates of the robot TCP (including tool). <br>
+
|[[image:Download.png|90px|link=http://softmc.servotronix.com/img_auth.php/1/16/scara.zip]]
Cuboid parameter defines relative to WorkSpace origin:
+
|}
* O = #{X,Y,Z,Yaw,Pitch,Roll}  - location
 
* L = O:#{0,WSCPL,0,0,0,0}
 
* W = O:#{WSCPW,0,0,0,0,0}
 
* H = O:#{0,0,WSCPH,0,0,0}
 
When '''WSPCL''' = WorkSpace length, '''WSPCW''' = WorkSpace width, '''WSPCH''' = WorkSpace height.
 
To sets a proper WorkSpace one need to follow these rules:
 
# WorkSpaces are grouped in WorkSpace-sets. There will be maximum 16 WorkSpace defined in one WorkSpace-set when each WorkSpace-set belongs to only one robot.
 
# WorkSpace will be indexed by unique numbers 1, 2, 3, ...
 
# Only '''active''' WorkSpace is considered.
 
# WorkSpace areas won't be able to edit (change) while robot is enabled (powered-on).
 
# WorkSpace can be '''activated''' only when the robot is disabled (powered-off).
 
# WorkSpace areas won't be active during '''conveyer tracking'''.
 
# In the first phase, if there are active WorkSpace lined to a robot joint-interpolated motions (MOVE) will be not allowed!
 
# Each WorkSpace area will have a set of '''entry & exit''' points: (En1,En2, …) and (Ex1,Ex2, …) defining exit and entry paths from one workspace to another.
 
# Entry and exit points will be '''defined only''' by #{X,Y,Z} relative to the origin (O) of the related working space.
 
# Entry and exit points '''must lie on the surface''' of the WorkSpace (not inside the WorkSpace).
 
# Entry and exit points will be defined with a '''tolerance radius R''' meaning that if the robot TCP is at distance less then R from the given point it will be considered at this point. The tolerance will be described by half-sphere of radius R – meaning only the half that is inside given WorkSpace is valid.
 
# There will be only one exit and one entry path from one given pair of WorkSpaces
 
# User can move the robot from one WorkSpace area to another only if:
 
## Movement is straight line movement (MOVES, MOVESKD), other interpolation types like: CIRCLE, MOVE, JOG are not allowed.
 
## Movement starts from one of the exit points of the WorkSpace area (Exi) to the entry-point (Enj) of another WorkSpace area.
 
## No other movement outside WorkSpace area are allowed.
 
# To move a robot to a WorkSpace area From random location without using WorkSpace paths, one need to issuing separate axis movements: <br> Move A1 10 <br> Move A2 -40 ....
 
# Different robots can have different WorkSpace sets.
 
# It will be possible to know for each robot in which WorkSpace-index the robot is currently placed.
 
  
=Graphic Movement Examples=
+
To run WorkSpace example:  
To understand the movement between WorkSpaces follow the next scenario: [[File:WSPC 1.png|right|450px]]
 
* There are three workspace objects:
 
** wspc#1
 
** wspc#2
 
** wspc#3
 
* Only the following exit/entry paths between workspaces are allowed:
 
** wspc#1.Ex1→ wspc#2.En2
 
** wspc#2.Ex1→ wspc#3.En1
 
**  wspc#3.Ex1→ wspc#1.En1
 
** wspc#3.Ex2→ wspc#2.En1
 
  
 +
# Upload all project files to MC
 +
# Via CS terminal send the following – “SEND SCARAEX.XML” – NEED TO GET “done” MESSAGE
 +
# Via CS terminal: “reset all” -> “load startprg.prg” -> “load WSPCONE.PRG” -> “STAS WSPCONE.PRG”
 +
# Information message should appear  in the Message Log panal.
  
 +
{{Note|
 +
The information you should get from WSPCONE.PRG task refer to:
 +
* loactions definition
 +
* Movements status
 +
* WSPC status
 +
}}
 +
{{Note|For more information about WorkSpace area definitions, and what the XML file contains please refer to [[WorkSpace areas]] page.}}
 +
=Steps=
 +
==Step 1==
 +
Make sure that the relevant XML file is within your project folder. <br>
 +
The XML file should be in this structure:
 +
<syntaxhighlight lang='XML'>
  
It's allowed for entry and exit paths to cross WorkSpaces and other WorkSpaces areas unlimited number of times: <br>
 
[[File:WSPC 2.png|450px]]
 
 
 
 
 
In case two WorkSpaces areas have common intersection, robot will be able to move from one to another without limitations:  <br>
 
[[File:WSPC 3.png|250px]]
 
 
=Initialization=
 
Initialization of one WorkSpace set will be done by reading an '''XML''' file with coordinates and entry/exit points linked to a specific robot. <br>
 
To upload Workspace setting user have to use WSPC function - '''WSPC_PARSE_XML(Robot ID number as long, XML Name as string)''' <br>
 
The XML structure should contain the following: <br>
 
* Workspace id number.
 
* WorkSpace vertices: O,W,H,L (all with X,Y,Z coordinates in mm)
 
* Accuracy radius: R (in mm)
 
* Exit Points to other Workspaces: Ex1#w1, … Exk#wk
 
* Entry Points from other WorkSpaces: En1#w1, … Enk#wk
 
<br>
 
In this format: <br>
 
<syntaxhighlight lang='XML'>
 
 
<workspace_set>
 
<workspace_set>
 
   <workspace number="1" name = "ToolCenter_pos">
 
   <workspace number="1" name = "ToolCenter_pos">
Line 86: Line 45:
 
     <tolerance radius="5" />
 
     <tolerance radius="5" />
 
   </workspace>
 
   </workspace>
 +
 +
  <workspace number="2" name = "First_pos">
 +
    <origin x="-50" y="350" z="-50" yaw="0" pitch="0" roll="0"/>
 +
    <dimensions x="100" y="100" z="100"/>
 +
    <entry_points>
 +
      <point ws_num="1" x="100" y="0" z="50"/>
 +
    </entry_points>
 +
    <exit_points>
 +
      <point ws_num="3" x="0" y="0" z="50"/>
 +
    </exit_points>
 +
    <tolerance radius="5" />
 +
  </workspace>
 +
 +
  <workspace number="3" name = "Second_pos">
 +
    <origin x="-50" y="-450" z="-50" yaw="0" pitch="0" roll="0"/>
 +
    <dimensions x="100" y="100" z="100"/>
 +
    <entry_points>
 +
      <point ws_num="2" x="0" y="100" z="50"/>
 +
    </entry_points>
 +
    <exit_points>
 +
      <point ws_num="1" x="100" y="100" z="50"/>
 +
    </exit_points>
 +
    <tolerance radius="5" />
 +
  </workspace>
 +
 
</workspace_set>
 
</workspace_set>
 +
 +
</syntaxhighlight>
 +
==Step 2==
 +
After XML created and located at project folder, send the following commands from CS terminal: <br>
 +
<syntaxhighlight lang=freebasic>
 +
--> SEND SCARAEX.XML        ' Need to get "done" message back
 +
--> Reset all
 +
--> load STARTPRG.PRG
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=WorkSpace Example=
+
'''Now your system is ready to use WorkSpaces setting as you create in the XML file.'''
{|class="wikitable" style="text-align: center"
+
 
|'''Description'''
+
==Step 3==
|'''Download'''
+
Create task for your robot, under WorkSpaces limitations, for example: <br>
|-
+
 
|It's recommended to download the example '''ZIP''' file, extract all the project files, open project with ControlStudio, and run the example by yourself.
+
<syntaxhighlight lang=freebasic>
|[[image:Download.png|90px|link=http://softmc.servotronix.com/img_auth.php/1/16/scara.zip]]
+
 
|}
+
 
 +
dim shared  lFlag  as long
 +
 
 +
program
 +
 
 +
dim lLoadXMLSeting         as long
 +
dim lRobotID as long = scara1.ElementID
 +
dim NumWSPC as long
 +
dim lTemp as long
 +
dim lSecTemp as long
 +
dim locTempExLocation         as generic location
 +
dim locTempEnLocation         as generic location
 +
dim locExCurr as location of XYZR
 +
dim locEnCurr as location of XYZR
 +
 
 +
withglobal scara1
 +
 
 +
 
 +
print RobotSetup
 +
attach
 +
pemax = 10
 +
 +
lLoadXMLSeting = WSPC_PARSE_XML(lRobotID, "SCARAEX.XML")
 +
NumWSPC = WSPC_GET_NUM(lRobotID)
 +
 +
if NOT lLoadXMLSeting then
 +
print "WorkSpace definitions completed"
 +
end if 'if there is an error - MC will throw it's message
 +
 +
print str$(NumWSPC) + " WSPC defined"
 +
 +
lTemp = WSPC_ACTIVATE_ALL(lRobotID)
 +
if NOT lTemp then
 +
print "All WSPC are activate"
 +
else
 +
print "Failed to activate all WSPC"
 +
end if
 +
 +
print ExitSet(lRobotID, 1, 2, locTempExLocation)
 +
print EntrySet(lRobotID, 2, 1, locTempEnLocation)
 +
lTemp = CurrectLoc(locTempExLocation, locExCurr)
 +
lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
 +
print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
 +
 +
print ExitSet(lRobotID, 2, 3, locTempExLocation)
 +
print EntrySet(lRobotID, 3, 2, locTempEnLocation)
 +
lTemp = CurrectLoc(locTempExLocation, locExCurr)
 +
lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
 +
print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
 +
 +
print ExitSet(lRobotID, 3, 1, locTempExLocation)
 +
print EntrySet(lRobotID, 1, 3, locTempEnLocation)
 +
lTemp = CurrectLoc(locTempExLocation, locExCurr)
 +
lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
 +
print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
 +
 +
try
 +
moves #{450, 300, 0,0}
 +
catch else
 +
print "Can't reach a point that is not defined within WorkSpace"
 +
end try
 +
 +
 +
sleep 10
 +
lTemp = WSPC_DEACTIVATE_ALL(lRobotID)
 +
if NOT lTemp then
 +
print "All WSPC deactivate"
 +
else
 +
print "Failed to deactivate all WSPC"
 +
end if
 +
 +
detach
 +
 +
end program
 +
 
 +
 
 +
function ExitSet (byval lRobotID as long, byval WSPCFrom as long, byval WSPCTo as long, exit_loc as generic location) as string
 +
dim lTemp as long
 +
 +
lTemp = WSPC_FIND_EXIT(lRobotID, WSPCFrom, WSPCTo, exit_loc)
 +
if NOT lTemp then
 +
ExitSet =  "exit point location setup succeeded"
 +
lFlag = 1
 +
else
 +
ExitSet = "exit point location setup failed"
 +
lFlag = 0
 +
end if
 +
 
 +
end function
 +
 
 +
 
 +
function EntrySet (byval lRobotID as long, byval WSPCTo as long, byval WSPCFrom as long, entry_loc as generic location) as string
 +
dim lTemp as long
 +
 +
lTemp = WSPC_FIND_ENTRY(lRobotID, WSPCTo, WSPCFrom, entry_loc)
 +
if NOT lTemp then
 +
entrySet =  "entry point location setup succeeded"
 +
lFlag = 1
 +
else
 +
entrySet = "entry point location setup failed"
 +
lFlag = 0
 +
end if
 +
 
 +
end function
 +
 
 +
 
 +
function RobotMovesFromWSPCto(byval lMotFlag as long, exit_Loc as generic location, entry_Loc as generic location) as string
 +
try
 +
if lMotFlag then
 +
En = 1
 +
moves exit_Loc vcruise = 5
 +
while IsMoving <>0
 +
sleep 1
 +
end while
 +
 +
moves entry_Loc vcruise = 5
 +
while IsMoving <>0
 +
sleep 1
 +
end while
 +
en = 0
 +
RobotMovesFromWSPCto = "movement completed"
 +
else
 +
RobotMovesFromWSPCto = "can't execute movement"
 +
end if
 +
 +
catch else
 +
RobotMovesFromWSPCto = "can't execute movement"
 +
end try
 +
 
 +
end function
 +
 
 +
function CurrectLoc(old_Loc as generic location, new_Loc as generic location) as long
 +
dim i as long
 +
 +
for i = 1 to 3
 +
new_Loc{i} = old_loc{i}
 +
next
 +
 +
 +
end function
 +
 
 +
 
 +
function RobotSetup as string
 +
dim i as long
 +
dim genAxis as generic axis
 +
for i = 1 to 4
 +
genAxis = SystemAxis(i)
 +
attach genAxis
 +
genAxis.pemax = 10
 +
genAxis.en = 1
 +
move genAxis 0 abs = 1 vcruise = 50
 +
while genAxis.ismoving<> 0
 +
sleep 1
 +
end while
 +
genAxis.en = 0
 +
detach genAxis
 +
 +
next
 +
  
To run WorkSpace example:
+
RobotSetup = "Setup Done"
  
# Upload all project files to MC
+
end function
# Via CS terminal send the following – “SEND SCARAEX.XML” – NEED TO GET “done” MESSAGE
 
# Via CS terminal: “reset all” -> “load startprg.prg” -> “load WSPCONE.PRG” -> “STAS WSPCONE.PRG”
 
# Information message should appear  in the Message Log panal.
 
  
{{Note|
+
</syntaxhighlight>
The information you should get from WSPCONE.PRG task refer to:
 
* loactions definition
 
* Movements status
 
* WSPC status
 
}}
 

Latest revision as of 07:59, 13 May 2018

Language: English

TOP2.png

WorkSpace Example

Description Download
It's recommended to download the example ZIP file, extract all the project files, open project with ControlStudio, and run the example by yourself. Download.png

To run WorkSpace example:

  1. Upload all project files to MC
  2. Via CS terminal send the following – “SEND SCARAEX.XML” – NEED TO GET “done” MESSAGE
  3. Via CS terminal: “reset all” -> “load startprg.prg” -> “load WSPCONE.PRG” -> “STAS WSPCONE.PRG”
  4. Information message should appear in the Message Log panal.
NOTE-Info.svgNOTE

The information you should get from WSPCONE.PRG task refer to:

  • loactions definition
  • Movements status
  • WSPC status
NOTE-Info.svgNOTE
For more information about WorkSpace area definitions, and what the XML file contains please refer to WorkSpace areas page.

Steps

Step 1

Make sure that the relevant XML file is within your project folder.
The XML file should be in this structure:

<workspace_set>
  <workspace number="1" name = "ToolCenter_pos">
    <origin x="450" y="-50" z="-50" yaw="0" pitch="0" roll="0"/>
    <dimensions x="100" y="100" z="100"/>
    <entry_points>
      <point ws_num="3" x="0" y="0" z="50"/>
    </entry_points>
    <exit_points>
      <point ws_num="2" x="0" y="100" z="50"/>
    </exit_points>
    <tolerance radius="5" />
  </workspace>

  <workspace number="2" name = "First_pos">
    <origin x="-50" y="350" z="-50" yaw="0" pitch="0" roll="0"/>
    <dimensions x="100" y="100" z="100"/>
    <entry_points>
      <point ws_num="1" x="100" y="0" z="50"/>
    </entry_points>
    <exit_points>
      <point ws_num="3" x="0" y="0" z="50"/>
    </exit_points>
    <tolerance radius="5" />
  </workspace>

  <workspace number="3" name = "Second_pos">
    <origin x="-50" y="-450" z="-50" yaw="0" pitch="0" roll="0"/>
    <dimensions x="100" y="100" z="100"/>
    <entry_points>
      <point ws_num="2" x="0" y="100" z="50"/>
    </entry_points>
    <exit_points>
      <point ws_num="1" x="100" y="100" z="50"/>
    </exit_points>
    <tolerance radius="5" />
  </workspace>

</workspace_set>

Step 2

After XML created and located at project folder, send the following commands from CS terminal:

--> SEND SCARAEX.XML        ' Need to get "done" message back
--> Reset all
--> load STARTPRG.PRG

Now your system is ready to use WorkSpaces setting as you create in the XML file.

Step 3

Create task for your robot, under WorkSpaces limitations, for example:

dim shared  lFlag  as long

program

	dim 		lLoadXMLSeting 			        as long 
	dim 		lRobotID 				as long = scara1.ElementID
	dim 		NumWSPC					as long 
	dim 		lTemp					as long
	dim 		lSecTemp				as long
	dim 		locTempExLocation 		        as generic location
	dim 		locTempEnLocation		        as generic location
	dim 		locExCurr				as location of XYZR	
	dim 		locEnCurr				as location of XYZR	

	withglobal scara1


		print RobotSetup
		attach
		pemax = 10
		
		lLoadXMLSeting = WSPC_PARSE_XML(lRobotID, "SCARAEX.XML")
		NumWSPC = WSPC_GET_NUM(lRobotID)
	
		if NOT lLoadXMLSeting then
			print "WorkSpace definitions completed"
		end if 			'if there is an error - MC will throw it's message 
		
		print str$(NumWSPC) + " WSPC defined"
		
		lTemp = WSPC_ACTIVATE_ALL(lRobotID)
		if NOT lTemp then
			print "All WSPC are activate"
		else
			print "Failed to activate all WSPC"
		end if
		
		print ExitSet(lRobotID, 1, 2, locTempExLocation)
		print EntrySet(lRobotID, 2, 1, locTempEnLocation)
		lTemp = CurrectLoc(locTempExLocation, locExCurr)
		lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
		print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
		
		print ExitSet(lRobotID, 2, 3, locTempExLocation)		
		print EntrySet(lRobotID, 3, 2, locTempEnLocation)
		lTemp = CurrectLoc(locTempExLocation, locExCurr)
		lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
		print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
		
		print ExitSet(lRobotID, 3, 1, locTempExLocation)		
		print EntrySet(lRobotID, 1, 3, locTempEnLocation)
		lTemp = CurrectLoc(locTempExLocation, locExCurr)
		lSecTemp = CurrectLoc(locTempEnLocation, locEnCurr)
		print RobotMovesFromWSPCto (lFlag, locExCurr, locEnCurr)
		
		try
			moves #{450, 300, 0,0}
		catch else
			print "Can't reach a point that is not defined within WorkSpace"
		end try 
		
		
		sleep 10
		lTemp = WSPC_DEACTIVATE_ALL(lRobotID)
		if NOT lTemp then
			print "All WSPC deactivate"
		else
			print "Failed to deactivate all WSPC"
		end if		
						
		detach
	
end program 


function ExitSet (byval lRobotID as long, byval WSPCFrom as long, byval WSPCTo as long, exit_loc as generic location) as string
	dim lTemp as long
	
	lTemp = WSPC_FIND_EXIT(lRobotID, WSPCFrom, WSPCTo, exit_loc)
	if NOT lTemp then
		ExitSet =  "exit point location setup succeeded"
		lFlag = 1 
	else
		ExitSet = "exit point location setup failed"
		lFlag = 0
	end if	

end function


function EntrySet (byval lRobotID as long, byval WSPCTo as long, byval WSPCFrom as long, entry_loc as generic location) as string
	dim lTemp as long 
	
	lTemp = WSPC_FIND_ENTRY(lRobotID, WSPCTo, WSPCFrom, entry_loc)
	if NOT lTemp then
		entrySet =  "entry point location setup succeeded"
		lFlag = 1 
	else
		entrySet = "entry point location setup failed"
		lFlag = 0
	end if	

end function


function RobotMovesFromWSPCto(byval lMotFlag as long, exit_Loc as generic location, entry_Loc as generic location) as string
	try
		if lMotFlag then
			En = 1
			moves exit_Loc vcruise = 5
			while IsMoving <>0 
				sleep 1
			end while
				
			moves entry_Loc vcruise = 5
			while IsMoving <>0 
					sleep 1
			end while
			en = 0
			RobotMovesFromWSPCto = "movement completed"
		else
			RobotMovesFromWSPCto = "can't execute movement"
		end if
		
	catch else
		RobotMovesFromWSPCto = "can't execute movement"
	end try

end function

function CurrectLoc(old_Loc as generic location, new_Loc as generic location) as long
	dim i as long
	
	for i = 1 to 3
		new_Loc{i} = old_loc{i}
	next
	
	
end function


function RobotSetup as string
	dim i as long
	dim genAxis as generic axis
		for i = 1 to 4 
		genAxis = SystemAxis(i)
		attach genAxis
		genAxis.pemax = 10
		genAxis.en = 1
		move genAxis 0 abs = 1 vcruise = 50
		while genAxis.ismoving<> 0
			sleep 1
		end while
		genAxis.en = 0
		detach genAxis
		
	next
	

	RobotSetup = "Setup Done" 	

end function