Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:intermediate:bullet_world [2019/07/08 16:24] – [Attaching objects to the robot] gkazhoya | tutorials: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: | + | **//Tested with Cram v0.8.0, ROS version: |
====== Bullet world demonstration ====== | ====== Bullet world demonstration ====== | ||
Line 153: | Line 153: | ||
(cram-robot-interfaces: | (cram-robot-interfaces: | ||
(assert (btr:object ?world :urdf ?robot ((0 0 0) (0 0 0 1)) :urdf , | (assert (btr:object ?world :urdf ?robot ((0 0 0) (0 0 0 1)) :urdf , | ||
- | (cram-robot-interfaces:robot-arms-parking-joint-states ?robot ? | + | (-> (rob-int: |
- | (assert (btr: | + | (assert (btr: |
- | (assert (btr: | + | (true)) |
+ | | ||
+ | | ||
+ | (true))))) | ||
</ | </ | ||
Line 223: | Line 226: | ||
<code lisp> | <code lisp> | ||
- | BTW-TUT> (btr:object btr: | + | BTW-TUT> (btr:object btr: |
</ | </ | ||
Line 232: | Line 235: | ||
(btr: | (btr: | ||
' | ' | ||
- | | + | |
</ | </ | ||
Line 305: | Line 308: | ||
<code lisp> | <code lisp> | ||
BTW-TUT> (prolog: | BTW-TUT> (prolog: | ||
- | (cram-robot-interfaces:robot ?robot) | + | (rob-int:robot ?robot) |
(btr: | (btr: | ||
NIL | NIL | ||
Line 329: | Line 332: | ||
BTW-TUT> | BTW-TUT> | ||
(def-fact-group costmap-metadata () | (def-fact-group costmap-metadata () | ||
- | (<- (location-costmap: | + | (<- (costmap-size 12 12)) |
- | (<- (location-costmap: | + | (<- (costmap-origin -6 -6)) |
- | (<- (location-costmap: | + | (<- (costmap-resolution 0.04)) |
- | + | ||
- | (<- (location-costmap: | + | (<- (costmap-padding 0.3)) |
- | (<- (location-costmap: | + | (<- (costmap-manipulation-padding 0.4)) |
- | (<- (location-costmap: | + | (<- (costmap-in-reach-distance 0.7)) |
- | (<- (location-costmap: | + | (<- (costmap-reach-minimal-distance 0.2)) |
- | (<- (location-costmap: | + | (<- (visibility-costmap-size 2)) |
- | (<- (location-costmap: | + | (<- (orientation-samples 2)) |
- | (<- (location-costmap: | + | (<- (orientation-sample-step 0.1))) |
</ | </ | ||
Now, we create an abstract location description that we call a // | Now, we create an abstract location description that we call a // | ||
Line 365: | Line 368: | ||
(type counter-top) | (type counter-top) | ||
| | ||
- | | + | |
| | ||
| | ||
Line 417: | Line 420: | ||
(btr: | (btr: | ||
' | ' | ||
- | | + | |
</ | </ | ||
The drawer is called ''" | The drawer is called ''" | ||
Line 425: | Line 428: | ||
Now let us spawn the fork inside the drawer: | Now let us spawn the fork inside the drawer: | ||
<code lisp> | <code lisp> | ||
- | (btr-utils:spawn-object | + | (prolog: |
- | ' | + | (assert (btr:object ? |
- | : | + | :mass 0.2 :color (0.5 0.5 0.5) :mesh : |
- | :pose '((1.0 0.9 0.75) (0 0 0 1))) | + | |
</ | </ | ||
Line 439: | Line 441: | ||
(prolog '(and (btr: | (prolog '(and (btr: | ||
(btr: | (btr: | ||
- | (assert (btr: | + | (assert (btr: |
</ | </ | ||
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 445: | Line 447: | ||
(btr: | (btr: | ||
' | ' | ||
- | | + | |
</ | </ | ||
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: | (prolog '(and (btr: | ||
- | (btr: | + | (btr: |
</ | </ | ||
- | 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 blank to ''? | + | 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 ''? |
<code lisp> | <code lisp> | ||
(prolog '(and (btr: | (prolog '(and (btr: | ||
- | (assert | + | (btr:%object ?world fork-1 ? |
+ | | ||
</ | </ | ||
- | In the fourth argument | + | This detaches |
+ | If you only want to detach from a specific | ||
Line 463: | Line 467: | ||
+ | |||
+ | |||
+ | < | ||
==== Visualizing coordinate frames of poses ==== | ==== Visualizing coordinate frames of poses ==== | ||
Line 476: | Line 483: | ||
</ | </ | ||
- | {{: | + | {{ : |
- | + | ||
+ | --></ | ||
Line 519: | Line 526: | ||
- | ==== Executing motions | + | ==== Using TF in the Bullet world ==== |
- | From now on we will use the utility | + | Per default, the TF listener is not set up in the REPL, when you are working with the Bullet world. |
- | The package '' | + | To have it running, we need a TF context. It is possible to create it manually, but to not overcomplicate this tutorial, |
- | By pressing '' | + | we will use the environment provided by the '' |
+ | |||
+ | For example, the following does not work (unless you have a real robot running in your ROS ecosystem): | ||
+ | <code lisp> | ||
+ | BTW-TUT> (cl-tf: | ||
+ | </ | ||
+ | and the following does: | ||
+ | <code lisp> | ||
+ | BTW-TUT> (urdf-proj: | ||
+ | | ||
+ | </ | ||
+ | Here, ''" | ||
+ | |||
+ | ==== 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 '' | ||
+ | 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. '' | ||
+ | |||
+ | Another | ||
+ | Until now we had to write lengthy Prolog queries to access the world state and assert changes to it. | ||
+ | From now on we will use the utility functions from '' | ||
+ | There are functions such as '' | ||
+ | By pressing '' | ||
We need a clean environment for this tutorial, so let's clean the world: | We need a clean environment for this tutorial, so let's clean the world: | ||
Line 530: | Line 559: | ||
</ | </ | ||
- | Now, let' | + | Let us try to perceive |
+ | For that we will use a mesh of a bottle loaded from the '' | ||
<code lisp> | <code lisp> | ||
BTW-TUT> (add-objects-to-mesh-list) | BTW-TUT> (add-objects-to-mesh-list) | ||
Line 539: | Line 569: | ||
BTW-TUT> (btr-utils: | BTW-TUT> (btr-utils: | ||
(cl-transforms: | (cl-transforms: | ||
- | | + | |
| | ||
</ | </ | ||
- | Lastly we simulate the world for 10 seconds to make sure, nothing moves unexpectedly | + | Lastly we simulate the world for 10 seconds to make sure, nothing moves unexpectedly |
<code lisp> | <code lisp> | ||
- | BTW-TUT> (btr: | + | BTW-TUT> (btr: |
</ | </ | ||
- | Before we grasp the bottle, | + | Before we perceive |
<code lisp> | <code lisp> | ||
- | BTW-TUT> (setf ? | + | BTW-TUT> (defparameter |
| | ||
" | " | ||
Line 558: | Line 588: | ||
The same thing can be done with the point we want to look at. | The same thing can be done with the point we want to look at. | ||
<code lisp> | <code lisp> | ||
- | BTW-TUT> (setf ? | + | BTW-TUT> (defparameter |
| | ||
" | " | ||
Line 565: | Line 595: | ||
(cl-transforms: | (cl-transforms: | ||
</ | </ | ||
- | To execute any plan in CRAM, we need a top-level context. Besides that we also use a macro to specify that the demo should be executed in simulation, not on the real robot. Putting your plan under '' | + | |
+ | < | ||
+ | To execute any plan in CRAM, we need a top-level context. Besides that we also use a macro to specify that the demo should be executed in simulation, not on the real robot. Putting your plan under '' | ||
+ | We can execute some movements in parallel, if they use different joints of the robot. That's what '' | ||
+ | We have used a simple call to low level methods to achieve motions like move to the ''? | ||
+ | --></ | ||
+ | |||
+ | Putting all these together we end up with the following: | ||
<code lisp> | <code lisp> | ||
BTW-TUT> | BTW-TUT> | ||
- | (pr2-proj: | + | (urdf-proj: |
- | (cpl:par | + | (urdf-proj:: |
- | (pp-plans:park-arms) | + | -0.26499816732737785d0 |
- | (pr2-proj:: | + | |
- | (pr2-proj:: | + | |
+ | | ||
+ | | ||
+ | | ||
+ | ' | ||
+ | -0.2567290370386635d0 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | (urdf-proj:: | ||
+ | (urdf-proj:: | ||
+ | </ | ||
+ | As some of the functions in '' | ||
+ | The function '' | ||
+ | <code lisp> | ||
+ | (prolog: | ||
</ | </ | ||
- | We can execute some movements in parallel, if they use different joints of the robot. That's what ''cpl:par'' | + | '' |
- | To grasp the bottle we need to have its pose in the room. Therefore, we first perceive | + | Now, let us finally |
<code lisp> | <code lisp> | ||
BTW-TUT> | BTW-TUT> | ||
(defvar *perceived-object* nil " | (defvar *perceived-object* nil " | ||
- | (pr2-proj: | + | (urdf-proj: |
(setf *perceived-object* | (setf *perceived-object* | ||
- | (pr2-proj:: | + | (urdf-proj:: |
</ | </ | ||
- | With that resulting perceived object we perform the picking up action. With the torso so far down we might not be able to reach for the bottle, so we need to also push the torso up: | + | With that resulting perceived object we could perform the picking up action. With the torso so far down we might not be able to reach the bottle, so we need to push the torso up: |
<code lisp> | <code lisp> | ||
- | (pr2-proj: | + | (urdf-proj: |
- | (let ((? | + | (urdf-proj:: |
- | (pr2-proj:: | + | |
</ | </ | ||
As there is no atomic motion for picking up an object, in fact, picking up is comprised of multiple move-arm motions, | As there is no atomic motion for picking up an object, in fact, picking up is comprised of multiple move-arm motions, | ||
- | so pick up is implemented within a plan and called by performing an action designator. | + | pick up is implemented within a plan and called by performing an action designator. |