Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:intermediate:bullet_world [2022/04/12 14:39] – [Abstract entity descriptions] schimpftutorials:intermediate:bullet_world [2023/05/02 14:15] (current) – [Abstract entity descriptions] gkazhoya
Line 1: Line 1:
-**//Tested with Cram v0.7.0, ROS version: Kinetic, Ubuntu 16.04//**+**//Tested with Cram v0.8.0, ROS version: Noetic, Ubuntu 20.04//**
  
 ====== Bullet world demonstration ====== ====== Bullet world demonstration ======
Line 308: Line 308:
 <code lisp> <code lisp>
 BTW-TUT> (prolog:prolog '(and (btr:bullet-world ?world) BTW-TUT> (prolog:prolog '(and (btr:bullet-world ?world)
-                              (assert (btr:object-pose ?world :pr2 +                              (rob-int:robot ?robot) 
-                                                       ((0.5 0) (0 0 1 0))))))+                              (btr:visible ?world ?robot mug-1)))
 NIL NIL
 </code> </code>
Line 332: Line 332:
 BTW-TUT> BTW-TUT>
 (def-fact-group costmap-metadata () (def-fact-group costmap-metadata ()
-    (<- (:costmap-size 12 12)) +    (<- (costmap-size 12 12)) 
-    (<- (:costmap-origin -6 -6)) +    (<- (costmap-origin -6 -6)) 
-    (<- (:costmap-resolution 0.04))+    (<- (costmap-resolution 0.04))
    
-    (<- (:costmap-padding 0.3)) +    (<- (costmap-padding 0.3)) 
-    (<- (:costmap-manipulation-padding 0.4)) +    (<- (costmap-manipulation-padding 0.4)) 
-    (<- (:costmap-in-reach-distance 0.7)) +    (<- (costmap-in-reach-distance 0.7)) 
-    (<- (:costmap-reach-minimal-distance 0.2)) +    (<- (costmap-reach-minimal-distance 0.2)) 
-    (<- (:visibility-costmap-size 2)) +    (<- (visibility-costmap-size 2)) 
-    (<- (:orientation-samples 2)) +    (<- (orientation-samples 2)) 
-    (<- (:orientation-sample-step 0.1)))+    (<- (orientation-sample-step 0.1)))
 </code> </code>
 Now, we create an abstract location description that we call a //designator//. The abstract description gets grounded into specific geometric coordinates with the ''reference'' function.  Now, we create an abstract location description that we call a //designator//. The abstract description gets grounded into specific geometric coordinates with the ''reference'' function. 
Line 420: Line 420:
 (btr:set-robot-state-from-joints (btr:set-robot-state-from-joints
  '(("sink_area_left_upper_drawer_main_joint"  0.4))  '(("sink_area_left_upper_drawer_main_joint"  0.4))
- (btr:object btr:*current-bullet-world* :kitchen))+ (btr:object btr:*current-bullet-world* :iai-kitchen))
 </code> </code>
 The drawer is called ''"sink_area_left_upper_drawer_main_joint"'' and we would like to open it to 0.4 meters. The drawer is called ''"sink_area_left_upper_drawer_main_joint"'' and we would like to open it to 0.4 meters.
Line 441: Line 441:
 (prolog '(and (btr:bullet-world ?world) (prolog '(and (btr:bullet-world ?world)
               (btr:%object ?world fork-1 ?fork)               (btr:%object ?world fork-1 ?fork)
-              (assert (btr:attached ?world :kitchen "sink_area_left_upper_drawer_main" ?fork))))+              (assert (btr:attached ?world :iai-kitchen "sink_area_left_upper_drawer_main" ?fork))))
 </code> </code>
 Notice, that the joint name differs from the link name. Now the fork moves when the drawer is moved. Notice, that the joint name differs from the link name. Now the fork moves when the drawer is moved.
Line 447: Line 447:
 (btr:set-robot-state-from-joints (btr:set-robot-state-from-joints
  '(("sink_area_left_upper_drawer_main_joint"  0.3))  '(("sink_area_left_upper_drawer_main_joint"  0.3))
- (btr:object btr:*current-bullet-world* :kitchen))+ (btr:object btr:*current-bullet-world* :iai-kitchen))
 </code> </code>
  Every attachment can be checked with the following predicate:  Every attachment can be checked with the following predicate:
 <code lisp> <code lisp>
 (prolog '(and (btr:bullet-world ?world) (prolog '(and (btr:bullet-world ?world)
-              (btr:attached ?world :kitchen ?_ fork-1)))+              (btr:attached ?world :iai-kitchen ?_ fork-1)))
 </code> </code>
 This checks if there is any attachments between kitchen and fork. If needed, it is possible to set the name of a link to be specifically checked. Or set the ''?_'' to ''?link'', to get the list of links the object is attached to. To detach an object, the ''retract'' predicate does the job. This checks if there is any attachments between kitchen and fork. If needed, it is possible to set the name of a link to be specifically checked. Or set the ''?_'' to ''?link'', to get the list of links the object is attached to. To detach an object, the ''retract'' predicate does the job.
Line 458: Line 458:
 (prolog '(and (btr:bullet-world ?world) (prolog '(and (btr:bullet-world ?world)
               (btr:%object ?world fork-1 ?fork-instance)               (btr:%object ?world fork-1 ?fork-instance)
-              (btr:retract (btr:attached ?world :kitchen ?fork-instance))))+              (btr:retract (btr:attached ?world :iai-kitchen ?fork-instance))))
 </code> </code>
 This detaches the fork from all the links of the kitchen that it has been attached to. This detaches the fork from all the links of the kitchen that it has been attached to.
Line 538: Line 538:
 and the following does: and the following does:
 <code lisp> <code lisp>
