|
5 | 5 | (if (ros::resolve-ros-path "package://hironx_ros_bridge")
|
6 | 6 | (ros::load-ros-manifest "hironx_ros_bridge"))
|
7 | 7 |
|
8 |
| -(defconstant +hironx-hand-servo-num+ 4) |
9 |
| - |
10 | 8 | (defclass hironxjsk-interface
|
11 | 9 | :super rtm-ros-robot-interface
|
12 |
| - :slots ()) |
| 10 | + :slots (hand-servo-num)) |
13 | 11 |
|
14 | 12 | ;; Initialize
|
15 | 13 | (defmethod hironxjsk-interface
|
|
31 | 29 | (format nil "~A/models/~A-force-moment-offset.l"
|
32 | 30 | (ros::resolve-ros-path "package://hrpsys_ros_bridge_tutorials")
|
33 | 31 | (send robot :name))
|
34 |
| - :set-offset t)))) |
| 32 | + :set-offset t)) |
| 33 | + ;; number of servo motors in one hand |
| 34 | + (setq hand-servo-num 4))) |
35 | 35 | (:define-all-ROSBridge-srv-methods
|
36 | 36 | (&key (debug-view nil) (ros-pkg-name "hrpsys_ros_bridge"))
|
37 | 37 | ;; First, define ROSBridge method for old impedance controller
|
|
254 | 254 | ;; Based on https://github.com/start-jsk/rtmros_hironx/blob/2.1.0/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py
|
255 | 255 | ;; and https://github.com/start-jsk/rtmros_tutorials/blob/0.1.6/hrpsys_ros_bridge_tutorials/euslisp/hrp2-common-interface.l
|
256 | 256 | (defmethod hironxjsk-interface
|
| 257 | + (:check-hand-vector-length (vec &optional (hand-num 1)) |
| 258 | + (let ((len (* hand-num hand-servo-num))) |
| 259 | + (assert (= (length vec) len) |
| 260 | + "[ERROR] Expecting vector of length ~a~%" len))) |
257 | 261 | (:hand-angle-vector (hand &optional av (tm 1000))
|
258 | 262 | ;; check type
|
259 | 263 | (when av
|
260 | 264 | (case hand
|
261 | 265 | (:hands
|
262 |
| - (if (= (length av) +hironx-hand-servo-num+) (setq av (concatenate float-vector av av))) |
263 |
| - (assert (= (length av) (* 2 +hironx-hand-servo-num+)))) |
| 266 | + (if (= (length av) hand-servo-num) (setq av (concatenate float-vector av av))) |
| 267 | + (send self :check-hand-vector-length av 2)) |
264 | 268 | ((:rhand :lhand)
|
265 |
| - (assert (= (length av) +hironx-hand-servo-num+))))) |
| 269 | + (send self :check-hand-vector-length av)))) |
266 | 270 |
|
267 | 271 | ;; simulation mode
|
268 | 272 | (when (send self :simulation-modep)
|
|
342 | 346 | ;; check length
|
343 | 347 | (case hand
|
344 | 348 | (:hands
|
345 |
| - (if (= (length effort) +hironx-hand-servo-num+) |
| 349 | + (if (= (length effort) hand-servo-num) |
346 | 350 | (setq effort (concatenate float-vector effort effort)))
|
347 |
| - (assert (= (length effort) (* 2 +hironx-hand-servo-num+)))) |
| 351 | + (send self :check-hand-vector-length effort 2)) |
348 | 352 | ((:rhand :lhand)
|
349 |
| - (assert (= (length effort) +hironx-hand-servo-num+)))) |
| 353 | + (send self :check-hand-vector-length effort))) |
350 | 354 | ;; setmaxtorque with different effort values
|
351 | 355 | (map cons
|
352 | 356 | #'(lambda (id val)
|
|
363 | 367 | (let ((a (rad2deg %(pi/2 - acos((width / 2.0 + safetymargin - w0) / l1)))))
|
364 | 368 | (float-vector a (- a) (- a) a))))
|
365 | 369 | (:hand-angles2width (vec)
|
366 |
| - (assert (= (length vec) +hironx-hand-servo-num+) |
367 |
| - (format nil "Expecting vector of length ~a~%" +hironx-hand-servo-num+)) |
| 370 | + (send self :check-hand-vector-length vec) |
368 | 371 | (let ((safetymargin 3) (w0 19) (l1 41.9) (l2 20))
|
369 | 372 | (flet ((get-width (r1 r2) %( w0 + l1 * cos(pi/2 - r1) + l2 * cos(pi/2 - r1 - r2) - safetymargin)))
|
370 | 373 | (multiple-value-bind (a1 a2 b1 b2) (map cons #'deg2rad vec)
|
|
0 commit comments