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

Setting Minimum distance from object

#3
I have changed my code slightly to incorpirate the new information you gave me as below


Code:
from robolink import *
from robodk import *


# Connect to RoboDK
RDK = Robolink()


# Get the robot and tool and object
robot = RDK.Item('KUKA KR 6 R900-2')
tool = RDK.Item('Kinect')
object = RDK.Item('Piston deform')

# Set the minimum distance constraint
min_distance = 5000 # Set the desired minimum distance in millimeters


while True:
# Get the pose of the robot, tool, and object
robot_pose = robot.Pose()
tool_pose = tool.PoseTool()
object_pose = object.Pose()

# Calculate the position of the tool in the global reference frame
tool_pose_global = robot_pose*tool_pose

# Calculate the distance between the tool and object
dist = subs3(tool_pose_global.Pos(), object_pose.Pos())
newdist = mult3(dist,1.0)

# If the distance is less than the minimum distance, move the robot away from the object
if newdist < min_distance:
displacement = min_distance - newdist
direction = mult3(dist, 1.0/dist)
new_pos = robot_pose * transl(displacement * direction)
robot.MoveJ(new_pos)





But now I am getting the error:Minimumdistance1.py", line 32, in
if newdist TypeError: '


I am assuming this means it cant compare the dist < min_distance as they are stored asdifferenttypes, but I am unsure how as Ibelievethey are both scalar types from the codesnippetsbelow

Code:
newdist = mult3(dist,1.0)
min_distance = 5000

I think I am getting closer to a final script but the last few lines are causing me some problems. any advice would be great


Messages In This Thread
RE: Setting Minimum distance from object - byAbdullahShafique27- 02-21-2023, 10:18 AM



Users browsing this thread:
1 Guest(s)