Skip to content

Commit 59d365d

Browse files
Affonso-Guipazeshun
authored andcommitted
Add printing information to typecheck
1 parent d66f87f commit 59d365d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

hrpsys_ros_bridge_tutorials/euslisp/hironxjsk-interface.l

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
(if (ros::resolve-ros-path "package://hironx_ros_bridge")
66
(ros::load-ros-manifest "hironx_ros_bridge"))
77

8-
(defconstant +hironx-hand-servo-num+ 4)
9-
108
(defclass hironxjsk-interface
119
:super rtm-ros-robot-interface
12-
:slots ())
10+
:slots (hand-servo-num))
1311

1412
;; Initialize
1513
(defmethod hironxjsk-interface
@@ -31,7 +29,9 @@
3129
(format nil "~A/models/~A-force-moment-offset.l"
3230
(ros::resolve-ros-path "package://hrpsys_ros_bridge_tutorials")
3331
(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)))
3535
(:define-all-ROSBridge-srv-methods
3636
(&key (debug-view nil) (ros-pkg-name "hrpsys_ros_bridge"))
3737
;; First, define ROSBridge method for old impedance controller
@@ -254,15 +254,19 @@
254254
;; Based on https://github.com/start-jsk/rtmros_hironx/blob/2.1.0/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py
255255
;; and https://github.com/start-jsk/rtmros_tutorials/blob/0.1.6/hrpsys_ros_bridge_tutorials/euslisp/hrp2-common-interface.l
256256
(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)))
257261
(:hand-angle-vector (hand &optional av (tm 1000))
258262
;; check type
259263
(when av
260264
(case hand
261265
(: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))
264268
((:rhand :lhand)
265-
(assert (= (length av) +hironx-hand-servo-num+)))))
269+
(send self :check-hand-vector-length av))))
266270

267271
;; simulation mode
268272
(when (send self :simulation-modep)
@@ -342,11 +346,11 @@
342346
;; check length
343347
(case hand
344348
(:hands
345-
(if (= (length effort) +hironx-hand-servo-num+)
349+
(if (= (length effort) hand-servo-num)
346350
(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))
348352
((:rhand :lhand)
349-
(assert (= (length effort) +hironx-hand-servo-num+))))
353+
(send self :check-hand-vector-length effort)))
350354
;; setmaxtorque with different effort values
351355
(map cons
352356
#'(lambda (id val)
@@ -363,8 +367,7 @@
363367
(let ((a (rad2deg %(pi/2 - acos((width / 2.0 + safetymargin - w0) / l1)))))
364368
(float-vector a (- a) (- a) a))))
365369
(: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)
368371
(let ((safetymargin 3) (w0 19) (l1 41.9) (l2 20))
369372
(flet ((get-width (r1 r2) %( w0 + l1 * cos(pi/2 - r1) + l2 * cos(pi/2 - r1 - r2) - safetymargin)))
370373
(multiple-value-bind (a1 a2 b1 b2) (map cons #'deg2rad vec)

0 commit comments

Comments
 (0)