Jump to content

Controlling the GOM Rotation Table via Scripting


---
 Share

Recommended Posts

Hi,

I would like to be able to control my gom ROT640 rotation table via scripting. My goal is to be able to move the table a specified angle without having to run the 'measure with rotation table' feature. Is there a way to do this? 

Thanks!

Link to comment
Share on other sites

This script will move the rotation table either by one specified angle of rotation or through an interval by adding new "intermediate positions" based on wherever the current robot position is. You might need to add some checks for if the rotation table is already at its max rotation, to reverse the degree of rotation (or however is necessary)

# -*- coding: utf-8 -*-

import gom

dialog=gom.script.sys.create_user_defined_dialog (content='<dialog>' \
' <title>Move Rotation Table</title>' \
' <style></style>' \
' <control id="OkCancel"/>' \
' <position></position>' \
' <embedding></embedding>' \
' <sizemode></sizemode>' \
' <size height="288" width="198"/>' \
' <content columns="2" rows="7">' \
'  <widget rowspan="1" row="0" type="input::checkbox" column="0" columnspan="2">' \
'   <name>check_single</name>' \
'   <tooltip></tooltip>' \
'   <value>true</value>' \
'   <title>Single Rotation:</title>' \
'  </widget>' \
'  <widget rowspan="1" row="1" type="separator" column="0" columnspan="2">' \
'   <name>separator</name>' \
'   <tooltip></tooltip>' \
'   <title></title>' \
'  </widget>' \
'  <widget rowspan="1" row="2" type="input::integer" column="0" columnspan="2">' \
'   <name>single</name>' \
'   <tooltip></tooltip>' \
'   <value>90</value>' \
'   <minimum>15</minimum>' \
'   <maximum>360</maximum>' \
'  </widget>' \
'  <widget rowspan="1" row="3" type="input::checkbox" column="0" columnspan="2">' \
'   <name>check_multi</name>' \
'   <tooltip></tooltip>' \
'   <value>false</value>' \
'   <title>Multiple Rotation:</title>' \
'  </widget>' \
'  <widget rowspan="1" row="4" type="separator" column="0" columnspan="2">' \
'   <name>separator_1</name>' \
'   <tooltip></tooltip>' \
'   <title></title>' \
'  </widget>' \
'  <widget rowspan="1" row="5" type="label" column="0" columnspan="1">' \
'   <name>label</name>' \
'   <tooltip></tooltip>' \
'   <text>Total Rotation:</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
'  <widget rowspan="1" row="5" type="input::integer" column="1" columnspan="1">' \
'   <name>total_rotation</name>' \
'   <tooltip></tooltip>' \
'   <value>360</value>' \
'   <minimum>90</minimum>' \
'   <maximum>360</maximum>' \
'  </widget>' \
'  <widget rowspan="1" row="6" type="label" column="0" columnspan="1">' \
'   <name>label_1</name>' \
'   <tooltip></tooltip>' \
'   <text>Interval:</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
'  <widget rowspan="1" row="6" type="input::integer" column="1" columnspan="1">' \
'   <name>interval</name>' \
'   <tooltip></tooltip>' \
'   <value>6</value>' \
'   <minimum>2</minimum>' \
'   <maximum>24</maximum>' \
'  </widget>' \
' </content>' \
'</dialog>')


def dialog_event_handler (widget):
	if widget=='initialize':
		dialog.total_rotation.enabled=False
		dialog.interval.enabled=False
	if widget==dialog.check_multi and dialog.check_multi.value==True:
		dialog.check_single.value=False
		dialog.single.enabled=False
		dialog.total_rotation.enabled=True
		dialog.interval.enabled=True
	if widget==dialog.check_multi and dialog.check_multi.value==False:
		dialog.check_single.value=True
		dialog.single.enabled=True
		dialog.total_rotation.enabled=False
		dialog.interval.enabled=False
	if widget==dialog.check_single and dialog.check_single.value==True:
		dialog.check_multi.value=False
		dialog.single.enabled=True
		dialog.total_rotation.enabled=False
		dialog.interval.enabled=False
	if widget==dialog.check_single and dialog.check_single.value==False:
		dialog.check_multi.value=True
		dialog.single.enabled=False
		dialog.total_rotation.enabled=True
		dialog.interval.enabled=True


dialog.handler = dialog_event_handler


scanbox=None
for setup in gom.app.project.measuring_setups:
	if setup.is_active:
		scanbox=setup.working_area.controller.name

if scanbox==None:
	print('no scanbox')
	quit()

robot=None
table=None
for component in gom.app.project.virtual_measuring_room[scanbox].components:
	if component.type=='robot':
		robot=component.name
	if component.type=='rotation_table':
		table=component.name

if robot==None:
	print('no robot')
	quit()
if table==None:
	print('no roto table')
	quit()

current_position = [gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[0].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[1].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[2].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[3].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[4].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[robot].get ('axis_info[5].current_position'),
					gom.app.project.virtual_measuring_room[scanbox].components[table].get ('axis_info[0].current_position')]

roto=current_position[-1]


result=gom.script.sys.show_user_defined_dialog (dialog=dialog)

if result.check_single==True:
	rotation=int(result.single)
	position=gom.script.automation.insert_intermediate_position (position={ scanbox : current_position })
	gom.interactive.automation.move_to_position(measurement=position)
	current_position[-1]=rotation+roto
	position=gom.script.automation.insert_intermediate_position (position={ scanbox : current_position })
	gom.interactive.automation.move_to_position(measurement=position)
else:
	total_rot=int(result.total_rotation)
	interval=int(total_rot/int(result.interval))
	for i in range(0,total_rot,interval):
		current_position[-1]=i+roto
		position=gom.script.automation.insert_intermediate_position (position={ scanbox : current_position })
		gom.interactive.automation.move_to_position(measurement=position)

 

Link to comment
Share on other sites

Hi James,

My ultimate goal is to be able to use angles from live tracking to input into a script that will then move the rotation table the specified angle. 

 

Hi Robert,

Do you need a special license for the 'gom.interactive.automation.move_to_position' command? When running this I get an error that I do not have the correct license to run that command.

 

Thanks!

Link to comment
Share on other sites

Christian, robert has provided code relevant to a scanbox /vmr setup.  this does not apply in your case , as i said the rot 640 does not have encoders so sadly you cannot pass it angles to turn to.

What are you live tracking?  Why is this angle rotation useful? Im trying to understand your application , it isnt possible to do what you want with the rotation table but maybe there is a different method/approach to get a solution.

Link to comment
Share on other sites

you could try this to move your table in position:

gom.script.automation.measure_with_rotation_table (
	invert_rotation_direction=False,
	move_to_first_position_only=True,
	number_of_rotation_steps=1,
	number_of_tilt_steps=1,
	return_to_start_position=False,
	start_angle=20,
	tilt_end_angle=0,
	tilt_start_angle=0,
	total_coverage=0)

start_angle (20) could be your input from a dialog

Link to comment
Share on other sites

Hello I use a simple code to do the rotation I don't no if it helps 

import gom

gom.script.automation.measure_with_rotation_table (
    invert_rotation_direction=False,
    number_of_rotation_steps=0,
    return_to_start_position=False,
    start_angle=0,
    total_coverage=0,
    move_to_reference_position=True)
    
# Move to start position 

gom.script.automation.measure_with_rotation_table (
    invert_rotation_direction=False,
    number_of_rotation_steps=8,
    return_to_start_position=False,
    start_angle=70,
    total_coverage=360)

# colect photos on a certain angle

Link to comment
Share on other sites

 Share

×
×
  • Create New...