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:pepper_shopping [2020/08/19 09:42] derricktutorials:intermediate:pepper_shopping [2022/02/08 14:11] (current) – [Creating an ASDF system for the cram_pepper_demo] sarthou
Line 1: Line 1:
-====== Pepper robot shopping assistant (tutorial in construction) ======+====== Pepper Robot Shopping Assistant ======
  
 ===== Setting Up The Workspace ===== ===== Setting Up The Workspace =====
  
 This process assumes you have already installed CRAM on your laptop. If not, please visit the installation section.  This process assumes you have already installed CRAM on your laptop. If not, please visit the installation section. 
-If you are using the image version of CRAM, please follow the next section.+If you are using the image version of CRAM, please follow the next section. Please note that Ubuntu 16.04 was used for this project.
  
 ==== VM Set Up ==== ==== VM Set Up ====
Line 11: Line 11:
  
 <code> <code>
-$ sudo apt update && sudo apt upgrade  +$ sudo apt-get update && sudo apt-get upgrade 
 </code> </code>
  
Line 17: Line 17:
  
 <code> <code>
-$ cd ~/workspace/ros/ +$ sudo apt-get install ros-kinetic-joint-state-publisher-gui
-$ sudo apt install ros-kinetic-joint-state-publisher-gui+
 $ sudo apt-get install ros-kinetic-pepper-meshes    $ sudo apt-get install ros-kinetic-pepper-meshes   
 </code> </code>
Line 28: Line 27:
 <code> <code>
 $ sudo apt-get install ros-kinetic-ros-control ros-kinetic-ros-controllers $ sudo apt-get install ros-kinetic-ros-control ros-kinetic-ros-controllers
-$ sudo apt install ros-melodic-roslisp-common  +$ sudo apt-get install ros-kinetic-roslisp-common  
 </code> </code>
  
-At this point, we need an older version of CRAM. We a specific branch of the CRAM architecture. Therefore, if you have some work done in the current version of CRAM, please make copy and place it in a different directory for safekeeping or commit your current branch.+At this point, we need an older version of CRAM. We need a specific branch of the CRAM architecture. Therefore, if you have some work done in the current version of CRAM, please create backup or commit your current branch before you proceed.
  
 Run the following in your terminal. Run the following in your terminal.
Line 37: Line 36:
 <code> <code>
 $ cd ~/workspace/ros/src/cram $ cd ~/workspace/ros/src/cram
 +$ git pull
 $ git checkout 3f5b268504cb5226709daa7a5d52364c2b05a93d $ git checkout 3f5b268504cb5226709daa7a5d52364c2b05a93d
 $ git branch  $ git branch 
Line 45: Line 45:
 ==== Native Set Up ==== ==== Native Set Up ====
  
-If you did a native installation of ROS and CRAM, you would most likely install all the necessary components. However, you have to go through the setup process for the VM to be sure everything is setup. Otherwise, skip to the part where you change the branch, then you are set to go.+If you did a native installation of ROS and CRAM, you would most likely install all the necessary components. However, you have to go through the setup process for the VM to be sure everything is setup. Otherwise, skip to the part where you update the repository and change the branch, then you are set to go.
  
 Now let's begin. Now let's begin.
Line 113: Line 113:
 Comment out the following code by putting semi-colon in front of them. It should be on line 40 - 43. Comment out the following code by putting semi-colon in front of them. It should be on line 40 - 43.
  
-<code>+<code lisp>
 ; (desig:register-location-generator ; (desig:register-location-generator
 ;  3 robot-current-pose-tf-generator ;  3 robot-current-pose-tf-generator
Line 127: Line 127:
 </code> </code>
  
-==== Uploading Models to the Parameter Server ====+===== Uploading Models to the Parameter Server =====
  
 After successfully building the package, we need to add the models we will be uploading to the ROS parameter server. Change directory to the pepper_description package, and let's create three folders, namely //launch//, //meshes//, and //urdf//. After successfully building the package, we need to add the models we will be uploading to the ROS parameter server. Change directory to the pepper_description package, and let's create three folders, namely //launch//, //meshes//, and //urdf//.
Line 220: Line 220:
 {{ :tutorials:intermediate:finalscene.png?nolink&800 |}} {{ :tutorials:intermediate:finalscene.png?nolink&800 |}}
  
-==== CRAM_Pepper Description ====+===== CRAM_Pepper Description =====
  
 We want to visualize our robot and shelves in the CRAM bullet world, but first, we need to map the various parts of the URDF to their functionality. CRAM needs to know which part of the robot is meant to do what. We want to visualize our robot and shelves in the CRAM bullet world, but first, we need to map the various parts of the URDF to their functionality. CRAM needs to know which part of the robot is meant to do what.
Line 252: Line 252:
 Since we have already done an example, let’s go ahead and replace everything in the package.xml with the following: Since we have already done an example, let’s go ahead and replace everything in the package.xml with the following:
  
-<code>+<code XML>
 <package format="2"> <package format="2">
   <name>cram_pepper_description</name>   <name>cram_pepper_description</name>
Line 275: Line 275:
 Next, let us replace everything in the //CmakeLists.txt// with the following: Next, let us replace everything in the //CmakeLists.txt// with the following:
  
-<code>+<code lisp>
 cmake_minimum_required(VERSION 2.8.3) cmake_minimum_required(VERSION 2.8.3)
 project(cram_pepper_description) project(cram_pepper_description)
Line 290: Line 290:
 By now, you should have done the beginner tutorial, which explains all about .asd files. Therefore let's create one for our cram_pepper_description. Create a file //cram-pepper-description.asd// and put the following code in it. By now, you should have done the beginner tutorial, which explains all about .asd files. Therefore let's create one for our cram_pepper_description. Create a file //cram-pepper-description.asd// and put the following code in it.
  
-<code>+<code lisp>
 (defsystem cram-pepper-description (defsystem cram-pepper-description
   :depends-on (cram-prolog   :depends-on (cram-prolog
Line 316: Line 316:
 Let’s define our package in the "//package.lisp//" file with the following code. Let’s define our package in the "//package.lisp//" file with the following code.
  
-<code>+<code lisp>
 (in-package :cl-user) (in-package :cl-user)
  
Line 331: Line 331:
 In the “//neck.lisp//” file, copy the following code, and paste it in there. In the “//neck.lisp//” file, copy the following code, and paste it in there.
  
-<code>+<code lisp>
 (in-package :pepper-descr) (in-package :pepper-descr)
  
Line 379: Line 379:
 Next, we need to do the same for the arms of the robot. Again, copy the following code and paste it in the "//arms.lisp//" file. Next, we need to do the same for the arms of the robot. Again, copy the following code and paste it in the "//arms.lisp//" file.
  
-<code>+<code lisp>
 (in-package :pepper-descr) (in-package :pepper-descr)
  
Line 494: Line 494:
 Finally, we need to provide a general knowledge of the robot. We do this in the "//general-knowledge.lisp//" file. Once again, copy the following code and paste it in the file. Finally, we need to provide a general knowledge of the robot. We do this in the "//general-knowledge.lisp//" file. Once again, copy the following code and paste it in the file.
  
-<code>+<code lisp>
 (in-package :pepper-descr) (in-package :pepper-descr)
  
Line 550: Line 550:
 Now let’s see if we can load our cram package in Emacs.  Now let’s see if we can load our cram package in Emacs. 
  
-First, run the following.+First, run the following in your terminal.
  
 <code> <code>
Line 581: Line 581:
 To be able to visualize our robot and shelves, let's set up our demo folder. To be able to visualize our robot and shelves, let's set up our demo folder.
  
-==== CRAM Pepper Demo ====+===== CRAM Pepper Demo =====
  
 Just like the //cram_pepper_description//, let’s create a new package in //cram_pepper// called //cram_pepper_demo// Just like the //cram_pepper_description//, let’s create a new package in //cram_pepper// called //cram_pepper_demo//
Line 607: Line 607:
 As explained before, open the //package.xml// file in any text editor and replace everything with the following code. As explained before, open the //package.xml// file in any text editor and replace everything with the following code.
  
-<code>+<code XML>
 <package format="2"> <package format="2">
   <name>cram_pepper_demo</name>   <name>cram_pepper_demo</name>
Line 668: Line 668:
 Next, replace open the //CmakeLists.txt// in any text editor and replace everything with the following code.  Next, replace open the //CmakeLists.txt// in any text editor and replace everything with the following code. 
  
-<code>+<code lisp>
 cmake_minimum_required(VERSION 2.8.3) cmake_minimum_required(VERSION 2.8.3)
 project(cram_pepper_demo) project(cram_pepper_demo)
Line 762: Line 762:
 </code> </code>
  
-Next, download the following resource folder from here (Github link) and put the entire folder in the cram_pepper_demo package folder. The folder contains our products for the shop.+Next, download the resource folder from [[https://github.com/danricky/cram-pepper/tree/master/cram_pepper_demo/resource|here]] and put the entire folder in the cram_pepper_demo package folder. The folder contains our products for the shop.
  
 Compile the project, make sure to have the "roslaunch" running at the background, and open Emacs. Compile the project, make sure to have the "roslaunch" running at the background, and open Emacs.
Line 907: Line 907:
  
   )   )
-<code>+</code>
  
 This function creates the bullet-world, extracts the necessary information about the robot and the shelves from the ros-parameter server, spawns a static floor (plane), generates the shelves, and spawns the robot. This function creates the bullet-world, extracts the necessary information about the robot and the shelves from the ros-parameter server, spawns a static floor (plane), generates the shelves, and spawns the robot.
Line 1071: Line 1071:
 So far, so good. So far, so good.
  
-==== Pack arms ====+===== Pack Arms =====
  
 At this point, we don’t want our robot arm looking a zombie. So let’s naturally park the arms. At this point, we don’t want our robot arm looking a zombie. So let’s naturally park the arms.
Line 1101: Line 1101:
 {{ :tutorials:intermediate:parkarm.png?nolink&600 |}} {{ :tutorials:intermediate:parkarm.png?nolink&600 |}}
  
-==== Import human ====+===== Import Human =====
  
 Now let’s bring in the human avatar. Let’s create a function for that as well. Append the following code to the “cram-plans.lisp” file. Now let’s bring in the human avatar. Let’s create a function for that as well. Append the following code to the “cram-plans.lisp” file.
Line 1131: Line 1131:
 Now that we have our human in the scene, we need to reposition the robot to face the human. It may be perceived as rude for the robot to turn the back to the human.  Now that we have our human in the scene, we need to reposition the robot to face the human. It may be perceived as rude for the robot to turn the back to the human. 
  
-==== Reposition Robot ====+===== Reposition Robot =====
  
 To reposition the robot, let's add the following function to the "cram-plans.lisp" file. To reposition the robot, let's add the following function to the "cram-plans.lisp" file.
Line 1823: Line 1823:
  
  ((cram-common-failures:ptu-goal-not-reached (e)  ((cram-common-failures:ptu-goal-not-reached (e)
-        ; (print e) 
  
         (roslisp:ros-warn (perception-failure) "~a~%Looking at product went wrong...repositioning" e)         (roslisp:ros-warn (perception-failure) "~a~%Looking at product went wrong...repositioning" e)
Line 1870: Line 1869:
  ?location-pose  ?location-pose
  (cram-tf:robot-current-pose)))  (cram-tf:robot-current-pose)))
 +</code>
  
 This function also contains another helper function. Let’s add it. This function also contains another helper function. Let’s add it.
 +
 +<code lisp>
 ;;"Given a `look-pose-stamped' and a `robot-pose-stamped' (both in fixed frame), ;;"Given a `look-pose-stamped' and a `robot-pose-stamped' (both in fixed frame),
 ;; calculate the new robot-pose-stamped, which is rotated with an angle to point towards ;; calculate the new robot-pose-stamped, which is rotated with an angle to point towards
Line 2005: Line 2007:
 If we try running the "interaction" function after compiling, we will realize that the human avatar will not reset back to its original position. See the image below. If we try running the "interaction" function after compiling, we will realize that the human avatar will not reset back to its original position. See the image below.
  
-image+{{ :tutorials:intermediate:stuckhuman.png?nolink&600 |}}
  
 So we need a function to reset the human back to its original position. Update the "cram-plans.lisp" file with the code below. So we need a function to reset the human back to its original position. Update the "cram-plans.lisp" file with the code below.
Line 2030: Line 2032:
  
 Congratulations!!! You just created a shopping assistant using the Pepper robot.  Congratulations!!! You just created a shopping assistant using the Pepper robot. 
 +
 +You can access the entire project from [[https://github.com/danricky/cram-pepper|here]]