Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:advanced:bullet_world_boxy [2015/09/11 15:33] – created gkazhoya | tutorials:advanced:bullet_world_boxy [2015/09/17 14:58] (current) – created gkazhoya | ||
---|---|---|---|
Line 4: | Line 4: | ||
The starting point of this tutorial is an installation of CRAM including projection with PR2. If you followed the installation manual, you should have all the necessary packages already. | The starting point of this tutorial is an installation of CRAM including projection with PR2. If you followed the installation manual, you should have all the necessary packages already. | ||
+ | |||
+ | |||
+ | ===== Robot URDF description ===== | ||
+ | |||
+ | The first thing that we actually need is the robot, more precisely, its URDF description. | ||
+ | For Boxy it is located in a repo on Github, so let's clone it into our ROS workspace: | ||
+ | |||
+ | <code bash> | ||
+ | cd ROS_WORKSPACE_FOR_LISP_CODE | ||
+ | cd src | ||
+ | git clone https:// | ||
+ | cd .. | ||
+ | catkin_make | ||
+ | </ | ||
+ | |||
+ | CRAM takes the URDF descriptions of the robots from the ROS parameter server, i.e., you will need to upload the URDFs of your robots as a ROS parameter. For Boxy there is a launch file doing that, you will find it here: | ||
+ | |||
+ | <code bash> | ||
+ | roscd iai_boxy_description/ | ||
+ | </ | ||
+ | |||
+ | It's called '' | ||
+ | |||
+ | <code xml> | ||
+ | < | ||
+ | <arg name=" | ||
+ | <arg name=" | ||
+ | |||
+ | <param | ||
+ | name=" | ||
+ | command=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | As we will need to know the names of the TF frames later, we will launch a general file that includes uploading the URDF as well as a robot state publisher: | ||
+ | |||
+ | <code bash> | ||
+ | roslaunch iai_boxy_description display.launch | ||
+ | </ | ||
+ | |||
+ | (It also starts a GUI to play with the joint angles but let's ignore that.) | ||
+ | |||
+ | Let's check if the URDF's on the parameter server using RViz: | ||
+ | |||
+ | <code bash> | ||
+ | rosrun rviz rviz | ||
+ | Add -> RobotModel -> Robot Description: | ||
+ | Add -> TF | ||
+ | </ | ||
+ | |||
+ | To be able to see the TF frames choose '' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
===== Directory / file setup ===== | ===== Directory / file setup ===== | ||
- | First of all, let' | + | Now let' |
<code bash> | <code bash> | ||
Line 31: | Line 86: | ||
</ | </ | ||
- | Now let's create the corresponding | + | Now let's create the corresponding |
<code lisp> | <code lisp> | ||
Line 61: | Line 116: | ||
</ | </ | ||
+ | Also, an empty '' | ||
- | ===== Robot URDF description ===== | + | Now, let's compile our new packages and load them through the REPL: |
- | Now, before creating the file with the actual | + | <code lisp> |
- | + | CL-USER> | |
- | <code bash> | + | ros-load-system |
- | cd ROS_WORKSPACE_FOR_LISP_CODE | + | cram_boxy_knowledge |
- | cd src | + | cram-boxy-knowledge |
- | git clone https:// | + | |
</ | </ | ||
- | Now let's compile our workspace such that ROS learns about the new '' | ||
- | |||
- | CRAM takes the URDF descriptions of the robots from the ROS parameter server, i.e., you will need to upload the URDFs of your robots. For Boxy there is a launch file doing that, you will find it here: | ||
- | |||
- | <code bash> | ||
- | roscd iai_boxy_description/ | ||
- | </ | ||
- | |||
- | It's called '' | ||
- | |||
- | <code xml> | ||
- | < | ||
- | <arg name=" | ||
- | <arg name=" | ||
- | |||
- | <param | ||
- | name=" | ||
- | command=" | ||
- | </ | ||
- | </ | ||
- | |||
- | As we will need to know the names of the TF frames later, we will launch a general file that includes uploading the URDF as well as a robot state publisher: | ||
- | |||
- | <code bash> | ||
- | roslaunch iai_boxy_description upload_boxy.launch | ||
- | </ | ||
- | |||
- | (It starts a GUI to play with the joint angles but let's ignore that.) | ||
- | |||
- | Let's check if it's there using RViz: | ||
- | |||
- | <code bash> | ||
- | rosrun rviz rviz | ||
- | Add -> Robot Model -> Robot description: | ||
- | Add -> TF | ||
- | </ | ||
- | |||
- | To be able to see the TF frames choose '' | ||
- | |||
- | |||
- | {{ : | ||
===== Boxy Prolog description ===== | ===== Boxy Prolog description ===== | ||
- | Now that we have a URDF on the ROS parameter server, let's describe our robot also in Prolog. | + | Now, let's describe our robot in Prolog, such that we could do some reasoning with it. |
- | We create a file '' | + | We fill in the file '' |
As can be seen from the TF tree, our robot has 3 camera frames, 1 depth and 1 RGB frame from a Kinect camera, and an RGB frame from a Kinect2 camera. | As can be seen from the TF tree, our robot has 3 camera frames, 1 depth and 1 RGB frame from a Kinect camera, and an RGB frame from a Kinect2 camera. | ||
Line 144: | Line 158: | ||
(<- (robot-pan-tilt-joints boxy " | (<- (robot-pan-tilt-joints boxy " | ||
</ | </ | ||
+ | |||
+ | Finally, compile the file ('' | ||
+ | |||
+ | |||
===== Loading the world ===== | ===== Loading the world ===== | ||
- | Now let's try to set up the world. | + | Now let's try to load our robot also into the Bullet |
- | We will only spawn the floor, the robot, and a couple of household objects. | + | We will spawn the floor, the robot, and a couple of household objects. |
For that, we | For that, we | ||
- | - load the bullet reasoning | + | - load the bullet reasoning package in the REPL |
- start a ROS node | - start a ROS node | ||
- spawn the robot and the floor | - spawn the robot and the floor | ||
- | - | + | - spawn a big box for a table and a couple of household objects to go on top |
<code lisp> | <code lisp> | ||
- | (asdf: | + | ;; step 1 |
+ | (asdf: | ||
(in-package :btr) | (in-package :btr) | ||
+ | ;; step 2 | ||
+ | (roslisp: | ||
+ | ;; step 3 | ||
+ | (let ((robot-urdf (cl-urdf: | ||
+ | (prolog | ||
+ | `(and | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | : | ||
+ | : | ||
+ | | ||
+ | |||
+ | ;; step 4 | ||
+ | (prolog | ||
+ | `(and | ||
+ | | ||
+ | | ||
+ | :size (0.7 1.5 1) :mass 10.0)) | ||
+ | | ||
+ | :mesh :pot)) | ||
+ | | ||
+ | :mesh :mug)) | ||
+ | | ||
+ | :mesh :mug)))) | ||
+ | </ | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | |||
+ | ===== Reasoning with Boxy ===== | ||
+ | |||
+ | Let's try some reasoning: | ||
+ | |||
+ | <code lisp> | ||
+ | BTR> (prolog ' | ||
+ | NIL | ||
+ | </ | ||
+ | |||
+ | The query asks if the object '' | ||
+ | The answer is " | ||
+ | Now let's put the object higher and try again: | ||
+ | |||
+ | <code lisp> | ||
+ | BTR> (prolog ' | ||
+ | | ||
+ | | ||
+ | BTR> (prolog ' | ||
+ | (((?WORLD . #< | ||
+ | (?ROBOT . CRAM-BOXY-KNOWLEDGE:: | ||
+ | . # | ||
+ | </ | ||
+ | |||
+ | Now it is visible. | ||
+ | |||
+ | Let's put the pot down: | ||
+ | |||
+ | <code lisp> | ||
+ | BTR> (simulate *current-bullet-world* 50) | ||
+ | </ | ||
+ | |||
+ | Now let's do something more complex: let's generate a visibility costmap, that will generate poses from where Boxy will be able to see the pot. | ||
+ | As we're going to be using costmaps, we will need to define costmap metadata first: | ||
+ | |||
+ | <code lisp> | ||
+ | BTR> (def-fact-group costmap-metadata () | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | We should also load the '' | ||
+ | <code lisp> | ||
+ | BTR> (asdf: | ||
+ | </ | ||
+ | |||
+ | Now let's create a location designator for a pose to see the '' | ||
+ | |||
+ | <code lisp> | ||
+ | BTR> (let ((location-to-see (desig: | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | {{ : | ||