forked from start-jsk/rtmros_tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
do not use https://github.com/start-jsk/rtmros_common/pull/1095 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,30 +3,6 @@ | |
| (when (probe-file (ros::resolve-ros-path "package://hrpsys_ros_bridge_tutorials/euslisp/hironxjsk-utils.l")) | ||
| (require :hironxjsk-utils "package://hrpsys_ros_bridge_tutorials/euslisp/hironxjsk-utils.l")) | ||
|
|
||
| ;; Waiting for https://github.com/start-jsk/rtmros_common/pull/1095 to be released | ||
| (defmethod rtm-ros-robot-interface | ||
| (:def-limb-controller-method | ||
| (limb &key (debugp nil)) | ||
| "Method to add limb controller action by default setting. | ||
| Currently, FollowJointTrajectoryAction is used. | ||
| This method calls defmethod. If :debugp t, we can see defmethod s-expressions." | ||
| (let ((sexp `(defmethod ,(send (class self):name) | ||
| (,(read-from-string (format nil "~A-controller" limb)) | ||
| () | ||
| (list | ||
| (list | ||
| (cons :group-name ,(string-downcase limb)) | ||
| (cons :controller-action ,(format nil "~A_controller/follow_joint_trajectory_action" (string-downcase limb))) | ||
| (cons :controller-state ,(format nil "~A_controller/state" (string-downcase limb))) | ||
| (cons :action-type control_msgs::FollowJointTrajectoryAction) | ||
| (cons :joint-names (send-all (send robot ,limb :joint-list) :name))) | ||
| ))))) | ||
| (if debugp | ||
| (pprint (macroexpand sexp))) | ||
| (eval sexp) | ||
| )) | ||
| ) | ||
|
|
||
| (defclass hironxjsk-interface | ||
| :super rtm-ros-robot-interface | ||
| :slots (hand-actions | ||
|
|
@@ -35,58 +11,49 @@ | |
|
|
||
| ;; Initialize | ||
| (defmethod hironxjsk-interface | ||
| ;; Based on https://github.com/start-jsk/rtmros_tutorials/blob/9132c58702b3b193e14271b4c231ad0080187850/hrpsys_ros_bridge_tutorials/euslisp/hrp2jsknts-interface.l | ||
| (:init (&rest args &key (show-default-controller nil) &allow-other-keys) | ||
| (let ((limbs '(:rarm :larm :head :torso))) | ||
| (dolist (limb limbs) | ||
| (send self :def-limb-controller-method limb)) | ||
| ;; If gazebo with ros_control, overwrite :default-controller | ||
| (ros::roseus "default_robot_interface") | ||
| (when (setq on-gazebo-ros-control | ||
| (and (ros::get-param "/gazebo/time_step" nil) | ||
| (ros::service-exists "/controller_manager/load_controller"))) | ||
| (let ((sexp `(defmethod ,(send (class self):name) | ||
| (:default-controller () | ||
| (append | ||
| ,@(mapcar | ||
| #'(lambda (limb) | ||
| `(send self ,(read-from-string | ||
| (format nil "~A-controller" limb)))) | ||
| limbs)))))) | ||
| (when show-default-controller | ||
| (pprint (macroexpand sexp))) | ||
| (eval sexp))) | ||
| (prog1 | ||
| ;; Hironx has two types of joint_states on one topic: whole body and hand, | ||
| ;; so queue size of joint_states should be two. | ||
| ;; https://github.com/jsk-ros-pkg/jsk_pr2eus/blob/0.3.13/pr2eus/robot-interface.l#L120 | ||
| (send-super* :init :joint-states-queue-size 2 :robot hironxjsk-robot args) | ||
| ;; add controller | ||
| (dolist (limb limbs) | ||
| (let ((ctype (read-from-string (format nil "~A-controller" limb)))) | ||
| ;; Avoid overwriting existing controllers to let actionlib-comm-state work | ||
| ;; Without this avoidance, "old client's goal" warning is showed after :angle-vector | ||
| (unless (send self :add-controller ctype :create-actions nil) | ||
| (send self :add-controller ctype | ||
| :joint-enable-check t :create-actions t)))) | ||
| ;; add hand controller for gazebo with ros_control | ||
| (when on-gazebo-ros-control | ||
| (setq hand-actions (make-hash-table)) | ||
| (dolist (hand (list :rhand :lhand)) | ||
| ;; initialize hand action | ||
| (sethash hand hand-actions | ||
| (instance ros::simple-action-client :init | ||
| (format nil "/~A_controller/follow_joint_trajectory_action" | ||
| (:init (&rest args) | ||
| (setq robot (instance hironxjsk-robot :init)) | ||
| ;; Define {limb}-controller, usually we can define manually as jsk_robots | ||
| (dolist (limb '(:rarm :larm :head :torso)) | ||
| (send self :def-limb-controller-method limb)) | ||
| ;; If gazebo with ros_control, overwrite :default-controller | ||
| (setq on-gazebo-ros-control | ||
| (and (ros::get-param "/gazebo/time_step" nil) | ||
| ;; rtm-ros-bridge does not have type parametrs | ||
| (ros::get-param "/torso_controller/type" nil))) | ||
| (when on-gazebo-ros-control | ||
| (ros::ros-warn "Found Gazebo/ros_control environment")) | ||
| (prog1 | ||
| ;; Hironx has two types of joint_states on one topic: whole body and hand, | ||
| ;; so queue size of joint_states should be two. | ||
| ;; https://github.com/jsk-ros-pkg/jsk_pr2eus/blob/0.3.13/pr2eus/robot-interface.l#L120 | ||
| (send-super* :init :joint-states-queue-size 2 :robot robot :type | ||
| (if on-gazebo-ros-control :gazebo-ros-controller :default-controller) | ||
|
||
| args) | ||
| ;; add hand controller for gazebo with ros_control | ||
| (when on-gazebo-ros-control | ||
| (setq hand-actions (make-hash-table)) | ||
| (dolist (hand (list :rhand :lhand)) | ||
| ;; initialize hand action | ||
| (sethash hand hand-actions | ||
| (instance ros::simple-action-client :init | ||
| (format nil "/~A_controller/follow_joint_trajectory_action" | ||
| (string-downcase hand)) | ||
| control_msgs::FollowJointTrajectoryAction | ||
| :groupname groupname)) | ||
| ;; check if hand action is respond (based on baxter-interface) | ||
| (unless | ||
| control_msgs::FollowJointTrajectoryAction | ||
| :groupname groupname)) | ||
| ;; check if hand action is respond (based on baxter-interface) | ||
| (unless | ||
| (and joint-action-enable (send (gethash hand hand-actions) :wait-for-server 3)) | ||
| (ros::ros-warn "~A is not respond" (gethash hand hand-actions)) | ||
| (ros::ros-info "*** if you do not have hand, you can ignore this message ***")))) | ||
| ;; number of servo motors in one hand | ||
| (setq hand-servo-num 4)))) | ||
| (ros::ros-warn "~A is not respond" (gethash hand hand-actions)) | ||
| (ros::ros-info "*** if you do not have hand, you can ignore this message ***")))) | ||
| ;; number of servo motors in one hand | ||
| (setq hand-servo-num 4))) | ||
| (:gazebo-ros-controller () | ||
| (append | ||
| (send self :rarm-controller) | ||
| (send self :larm-controller) | ||
| (send self :head-controller) | ||
| (send self :torso-controller))) | ||
| (:call-operation-return (method &rest args) | ||
| ;; Call method until it returns true | ||
| ;; Used to ensure operation on the hand service calls, that sometimes fail | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.