Skip to content

[Fetch] add servo-off method to fetch-interface.l #1405

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 15 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jsk_fetch_robot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ roslaunch jsk_fetch_gazebo_demo demo.launch
(send *fetch* :rarm :shoulder-y :joint-angle 75)
```

- Servo on and off. Able to choose servo on and off part respectively.

```lisp
(send *ri* :servo-off) ;; arm, gripper and head servos off
(send *ri* :servo-off :arm t :gripper nil :head nil) ;; arm servo off
(send *ri* :servo-on) ;; arm, gripper and head servos on
(send *ri* :servo-on :arm t :gripper nil :head nil :time 80) ;; arm servo on in 80[msec]
```

### Gripper Control

- Grasp object
Expand Down
87 changes: 85 additions & 2 deletions jsk_fetch_robot/fetcheus/fetch-interface.l
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

(ros::load-ros-package "fetcheus")
(ros::load-ros-package "fetch_driver_msgs")
(ros::load-ros-package "robot_controllers_msgs")

(defclass fetch-interface
:super robot-move-base-interface
:slots (gripper-action moveit-robot)
:slots (gripper-action moveit-robot fetch-controller-action)
)

(defmethod fetch-interface
Expand All @@ -32,6 +33,10 @@
(send self :delete-ground-collision-object)
(send self :add-keepout-collision-object)
(send self :add-ground-collision-object))
(setq fetch-controller-action
(instance ros::simple-action-client :init
"/query_controller_states"
robot_controllers_msgs::QueryControllerStatesAction))
))
(:state (&rest args)
"We do not have :wait-until-update option for :state :worldcoords.
Expand Down Expand Up @@ -265,7 +270,85 @@ Example: (send self :gripper :position) => 0.00"
:touch-links nil)))
(:delete-ground-collision-object ()
(send *co* :delete-attached-object-by-id "ground")
(send *co* :delete-object-by-id "ground")))
(send *co* :delete-object-by-id "ground"))
(:servo-off (&key (arm t) (gripper t) (head t))
"
Turn servo off for arm/gripper/head motors
Args:
- key
- arm: If you do not want to servo off the arm, set nil (default: t)
- gripper: If you do not want to servo off the grippper, set nil (default: t)
- head: If you do not want to servo off the head, set nil (default: t)
Examples:
(send self :servo-off) ;; arm, gripper and head servos off
(send self :servo-off :arm t :gripper nil :head nil) ;; arm servo off
"
(let ((goal-servo-off (instance robot_controllers_msgs::QueryControllerStatesGoal :init))
(goal-gripper-servo-off (instance control_msgs::GripperCommandGoal :init))
(state nil) (update-list nil)
(gravity-comp (list "arm_controller/gravity_compensation"))
(arm-controller (list "arm_controller/follow_joint_trajectory"
"arm_with_torso_controller/follow_joint_trajectory"
"torso_controller/follow_joint_trajectory"))
(head-controller (list "head_controller/follow_joint_trajectory"
"head_controller/point_head")))
(when (or arm head)
(setq update-list (send goal-servo-off :updates))
(when arm
(ros::ros-info "arm servo off")
;; start gravity compensation
(dolist (controller gravity-comp)
(setq state (instance robot_controllers_msgs::ControllerState :init))
(send state :name controller)
(send state :state 1) ;; running
(push state update-list))
;; stop arm controllers
(dolist (controller arm-controller)
(setq state (instance robot_controllers_msgs::ControllerState :init))
(send state :name controller)
(send state :state 0) ;; stopping
(push state update-list)))
(when head
;; stop head controllers
(ros::ros-info "head servo off")
(dolist (controller head-controller)
(setq state (instance robot_controllers_msgs::ControllerState :init))
(send state :name controller)
(send state :state 0) ;; stopping
(push state update-list)))
(send goal-servo-off :updates update-list)
(send fetch-controller-action :send-goal goal-servo-off))
(when gripper
;; disable gripper torque
(ros::ros-info "gripper servo off")
(send (send goal-gripper-servo-off :command) :max_effort -1.0)
(send gripper-action :send-goal goal-gripper-servo-off))))
(:servo-on (&key (arm t) (gripper t) (head t) (time 200))
"
Turn servo on for arm/gripper/head motors
Args:
- key:
- arm: If you do not want to servo on the arm, set nil (default: t)
- gripper: If you do not want to servo on the grippper, set nil (default: t)
- head: If you do not want to servo on the head, set nil (default: t)
- time: [msec] duration to turn servo on,
experimentally the minimal duration is about 60[msec] (default: 200)
Examples:
(send self :servo-on) ;; arm, gripper and head servos on
(send self :servo-on :arm nil :gripper nil :head t :time 80) ;; head servo on in 80[msec]
"
;; the reason why :servo-off and :servo-on has different implementation is in the following issue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkmtnt7000 thank you, the last comment, please add method documentation like https://github.com/jsk-ros-pkg/jsk_pr2eus/blob/ca2d919fe87f61605c10c966af32dcdf8c4f5147/pr2eus/robot-interface.l#L378-L391

(:servo-off (&key (arm t) (gripper t) (head t))
"
Turn servo off for arm/gripper/head motors
- arm : If you do not want to servo off the arm, set nil (default: t)
- gripper : If you do not want to servo off the grippper, set nil (default: t)
- head : If you do not want to servo off the head, set nil (default: t)
"
 (:servo-on (&key (arm t) (gripper t) (head t) (time 500))
   "Turm upperbody servo on 
- arm : If ...
- gripper : ...
- head : ...
- time : [msec] duration to turn servo on, experimentally the minimal duration is about 60[msec]
    ;; the reason why :servo-off and :servo-on has different implementation is in the following issue

You can find better English explanation of each keyward...
If there is no reason for 500[msec], please set 200 or 300 as default. As you get used to robot experiments, you'll tend to set a lot of sleep and more duration time.
c.f. https://youtu.be/8o0eU_O3_OY?t=982, https://www.mis.mpg.de/fileadmin/pdf/slides_al_2616.pdf (p.81), https://hlr2016.sciencesconf.org/data/hlr_2016_ta.pdf (p.39), https://www.codyco.eu/images/pdf/2013_Humanoids/Asfour.pdf (p.17)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for advice.
I understand speed is important.
I add the explanation of each keyword and the usage examples of these methods.

;; https://github.com/fetchrobotics/robot_controllers/issues/72
(when arm
(ros::ros-info "arm servo on")
(send self :angle-vector (send self :state :potentio-vector) time :arm-controller)
(send self :angle-vector (send self :state :potentio-vector) time :torso-controller))
(when head
(ros::ros-info "head servo on")
(send self :angle-vector (send self :state :potentio-vector) time :head-controller))
(when gripper
(ros::ros-info "gripper servo on")
(send self :go-grasp :pos (send self :gripper :position)))))

;; interface for simple base actions
(defmethod fetch-interface
Expand Down