Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
助教rget Joints() fails to raise exception
#1
collision_test_scene开放。从这个线程rdk:
//www.sinclairbody.com/forum/Thread-Targets-...rgets-move

Code:
>>> t = rdk.Item('Target 5')

>>> t.Joints()
Matrix: (6, 1)
[[ 64.011 ],
[ -123.779 ],
[ -112.164 ],
[ -34.057 ],
[ 90.000 ],
[ 64.011 ]]

Now close the station and try to access Joints(). Fails as expected:


Code:
>>> t.Joints()
Invalid item provided: The item identifier provided is not valid or it does not exist.
Traceback (most recent call last):
File "", line 1, in
File "/home/j/RoboDK/Python/robodk/robolink.py", line 4775, in Joints
self.link._check_status()
File "/home/j/RoboDK/Python/robodk/robolink.py", line 764, in _check_status
raise Exception(self.LAST_STATUS_MESSAGE)
Exception: Invalid item provided: The item identifier provided is not valid or it does not exist.


Now reopen the same station and try again. t.Joints() now points at the robot's joints. You can verify this by jogging a robot joint and then querying Joints() again. t.Name() still raises an exception as it should.


Code:
>>> t.Joints()
Matrix: (6, 1)
[[ 0.985 ],
[ -90.520 ],
[ -90.341 ],
[ -0.524 ],
[ 90.000 ],
[ 0.985 ]]

>>> t.Name()
Invalid item provided: The item identifier provided is not valid or it does not exist.
Traceback (most recent call last):
File "", line 1, in
File "/home/j/RoboDK/Python/robodk/robolink.py", line 4227, in Name
self.link._check_status()
File "/home/j/RoboDK/Python/robodk/robolink.py", line 764, in _check_status
raise Exception(self.LAST_STATUS_MESSAGE)
Exception: Invalid item provided: The item identifier provided is not valid or it does not exist.

t.setJoints() likewise moves the robot's joints.

Seems like what you intended is for Joints() to raise an exception like the other methods do after the station has been closed.
#2
This is a good observation. Thank you for your feedback. This happens because RoboDK takes the first robot available by default if your item in null or invalid (this happens by default with some commands that apply to robots).

We'll improve RoboDK to raise an exception to make sure the item pointer is correct with the next version.




Users browsing this thread:
1 Guest(s)