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

[WIP] Move robot-common part of simulated grasping to robot-interface #435

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions pr2eus/pr2-interface.l
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,8 @@ Example: (send self :gripper :rarm :position) => 0.00"
(&optional (arm :arms) &key ((:gain g) 0.01) ((:objects objs) objects) force-assoc ((:wait wait) t))
(send self :move-gripper arm 0.0 :effort (* 2000 g) :wait wait)
(unless joint-action-enable
(dolist (a (if (eq arm :arms) '(:larm :rarm) (list arm)))
(when objs
(let ((grasp-convex
(convex-hull-3d
(flatten
(mapcar
#'(lambda (l)
(send-all (send l :bodies) :worldcoords)
(send-all (send l :bodies) :vertices))
(send robot a :gripper :links))))))
(dolist (obj objs)
(when (or force-assoc
(and (find-method obj :faces)
(not (= (pqp-collision-check grasp-convex obj) 0))))
(if (send obj :parent) (send (send obj :parent) :dissoc obj))
(send robot a :end-coords :assoc obj))))))
(send self :assoc-objects-in-gripper
(if (eq arm :arms) '(:larm :rarm) (list arm)) :objects objs :force-assoc force-assoc)
;; (send self :update-robot-state) ;; update state of 'robot' for real robot
(return-from :start-grasp
(case arm
Expand Down Expand Up @@ -352,9 +338,8 @@ Example: (send self :gripper :rarm :position) => 0.00"
(prog1
(send self :move-gripper arm 0.09 :effort (* 2000 g) :wait wait)
(unless joint-action-enable
(dolist (a (if (eq arm :arms) '(:larm :rarm) (list arm)))
(dolist (obj (send robot a :end-coords :descendants))
(send robot arm :end-coords :dissoc obj))))))
(send self :dissoc-objects-in-gripper
(if (eq arm :arms) '(:larm :rarm) (list arm))))))
;;
(:pr2-gripper-state-callback
(arm msg)
Expand Down
23 changes: 23 additions & 0 deletions pr2eus/robot-interface.l
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,29 @@ Return value is a list of interpolatingp for all controllers, so (null (some #'i
(if spin-self (send self :spin-once))
(ros::sleep)))
t)
(:assoc-objects-in-gripper
(arm-list &key ((:objects objs) objects) force-assoc)
(dolist (a arm-list)
(when objs
(let ((grasp-convex
(convex-hull-3d
(flatten
(mapcar
#'(lambda (l)
(send-all (send l :bodies) :worldcoords)
(send-all (send l :bodies) :vertices))
(send robot a :gripper :links))))))
(dolist (obj objs)
(when (or force-assoc
(and (find-method obj :faces)
(not (= (pqp-collision-check grasp-convex obj) 0))))
(if (send obj :parent) (send (send obj :parent) :dissoc obj))
(send robot a :end-coords :assoc obj)))))))
(:dissoc-objects-in-gripper
(arm-list)
(dolist (a arm-list)
(dolist (obj (send robot a :end-coords :descendants))
(send robot a :end-coords :dissoc obj))))
;;
(:go-pos
(x y &optional (d 0)) ;; [m] [m] [degree]
Expand Down