Modifying a robot base frame

Hi. I am trying to modify a robot base frame within a python script.

How do I do that?

I would like to find a specific robot base frame

Load its position matrix

Modify the matrix

Save the new matrix back to the base frame properties

Following python logic should work:

 

robotController = robotComponent.findBehaviour(“ControllerName”)

listBases = robotController .Bases #getting the list of all Bases of the robot

for base in listBases:

if base.Name == “MyBaseName”: # getting a certain base

posMat = base.PositionMatrix #getting the position

posMat.translateRel(100, 0, 0) # e.g. translate the position realatively in x-direction

base.PositionMatrix ( posMat ) # assign the new position to the base

 

I get the following error. Is this because I need to specify a controller name? If so how would I know what this is?

SyntaxError: invalid syntax
File “IRB 2600-20/1.65::PythonScript_2”, line 11
robotController = robotComponent.findBehaviour(“ControllerName”)

ok I change this to be:

robotComponent = getComponent()

robotController = robotComponent.findBehaviour(“IRC5”)

I found the controller name under the behaviours of the robot in the modelling tab.

However, now I have a new error:

Traceback (most recent call last):
File “IRB 2600-20/1.65::PythonScript_2”, line 41, in test
TypeError: ‘vcMatrix’ object is not callable

 

ok. I think I solved this.

base.PositionMatrix = posMat # assign the new position to the base

there should be an equal sign to assign the variable posMat to base.PositionMatrix and not brackets around it.

Those “double quotes” look a bit strange, like a ditto mark. Try to use single quotes robotController = robotComponent.findBehaviour(‘ControllerName’)

If those not work, please publish your code so we can give it a look.

Ok so it seems my replies are displayed in the wrong order after being moderated giving the impression this is still not solved. However, it is solved so I will write the solutions in order.

I got the following error. This is because you need to specify a controller name.

SyntaxError: invalid syntax
File “IRB 2600-20/1.65::PythonScript_2”, line 11
robotController = robotComponent.findBehaviour(“ControllerName”)

This was solved by:

robotComponent = getComponent()

robotController = robotComponent.findBehaviour(“IRC5”)

I found the controller name under the behaviours of the robot in the modelling tab.

This throw up the following error:

Traceback (most recent call last):
File “IRB 2600-20/1.65::PythonScript_2”, line 41, in test
TypeError: ‘vcMatrix’ object is not callable

This was solved by:

base.PositionMatrix = posMat # assign the new position to the base

there should be an equal sign to assign the variable posMat to base.PositionMatrix and not brackets around it.

The original

base.PositionMatrix ( posMat )

This is trying to called the method by the name of posMat rather then assigning its value to the positionMatrix.