Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Python example to update robot targets

#1
Hello everyone , I m facing a problem ... I want to make a programm which asks the User the places where he wants the ROBOT to visit via a message box. So far I've made the message box and all the things that i want the robot to do , but I don't know the command which sets the Target manually  .Does anyone have a clue ?
#2
What do you mean by setting the Target manually?

You can move the target by using setPose.
#3
I want the User to control the robot without using the set target method that we normally use to set targets. For example while running the python script a message box will ask you how many targets you want to have and where are it should go next? So you will insert the the next target (X,Y,Z Values).Can thiss "setPose" command do that?
#4
Yes, you can create targets by using AddTarget. Then, you can use setPos on a pose to update the XYZ position of the target pose. Finally, you should use setPose to update the pose on the target in your project.

I recommend you to take a look at this example:
https://robodk.com/doc/en/PythonAPI/exam...to-program

And more precisely this section:
Code:
# Retrieve the reference target:
pose_ref = home_target.Pose()

# Iterate through all the points
for i in range(len(POINTS)):
    # add a new target and keep the reference to it
    ti = RDK.AddTarget('Target %i' % (i + 1))

    # use the reference pose and update the XYZ position
    pose_i = pose_ref
    pose_i.setPos(POINTS[i])
    ti.setPose(pose_i)

    # force to use the target as a Cartesian target
    ti.setAsCartesianTarget()

    # Optionally, add the target as a Linear/Joint move in the new program
    prog.MoveL(ti)
#5
Hello, I have almost the same doubt. But I want to change only the Z pos....
Im drawing some glue points at a ceramic tiles and some time the Teach Target To Surface do some mistakes by getting downside of the tiles. And cause of that I'm clicking F3 to every 210 targets and then changing Z pos by hand.
What can I use on RoboDK API to change that?

I made something like that
Code:
print('Targets in the station:')
i=1
while i<10:
    in_target = RDK.Item('P '+str(i), ITEM_TYPE_TARGET) #Get target and use In function target
    saida = in_target.Pose() #Debug Propose
    XYZABC = Pose_2_Motoman(saida) #Convert Pose To Cartesian
    x,y,z,a,b,c = XYZABC #Create x y z a b c
    XYZABC2 = [x,y,38,a,b,c] #Change only Z
    pose2 = Motoman_2_Pose(XYZABC2)  #Re-do pose
    in_target.SetPoseAbs(pose2) #Update Target
    print(pose2) #Debug Propose
    i += 1 #Can change to For function later;

BTW
But Im getting error when try to update target pose.
API returns that in_target dosent have SetPoseAbs


thanks;
Best Regards
#6
Code:
in_target.SetPoseAbs(pose2) #Update Target

setPoseAbs - the first letter in the name of this function is not capitalized
https://robodk.com/doc/en/PythonAPI/robo...setPoseAbs
#7
(06-28-2024, 09:51 AM)Sergei Wrote:
Code:
in_target.SetPoseAbs(pose2) #Update Target

setPoseAbs - the first letter in the name of this function is not capitalized
https://robodk.com/doc/en/PythonAPI/robo...setPoseAbs
Thanks! I figured it out today when I rewrite the code! 
Many thanks !
  




Users browsing this thread:
1 Guest(s)