How to move robot using matrix instead of move joint

Hello!

I woud like to move robot via python API using coordinates instead of moveJoint.

Any suitable python API?

move_robot_via_python_API_Q.vcmx (99.5 KB)

Hi alfaromeo

Maybe there’s a better way but what I do is I create a vcMotionTarget, set the target matrix and then read out the calculated joint values.

comp = getComponent()
controller = comp.getBehaviour('Controller')

motionTarget = controller.createTarget()
motionTarget.TargetMode = VC_MOTIONTARGET_TM_WORLDTARGET
motionTarget.Target = yourTargetMatrix

jointValues = motionTarget.JointValues

Hope that helps!

Hi,

vcHelpers.Robot2 has many methods you could use such as linearMoveToPosition(). Robot2 is a wrapper class for the robot controller and you can also use the controller class itself a little bit like Johnny described. I fleshed out his example a bit so check the snippet below. Using the actual robot controller instead of Robot2 wrapper grants you a bit more control over the motion and in the snippet below things such as tool, base, configuration and motion type are defined for the target. And of course the target matrix. For translating the matrix I used matrices translateAbs() method. But check the reference guide (in help) for more info about the vcRobotController and vcHelpers.Robot2.

def OnRun():
  controller = comp.getBehaviour('Controller')

  m = vcMatrix.new()
  m.translateAbs(800, 0, 800)
  m.setWPR(0, 180, 0)

  motionTarget = controller.createTarget()
  motionTarget.TargetMode = VC_MOTIONTARGET_TM_NORMAL
  motionTarget.BaseName = "BASE_1"
  motionTarget.ToolName = "Tool_TCP"
  motionTarget.MotionType = VC_MOTIONTARGET_MT_LINEAR
  motionTarget.RobotConfig = 0
  motionTarget.Target = m

  controller.moveTo(motionTarget)

-k

I understand that.
Thank you for the detailed example.