Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grasping / Sensor Bug #565

Closed
seantrott opened this issue Oct 6, 2014 · 15 comments
Closed

Grasping / Sensor Bug #565

seantrott opened this issue Oct 6, 2014 · 15 comments

Comments

@seantrott
Copy link

I am using the Human component in MORSE, with the intent of demonstrating grasping motions like "picking up" and "putting down". I've set up my scene with a MORSE human, as well as a "socket" service to control this human from a simulator file.

However, when I call the "grasp" function from the simulated human instance, an error arises within the grasp function itself:

In line 49 of grasping_robot.py (possibly line 47 on some versions), this code fails: "near_sensor = hand_empty.sensors['Near']"

This error is:
"""
line 49, in grasp
near_sensor = hand_empty.sensors['Near']
KeyError: 'requested item "Near" does not exist'
"""

I think it has to do with an error in instantiating the Sensors list. I am going to try and append my own Sensor to the human, but it seems to be a bug in MORSE.

@adegroote
Copy link
Contributor

Can you provide a minimal builder script showing the issue ?

adegroote pushed a commit to adegroote/morse that referenced this issue Oct 7, 2014
Enable it for human.
For PR2, I don't have any idea how to call it at the morse.robot.pr2
speaks about Hand.Grasp.PR2, which does not exists ...
Should fix morse-simulator#565
@adegroote
Copy link
Contributor

Can you test my fix_565 branch ?

@seantrott
Copy link
Author

I will copy the code now to test. Here is an example of the builder script, as well as the simulator script:

Here is the builder code:
motion2 = Waypoint()
motion2.properties(ObstacleAvoidance = False)
motion2.properties(ControlType="Position")
motion2.add_interface('socket')
motion2.add_service('socket')
motion2.add_stream('socket')
human_pose = Pose()
human_pose.add_interface('socket')
human = Human(name="john_instance")
human.use_world_camera()
human.append(motion2)
human.append(human_pose)
human.disable_keyboard_control()
human.add_service('socket')

And here is the code to call grasp:

    inst = getattr(self.simulator, self.name)
    inst.grasp(True, 'bottle1_instance')

Alternatively:

    inst.grasp(True)

@seantrott
Copy link
Author

I copied/pasted the code referenced here (adegroote@d703ba5) into the relevant files. There's no longer an error on line 49, which governs the sensors, but now there is an error on line 54, when I call:

grasp(True, 'bottle1_instance')
""File "/usr/local/lib/python3.4/site-packages/morse/robots/grasping_robot.py", line 54, in grasp
if (grasping_robot['DraggedObject'] is None or grasping_robot['DraggedObject'] == '') :
KeyError: 'value = gameOb[key]: KX_GameObject, key "DraggedObject" does not exist'
""

If I just call:
inst.grasp(True)

There's no error, but the human also doesn't pick up the closest object (there is a bottle next to him), which I thought grasp() was supposed to do if no object name was specified.

@adegroote
Copy link
Contributor

You need also adegroot@84bfa31d9 which is in the branch (which fix the previous error) Otherwise, the human should pick the object if the object is in the 'range' of the Near sensor. Maybe we need to put a bigger ranger for the Near sensor using 'sens.distance = xxx' in the make_grasper method

@seantrott
Copy link
Author

Ah, I see, thanks - though the "adegroot@84bfa31" link leads to a 404 error?

@adegroote
Copy link
Contributor

It is adegroote@84bfa31

@seantrott
Copy link
Author

Thanks for your feedback on all this. I added that line of code to grasping_robot.py, and it addressed the error I referenced above. However, I think there might be an issue with the Sensors; when I call:

grasp(True, 'bottle1_instance')

The MORSE log prints this line during its output:
[ 44.809] [robots.grasping_robot] no object named bottle1_instance in []

Above, the "[]" referenced is meant to be the list of objects near the Human, obtained in grasping_robot.grasp:

"near_sensor.hitObjectList"

I added a line changing the Sensor distance dramatically in make_grasp, but the method still can't seem to locate any "near" objects.

@adegroote
Copy link
Contributor

Do you have call setgraspable on the object you're interested in ? see

http://www.openrobots.org/morse/doc/1.2/user/others/passive_objects.html

@seantrott
Copy link
Author

Yes, when I initialize the bottle instance I set it:

bottle1 = PassiveObject('environments/indoors-1/indoor-1', 'Bottle1')
bottle1.properties(Object=True, Label="bottle1_instance", Type='bottle', Graspable=True)    
bottle1.setgraspable()
bottle1.translate(x=0, y=0, z=1)

It seems that the sensor doesn't recognize it as being "near". I have the sens.distance set to 10.

@adegroote
Copy link
Contributor

Probably miss something in my patch, will try to fix it tomorrow

@adegroote
Copy link
Contributor

Can you test with one more patch adegroote@33cf6fd ?

@seantrott
Copy link
Author

Thanks, so this worked somewhat. I determined that you need to pass in the variable name of the object, not the object label (e.g., "bottle1", not "bottle1_instance".) and it doesn't work even when I rename the variable name to "bottle1_instance".

But the human does pick up the bottle when I call:

grasp(True, 'bottle1').

However, once he picks up the bottle, he moves randomly across the screen and disappears from view. Any idea on why this might be? I get the message that the GRASP action is successful, and as soon as he picks it up, he starts moving away.

@adegroote
Copy link
Contributor

It seems odd. It looks like a physics bugs, when some physical objects interacts in bad way and the physical engine diverges. I will retest tomorrow, but I don't think I get this behaviour. Debugging it would be harder (as I don't want to touch too much the physics related to human).

Considering the name, the doc mentions properly the 'object name', so it seems to be the expected behaviour.

@seantrott
Copy link
Author

I see, thanks. I tried putting the Simulator to sleep after the grasping motion is completed, but it had no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants