Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:advanced:new-robot [2018/12/09 19:42] – [Spawn the robot in Bullet] vanessa | tutorials:advanced:new-robot [2019/03/05 12:08] (current) – [Action designators and plans] gkazhoya | ||
---|---|---|---|
Line 188: | Line 188: | ||
===== Action designators and plans ===== | ===== Action designators and plans ===== | ||
- | This is TODO... | + | Everything above motion designators should be independent of the robot platform. |
+ | For example, try performing a picking up action with your robot. | ||
+ | See [[http:// | ||
===== Projection for your new robot ===== | ===== Projection for your new robot ===== | ||
Line 199: | Line 200: | ||
Then simply execute in your terminal: < | Then simply execute in your terminal: < | ||
- | The HSR does not have so many links and joins as the PR2 so our life is much easier on that point. | + | The HSR does not have so many links and joins as the PR2 so our life is much easier on that point. |
+ | |||
+ | Which files are later needed in the // | ||
+ | * **cram_hsrb_description** | ||
+ | * arms.lisp | ||
+ | * general-knowledge.lisp | ||
+ | * package.lisp | ||
+ | * **cram_hsrb_projection** | ||
+ | * action-designators.lisp | ||
+ | * ik.lisp | ||
+ | * low-level.lisp | ||
+ | * package.lisp | ||
+ | * process-modules.lisp | ||
+ | * projection-environment.lisp | ||
+ | * resources.lisp ?TODO: do we really | ||
+ | * setup-urdf.lisp ;;at least for the hsrb we come to that point later in the tutorial | ||
+ | * tf.lisp | ||
+ | * **hsrb_arm_kinematics** ;;python code TODO: should we explain? | ||
+ | |||
+ | For reference and starting point take a look at those package for the pr2 or hsrb. | ||
Line 206: | Line 227: | ||
==== Spawn the robot in Bullet ==== | ==== Spawn the robot in Bullet ==== | ||
- | Use the Prolog assertion predicates. See example of how PR2 is spawned from a URDF in the bullet tutorial: http:// | + | Use the Prolog assertion predicates. See example of how PR2 is spawned from a URDF in the bullet tutorial: http:// |
Line 240: | Line 261: | ||
(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: | ||
(assert (btr: | (assert (btr: | ||
(assert (btr: | (assert (btr: | ||
Line 252: | Line 272: | ||
{{: | {{: | ||
- | + | The '' | |
- | At this moment the command: | + | |
<code lisp> | <code lisp> | ||
(defvar *robot-base-frame* nil | (defvar *robot-base-frame* nil | ||
Line 269: | Line 288: | ||
"Tool frame of the right arm. Initialized from CRAM robot desciption." | "Tool frame of the right arm. Initialized from CRAM robot desciption." | ||
</ | </ | ||
- | Usually u will define those parameters in the ROBOT_description package. For now to simply test the beginning | + | Usually u will define those parameters in the ROBOT_description package. For now to simply test the beginning |
Try to move the robot joints using Bullet Prolog predicates or Lisp functions. E.g. | Try to move the robot joints using Bullet Prolog predicates or Lisp functions. E.g. | ||
- | < | + | < |
(btr: | (btr: | ||
- | ' | + | ' |
| | ||
</ | </ | ||
Line 282: | Line 301: | ||
If you are unsure what joints are possible to move use: | If you are unsure what joints are possible to move use: | ||
<code lisp> | <code lisp> | ||
- | (btr:object btr: | + | (btr:object btr: |
</ | </ | ||
- | to get the instance of the spawned Bullet object there is a function. | + | |
After lifting the torso the HSR should looks like this: | After lifting the torso the HSR should looks like this: | ||
{{: | {{: | ||
+ | |||
+ | |||
+ | As you can see for the HSR lifting the ' | ||
+ | How we define mimic joints will be shown later in the tutorial. | ||
Line 299: | Line 322: | ||
Similar to '' | Similar to '' | ||
- | The queries are implementations of the interfaces defined in '' | + | The queries are implementations of the interfaces defined in '' |
Define the most important links and joints there e.g. | Define the most important links and joints there e.g. | ||
Line 319: | Line 342: | ||
- | (<- (robot-tool-frame hsrb :left "gripper_tool_frame")) | + | (<- (robot-tool-frame hsrb :left "gripper_tool_joint")) |
(<- (robot-tool-frame hsrb :right " | (<- (robot-tool-frame hsrb :right " | ||
Line 333: | Line 356: | ||
- | (<- (gripper-joint hsrb :left "hand_motor_frame_joint")) | + | (<- (gripper-joint hsrb :left "hand_motor_joint")) |
(<- (gripper-link hsrb :left ?link) | (<- (gripper-link hsrb :left ?link) | ||
Line 354: | Line 377: | ||
</ | </ | ||
- | If no **gripper_tool_joint** is defined for your robot you need to add one in the URDF it self. It is important that the parent will be the wrist_palm_link and the joint is fixed. The origin you will need to change yourself it should be directly in the middle of the gripper: | + | If no **gripper_tool_joint** is defined for your robot you need to add one in the URDF it self. It is important that the parent will be the wrist_palm_link and the joint is fixed. The origin you will need to change yourself it should be directly in the middle of the gripper. However since we dont want to change the original URDF we decided that there will be a setup-urdf.lisp file for the HSR that takes care of the necessary URDF changes. |
- | < | + | < |
- | <joint name=" | + | ;;the tool-frame for the hsrb, since the urdf does not provide one |
- | < | + | (defparameter *tool-frame* |
- | < | + | "<joint name=\" |
- | <child link=" | + | |
+ | < | ||
+ | <child link=\" | ||
</ | </ | ||
- | <link name=" | + | <link name=\" |
</ | </ | ||
- | {{ : | + | {{: |
Then the moveable arm-joints/ | Then the moveable arm-joints/ | ||
+ | |||
+ | |||
Next step is to define the general-knowledge.lisp: | Next step is to define the general-knowledge.lisp: | ||
Line 378: | Line 405: | ||
| | ||
arm | arm | ||
- | | + | |
+ | | ||
(<- (robot hsrb)) | (<- (robot hsrb)) | ||
Line 384: | Line 412: | ||
(<- (robot-base-frame hsrb " | (<- (robot-base-frame hsrb " | ||
- | (<- (robot-torso-link-joint hsrb "torso_lift_joint" "torso_lift_link")) | + | (<- (robot-torso-link-joint hsrb "arm_lift_link" "arm_lift_joint")) |
- | (<- (arm hsrb :left)) | + | |
+ | ;(<- (robot-torso-link-joint | ||
- | (<- (camera-frame hsrb "/hsrb/ | + | |
+ | | ||
+ | (<- (robot-pan-tilt-links | ||
+ | (<- (robot-pan-tilt-joints hsrb " | ||
</ | </ | ||
It is important to describe the robot-base-frame here and the torso-link/ | It is important to describe the robot-base-frame here and the torso-link/ | ||
+ | In the description package you can also see that we declared the ' | ||
==== Create a CRAM YOUR_ROBOT_NAME projection package ==== | ==== Create a CRAM YOUR_ROBOT_NAME projection package ==== | ||
- | Similar to '' | + | Similar to '' |
+ | <code lisp> | ||
+ | ;;in low-level.lisp | ||
+ | ;;;;;;;;;;;;;;;;; | ||
+ | (defun move-torso (joint-angle) | ||
+ | (declare (type number joint-angle)) | ||
+ | (let* ((bindings | ||
+ | (car | ||
+ | (prolog: | ||
+ | `(and (cram-robot-interfaces: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | (if (< joint-angle lower-limit) | ||
+ | | ||
+ | (if (> joint-angle upper-limit) | ||
+ | | ||
+ | | ||
+ | (prolog: | ||
+ | | ||
+ | | ||
+ | (prolog: | ||
+ | | ||
+ | | ||
+ | (unless (< (abs (- joint-angle cropped-joint-angle)) 0.0001) | ||
+ | (cpl:fail ' | ||
+ | : | ||
+ | :torso joint-angle))) | ||
+ | ;; (cram-occasions-events: | ||
+ | ;; (make-instance ' | ||
+ | ) | ||
+ | </ | ||
+ | **setup-urdf.lisp** | ||
+ | In the setup-urdf.lisp we make sure that the original urdf from the hsrb is working with our bullet world. This function needs to be called in the setup.lisp before spawning the robot. | ||
+ | <code lisp> | ||
+ | (in-package :hsrb-proj) | ||
+ | (defparameter *robot-parameter* " | ||
+ | ;;the collision-box for base_footprint, | ||
+ | (defparameter *collision-box* | ||
+ | "> | ||
+ | < | ||
+ | <origin rpy=\" | ||
+ | < | ||
+ | <box size=\" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ;;the tool-frame for the hsrb, since the urdf does not provide one | ||
+ | (defparameter *tool-frame* | ||
+ | "< | ||
+ | < | ||
+ | < | ||
+ | <child link=\" | ||
+ | </ | ||
+ | <link name=\" | ||
+ | |||
+ | |||
+ | ;;call this function in your demo seutp.lisp it also takes care of the parameter in rob-int e.g | ||
+ | ;; (defun setup-bullet-world () | ||
+ | ;; (setf btr: | ||
+ | ;; (let* ((robot (hsrb-proj:: | ||
+ | ;; (kitchen (or *kitchen-urdf* ..... | ||
+ | |||
+ | (defun get-urdf () | ||
+ | (let* ((robi (substitute #\SPACE #\` | ||
+ | | ||
+ | | ||
+ | (cl-urdf: | ||
+ | | ||
+ | ;;plus 15 because of base_footprint" | ||
+ | (subseq robi 0 (+ 15 (search " | ||
+ | *collision-box* | ||
+ | ;;plus 17 because of base_footprint"/> | ||
+ | (subseq robi (+ 17 (search " | ||
+ | (search "< | ||
+ | *tool-frame* | ||
+ | (subseq robi (search "< | ||
+ | robot)) | ||
+ | </ |