@@ -374,3 +374,71 @@ You can create `*ri*' like
374
374
ret-coords
375
375
)
376
376
)
377
+
378
+ ; ; Functions to use footstep planning from euslisp
379
+ (defun initialize-eus-footstep-planning-client
380
+ ()
381
+ " Initialize footstep planning client from euslisp."
382
+ (ros ::roseus " footstep_planner_client" )
383
+ ; ; For obstacles
384
+ (ros ::advertise " /footstep_planner/obstacle_model" sensor_msgs ::PointCloud2 1 )
385
+ (ros ::load-ros-manifest " sensor_msgs" )
386
+ ; ; For visualization
387
+ (ros ::advertise " /footstep_from_marker" jsk_footstep_msgs ::FootstepArray 1 )
388
+ ; ; For footstep planning action server
389
+ (setq *footstep-planning-client* (instance ros ::simple-action-client :init
390
+ " footstep_planner" jsk_footstep_msgs ::PlanFootstepsAction))
391
+ (unix :sleep 3 )
392
+ (ros ::ros-info " waiting actionlib server" )
393
+ (send *footstep-planning-client* :wait-for-server )
394
+ (ros ::ros-info " waited actionlib server" )
395
+ )
396
+
397
+ (defun plan-footstep-from-goal-coords
398
+ (goal-coords &key (publish-result t ) (start-coords (make-coords)) (frame-id " odom" ))
399
+ " Plan footstep from goal-coords."
400
+ (let ((goal (make-footstep-planning-msgs
401
+ start-coords goal-coords :frame-id frame-id)))
402
+ (ros ::ros-info " sending goal" )
403
+ (send *footstep-planning-client* :send-goal goal)
404
+ (ros ::ros-info " waiting for result" )
405
+ (send *footstep-planning-client* :wait-for-result )
406
+ ; ; (ros::ros-info "result: ~A" (send *footstep-planning-client* :get-result))
407
+ (when publish-result
408
+ (ros ::publish " /footstep_from_marker" (send (send *footstep-planning-client* :get-result ) :result )))
409
+ (send (send *footstep-planning-client* :get-result ) :result )
410
+ ))
411
+
412
+ (defun publish-footstep-planning-obstacle-model-from-eus-pointcloud
413
+ (a-pointcloud &key (frame-id " odom" ))
414
+ " Publish obsacle_model used in footstep planning.
415
+ A eus-style pointcloud is required as an argument."
416
+ (ros ::publish " /footstep_planner/obstacle_model" (make-ros-msg-from-eus-pointcloud a-pointcloud :frame frame-id))
417
+ )
418
+
419
+ (defun get-pointcloud-within-bodies-2D
420
+ (blist &key (return-point-cloud t ) ((:resolution dif) 50.0 ))
421
+ " Get pointcloud within bodies.
422
+ blist is list of bodies.
423
+ All bodies are assumed to be vertical prisms, so inclusion check is 2D."
424
+ (labels
425
+ ((get-points-within-object-2D-tmp
426
+ (bb)
427
+ (let* ((ret1) (vv (send bb :vertices ))
428
+ (xmin (elt (find-extream vv #' (lambda (x) (elt x 0 )) #' < ) 0 ))
429
+ (xmax (elt (find-extream vv #' (lambda (x) (elt x 0 )) #' > ) 0 ))
430
+ (ymin (elt (find-extream vv #' (lambda (x) (elt x 1 )) #' < ) 1 ))
431
+ (ymax (elt (find-extream vv #' (lambda (x) (elt x 1 )) #' > ) 1 ))
432
+ (zmin (elt (find-extream vv #' (lambda (x) (elt x 0 )) #' < ) 2 ))
433
+ (zmax (elt (find-extream vv #' (lambda (x) (elt x 0 )) #' > ) 2 )))
434
+ (do ((x (- xmin dif) (+ dif x))) ((< (+ dif xmax) x))
435
+ (do ((y (- ymin dif) (+ dif y))) ((< (+ ymax dif) y))
436
+ (let ((z (* 0.5 (+ zmin zmax))))
437
+ (when (not (eq :outside (send bb :insidep (float-vector x y z))))
438
+ (push (float-vector x y z) ret1))
439
+ )))
440
+ ret1)))
441
+ (let ((ret1 (apply #' append (mapcar #' get-points-within-object-2D-tmp blist))))
442
+ (if return-point-cloud
443
+ (instance pointcloud :init :points ret1)
444
+ ret1))))
0 commit comments