Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:advanced:bullet_world_robot [2015/09/11 12:47] – gkazhoya | tutorials:advanced:bullet_world_robot [2015/09/17 15:54] (current) – [Boxy Prolog description] gkazhoya | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Setting up the Bullet world with a new robot ====== | ====== Setting up the Bullet world with a new robot ====== | ||
- | This tutorial will walk you though creating your own repo / metapackage from scratch that will use CRAM and Bullet world with your own robots. In this tutorial we will use the Boxy robot as an example. | + | This tutorial will walk you though creating your own repo / metapackage from scratch that will use CRAM and Bullet world with your own robots. In this tutorial we will use the [[http:// |
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 the quadrotor it is located in a repo on Github and if you're lucky it's also release as a Debian, so let's install it / clone it into our ROS workspace: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install ros-YOUR-ROS-DISTRO-hector-quadrotor-description | ||
+ | rospack profile | ||
+ | # or | ||
+ | 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 our robot there is a launch file doing that, you will find it here: | ||
+ | |||
+ | <code bash> | ||
+ | roscd hector_quadrotor_description/ | ||
+ | </ | ||
+ | |||
+ | It's called '' | ||
+ | |||
+ | <code xml> | ||
+ | < | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | | ||
+ | <node name=" | ||
+ | <node name=" | ||
+ | <node name=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | It includes a robot state publisher to publish the TF, we will need it to know the names of the TF frames of the robot later. | ||
+ | It also starts Rviz: | ||
+ | |||
+ | <code bash> | ||
+ | roslaunch hector_quadrotor_description xacrodisplay_quadrotor_base.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. For that, in RViz click: | ||
+ | |||
+ | <code bash> | ||
+ | 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> | ||
- | mkdir cram_boxy | + | mkdir cram_quadrotor |
- | catkin_create_pkg | + | catkin_create_pkg |
</ | </ | ||
Line 18: | Line 75: | ||
<code cmake> | <code cmake> | ||
cmake_minimum_required(VERSION 2.8.3) | cmake_minimum_required(VERSION 2.8.3) | ||
- | project(cram_boxy) | + | project(cram_quadrotor) |
find_package(catkin REQUIRED) | find_package(catkin REQUIRED) | ||
catkin_metapackage() | catkin_metapackage() | ||
</ | </ | ||
- | The first ROS package we will create will be the Prolog description of our robot. We will call it '' | + | The first ROS package we will create will be the Prolog description of our robot. We will call it '' |
- | Go back to the root of your '' | + | Go back to the root of your '' |
<code bash> | <code bash> | ||
cd .. | cd .. | ||
- | catkin_create_pkg | + | catkin_create_pkg |
</ | </ | ||
- | Now let's create the corresponding | + | Now let's create the corresponding |
<code lisp> | <code lisp> | ||
;;; You might want to add a license header first | ;;; You might want to add a license header first | ||
- | (defsystem cram-boxy-knowledge | + | (defsystem cram-quadrotor-knowledge |
:author "Your Name" | :author "Your Name" | ||
:license " | :license " | ||
Line 45: | Line 102: | ||
:components | :components | ||
((:file " | ((:file " | ||
- | | + | |
</ | </ | ||
- | Now create the corresponding '' | + | Now create the corresponding '' |
<code lisp> | <code lisp> | ||
Line 55: | Line 112: | ||
(in-package :cl-user) | (in-package :cl-user) | ||
- | (defpackage cram-boxy-knowledge | + | (defpackage cram-quadrotor-knowledge |
(:use #: | (:use #: | ||
#: | #: | ||
Line 61: | Line 118: | ||
</ | </ | ||
+ | Also, an empty '' | ||
- | ===== Robot URDF description ===== | + | Now, let's compile our new packages ('' |
- | Now, before creating the file with the actual | + | <code lisp> |
- | + | CL-USER> | |
- | <code bash> | + | ros-load-system |
- | cd ROS_WORKSPACE_FOR_LISP_CODE | + | cram_quadrotor_knowledge |
- | cd src | + | cram-quadrotor-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: | + | ===== Boxy Prolog description ===== |
- | <code bash> | + | Now, let's describe our robot in Prolog, such that we could do some reasoning with it. |
- | roscd iai_boxy_description/ | + | |
- | </ | + | |
- | It's called | + | We fill in the file '' |
- | <code xml> | + | 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. |
- | < | + | {{ : |
- | <arg name=" | + | |
- | <arg name=" | + | |
- | <param | + | It's camera can be from 1.60 m to 2.10 m above the ground, depending on the torso position. |
- | name=" | + | It also has a pan-tilt-unit. |
- | 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: | + | < |
+ | ;;; license | ||
- | <code bash> | + | (in-package : |
- | roslaunch iai_boxy_description upload_boxy.launch | + | |
+ | (def-fact-group boxy-metadata (robot | ||
+ | | ||
+ | | ||
+ | | ||
+ | (<- (robot boxy)) | ||
+ | | ||
+ | (<- (camera-frame boxy " | ||
+ | (<- (camera-frame boxy " | ||
+ | (<- (camera-minimal-height boxy 1.60)) | ||
+ | (<- (camera-maximal-height boxy 2.10)) | ||
+ | (<- (robot-pan-tilt-links boxy " | ||
+ | (<- (robot-pan-tilt-joints boxy " | ||
</ | </ | ||
- | (It starts a GUI to play with the joint angles but let's ignore that.) | + | Finally, compile |
- | Let's check if it's there using RViz: | ||
- | < | + | |
- | rosrun rviz rviz | + | ===== Loading the world ===== |
- | Add -> Robot state -> Robot description: robot description | + | |
- | Add -> TF | + | Now let's try to load our robot also into the Bullet world. |
+ | We will spawn the floor, the robot, and a couple of household objects. | ||
+ | |||
+ | For that, we | ||
+ | - load the bullet reasoning package in the REPL | ||
+ | - start a ROS node | ||
+ | - spawn the robot and the floor | ||
+ | - spawn a big box for a table and a couple of household objects to go on top | ||
+ | |||
+ | < | ||
+ | ;; step 1 | ||
+ | (asdf:load-system :cram-bullet-reasoning) | ||
+ | (in-package | ||
+ | |||
+ | ;; step 2 | ||
+ | (roslisp: | ||
+ | |||
+ | ;; step 3 | ||
+ | (let ((robot-urdf (cl-urdf: | ||
+ | (prolog | ||
+ | `(and | ||
+ | (clear-bullet-world) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | : | ||
+ | : | ||
+ | | ||
+ | |||
+ | ;; step 4 | ||
+ | (prolog | ||
+ | | ||
+ | | ||
+ | | ||
+ | :size (0.7 1.5 1) :mass 10.0)) | ||
+ | | ||
+ | :mesh :pot)) | ||
+ | | ||
+ | :mesh :mug)) | ||
+ | | ||
+ | :mesh :mug)))) | ||
</ | </ | ||
- | To be able to see the TF frames choose '' | + | {{ : |
- | {{ : | ||
- | ===== Boxy Prolog description | + | ===== Reasoning with Boxy ===== |
- | Now that we have a URDF on the ROS parameter server, let' | + | Let' |
- | We create a file '' | + | <code lisp> |
+ | BTR> (prolog | ||
+ | NIL | ||
+ | </code> | ||
- | 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. | + | The query asks if the object '' |
- | {{ :tutorials: | + | The answer is " |
+ | Now let's put the object higher and try again: | ||
- | < | + | < |
- | ;;; license | + | BTR> (prolog '(and |
+ | | ||
+ | | ||
+ | BTR> (prolog ' | ||
+ | (((?WORLD . #< | ||
+ | (?ROBOT . CRAM-BOXY-KNOWLEDGE:: | ||
+ | . # | ||
+ | </ | ||
- | (in-package : | + | 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: | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | {{ : | ||
+ | |||
+ |