-BTW-TUT> (pr2-proj:with-simulated-robot+BTW-TUT> (urdf-proj:with-simulated-robot
            (cl-tf:lookup-transform cram-tf:*transformer* "map" "l_gripper_tool_frame"))            (cl-tf:lookup-transform cram-tf:*transformer* "map" "l_gripper_tool_frame"))
 </code> </code>
Line 545: Line 545:
 ==== Moving the robot in the Bullet world ==== ==== Moving the robot in the Bullet world ====
  
-In this part of the tutorial we will look into moving the robot and it's body parts as well as perceiving objects through the Bullet world. We will use functions from the ''cram_pr2_projection'' package, which implements a simple robot simulator in the Bullet world. This robot simulator does not execute motions in a continuous manner, but by teleporting through key poses. +In this part of the tutorial we will look into moving the robot and it's body parts as well as perceiving objects through the Bullet world. We will use functions from the ''cram-urdf-projection'' package, which implements a simple robot simulator in the Bullet world. This robot simulator does not execute motions in a continuous manner, but by teleporting through key poses. 
-This teleporting is done by directly calling Prolog predicates that move objects in the world (for navigating the robot, simply teleport it to the goal), changing joint angles (to move the arm simply teleport the arm to given joint values) etc. ''cram_pr2_projection'' also uses Prolog predicates for attaching and detaching objects to the robot, as we did with the fork and the drawer.+This teleporting is done by directly calling Prolog predicates that move objects in the world (for navigating the robot, simply teleport it to the goal), changing joint angles (to move the arm simply teleport the arm to given joint values) etc. ''cram-urdf-projection'' also uses Prolog predicates for attaching and detaching objects to the robot, as we did with the fork and the drawer.
  
 Another package that we will use in this part of the tutorial is ''cram_bullet_reasoning_utilities'', which has a number of utility functions to make rapid prototyping with the Bullet world faster and easier. Another package that we will use in this part of the tutorial is ''cram_bullet_reasoning_utilities'', which has a number of utility functions to make rapid prototyping with the Bullet world faster and easier.
Line 569: Line 569:
 BTW-TUT> (btr-utils:move-object 'bottle-1 BTW-TUT> (btr-utils:move-object 'bottle-1
                                 (cl-transforms:make-pose                                 (cl-transforms:make-pose
-                                 (cl-transforms:make-3d-vector -2 -0.9 0.83)+                                 (cl-transforms:make-3d-vector -2 -0.83)
                                  (cl-transforms:make-identity-rotation)))                                  (cl-transforms:make-identity-rotation)))
 </code> </code>
Line 605: Line 605:
 <code lisp> <code lisp>
 BTW-TUT> BTW-TUT>
-(pr2-proj:with-simulated-robot +(urdf-proj:with-simulated-robot 
-  (pr2-proj::move-joints '(1.9652919379395388d0+  (urdf-proj::move-joints '(1.9652919379395388d0
                            -0.26499816732737785d0                            -0.26499816732737785d0
                            1.3837617139225473d0                            1.3837617139225473d0
Line 620: Line 620:
                            -0.07942669250968948d0                            -0.07942669250968948d0
                            0.05106258161229582d0))                            0.05106258161229582d0))
-  (pr2-proj::drive ?grasp-base-pose) +  (urdf-proj::drive ?grasp-base-pose) 
-  (pr2-proj::look-at :pose ?grasp-look-pose))+  (urdf-proj::look-at ?grasp-look-pose nil))
 </code> </code>
-As some of the functions in ''cram-pr2-projection'' package need a running TF listener object, we wrapped our calls in ''pr2-proj:with-simulated-robot''.+As some of the functions in ''cram-urdf-projection'' package need a running TF listener object, we wrapped our calls in ''urdf-proj:with-simulated-robot''.
  
-The function ''pr2-proj::move-joints'' moves the joints of both arms, which brings them into a specific position, specified in the arguments, so they don't hang around the field of view. ''pr2-proj::drive'' moves the robot, by internally calling +The function ''urdf-proj::move-joints'' moves the joints of both arms, which brings them into a specific position, specified in the arguments, so they don't hang around the field of view. ''urdf-proj::drive'' moves the robot, by internally calling 
 <code lisp> <code lisp>
 (prolog:prolog '(btr:assert ?world (btr:object-pose ?robot ?target-pose))) (prolog:prolog '(btr:assert ?world (btr:object-pose ?robot ?target-pose)))
 </code> </code>
-''pr2-proj::look-at'' calculates the pan and tilt angles of the robot's neck such that it ends up looking at the specified point, and asserts these angles to the neck joints.+''urdf-proj::look-at'' calculates the pan and tilt angles of the robot's neck such that it ends up looking at the specified point, and asserts these angles to the neck joints.
  
 Now, let us finally perceive the object and store the result in the ''*perceived-object*'' variable: Now, let us finally perceive the object and store the result in the ''*perceived-object*'' variable:
Line 635: Line 635:
 BTW-TUT> BTW-TUT>
 (defvar *perceived-object* nil "Object designator returned from perception") (defvar *perceived-object* nil "Object designator returned from perception")
-(pr2-proj:with-simulated-robot+(urdf-proj:with-simulated-robot
   (setf *perceived-object*   (setf *perceived-object*
-        (pr2-proj::detect (desig:an object (type bottle)))))+        (urdf-proj::detect (desig:an object (type bottle)))))
 </code> </code>
  
Line 643: Line 643:
  
 <code lisp> <code lisp>
-(pr2-proj:with-simulated-robot +(urdf-proj:with-simulated-robot 
-    (let ((?perceived-bottle-desig *perceived-object*)) +      (urdf-proj::move-torso 0.3))
-      (pr2-proj::move-torso 0.3)))+
 </code> </code>