Skip to content

Commit 5028c90

Browse files
authoredNov 9, 2016
Merge pull request #643 from snozawa/update_footstep_planner_sample
Update footstep planner sample
2 parents f1bdf97 + 206c9eb commit 5028c90

File tree

7 files changed

+175
-31
lines changed

7 files changed

+175
-31
lines changed
 

‎jsk_footstep_controller/euslisp/util.l

+68
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,71 @@ You can create `*ri*' like
374374
ret-coords
375375
)
376376
)
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))))

‎jsk_footstep_planner/euslisp/footstep-planner-client-sample.l

+3-28
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,21 @@
33
(ros::load-ros-manifest "jsk_footstep_planner")
44
(load "package://jsk_footstep_controller/euslisp/util.l")
55

6-
(defun init ()
7-
(ros::roseus "footstep_planner_client")
8-
(ros::advertise "/footstep_from_marker" jsk_footstep_msgs::FootstepArray 1)
9-
(setq *client* (instance ros::simple-action-client :init
10-
"footstep_planner" jsk_footstep_msgs::PlanFootstepsAction))
11-
(unix:sleep 3)
12-
(ros::ros-info "waiting actionlib server")
13-
(send *client* :wait-for-server)
14-
(ros::ros-info "waited actionlib server")
15-
)
16-
17-
(defun send-goal (goal-coords &key (publish-result t) (start-coords (make-coords)))
18-
(let ((goal (make-footstep-planning-msgs
19-
start-coords goal-coords :frame-id "odom")))
20-
(ros::ros-info "sending goal")
21-
(send *client* :send-goal goal)
22-
(ros::ros-info "waiting for result")
23-
(send *client* :wait-for-result)
24-
;; (ros::ros-info "result: ~A" (send *client* :get-result))
25-
(when publish-result
26-
(ros::publish "/footstep_from_marker" (send (send *client* :get-result) :result)))
27-
(send (send *client* :get-result) :result)
28-
))
29-
306
(warn "
317
## launch simple node (not using pointcloud)
328
roslaunch jsk_footstep_planner optimistic_footstep_planner.launch USE_CONTROLLER:=false USE_MARKER:=false USE_PERCEPTION:=false
339
3410
")
35-
36-
(init)
37-
(setq result (send-goal (make-coords :pos (float-vector 3000 0 0))))
11+
(initialize-eus-footstep-planning-client)
12+
(setq result (plan-footstep-from-goal-coords (make-coords :pos (float-vector 3000 0 0))))
3813
(let ((footstep-coords (footstep-array->coords result)))
3914
(print-readable-coords footstep-coords)
4015
;; (send *ri* :set-foot-steps footstep-coords) ;; send real-robot if needed
4116
)
4217
(ros::spin-once)
4318

4419
(warn "
45-
(setq result (send-goal (make-coords :pos (float-vector 3000 0 0))))
20+
(setq result (plan-footstep-from-goal-coords (make-coords :pos (float-vector 3000 0 0))))
4621
(let ((footstep-coords (footstep-array->coords result)))
4722
(print-readable-coords footstep-coords)
4823
;; (send *ri* :set-foot-steps footstep-coords) ;; send real-robot if needed

‎jsk_footstep_planner/launch/cppplanner/footstep_planner.rviz

+30
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,36 @@ Visualization Manager:
568568
left: 0
569569
top: 750
570570
width: 128
571+
- Alpha: 1
572+
Autocompute Intensity Bounds: true
573+
Autocompute Value Bounds:
574+
Max Value: 10
575+
Min Value: -10
576+
Value: true
577+
Axis: Z
578+
Channel Name: intensity
579+
Class: rviz/PointCloud2
580+
Color: 255; 255; 255
581+
Color Transformer: Intensity
582+
Decay Time: 0
583+
Enabled: true
584+
Invert Rainbow: false
585+
Max Color: 255; 255; 255
586+
Max Intensity: 4096
587+
Min Color: 0; 0; 0
588+
Min Intensity: 0
589+
Name: PointCloud2
590+
Position Transformer: XYZ
591+
Queue Size: 10
592+
Selectable: true
593+
Size (Pixels): 3
594+
Size (m): 0.01
595+
Style: Flat Squares
596+
Topic: /footstep_planner/obstacle_model
597+
Unreliable: false
598+
Use Fixed Frame: true
599+
Use rainbow: true
600+
Value: true
571601
Enabled: true
572602
Global Options:
573603
Background Color: 48; 48; 48

‎jsk_footstep_planner/launch/cppplanner/optimistic_footstep_planner.launch

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<arg name="USE_PERCEPTION" default="true"/>
77
<arg name="USE_SIMPLE_FOOTSTEP_CONTROLLER" default="true" />
88
<arg name="GLOBAL_FRAME" default="map" />
9+
<arg name="USE_OBSTACLE_MODEL" default="false" />
910
<node pkg="dynamic_tf_publisher" type="tf_publish.py" name="dynamic_tf_publisher"
1011
output="log">
1112
<param name="use_cache" value="false"/>
@@ -17,18 +18,21 @@
1718
<!-- <remap from="footstep_planner/result" to="footstep_planner/result_non_refined" /> -->
1819
<rosparam subst_value="true">
1920
use_pointcloud_model: $(arg USE_PERCEPTION)
20-
use_lazy_perception: true
21+
use_lazy_perception: $(arg USE_PERCEPTION)
2122
use_local_movement: false
2223
use_transition_limit: true
2324
project_start_state: $(arg USE_PERCEPTION)
2425
project_goal_state: $(arg USE_PERCEPTION)
26+
use_obstacle_model: $(arg USE_OBSTACLE_MODEL)
2527
</rosparam>
2628
<rosparam>
2729
resolution_x: 0.1
2830
resolution_y: 0.1
2931
resolution_theta: 0.1
3032
footstep_size_x: 0.24
3133
footstep_size_y: 0.14
34+
collision_bbox_size: [0.4, 1.2, 1.0]
35+
collision_bbox_offset: [0, 0, 0]
3236
</rosparam>
3337
<!-- successors -->
3438
<rosparam>

‎jsk_footstep_planner/src/footstep_graph.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ namespace jsk_footstep_planner
125125
bool FootstepGraph::isColliding(StatePtr current_state, StatePtr previous_state)
126126
{
127127
// if not use obstacle model, always return false
128-
// to be collision-free always.
129-
if (!use_obstacle_model_) {
128+
// if use obstacle model and obstacle_model_ point cloud size is zero, always return false
129+
// => to be collision-free always.
130+
if (!use_obstacle_model_ || (obstacle_model_->size() == 0) ) {
130131
return false;
131132
}
132133
// compute robot coorde
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env roseus
2+
3+
(require :unittest "lib/llib/unittest.l")
4+
(init-unit-test)
5+
6+
(deftest test-sample-init
7+
(assert
8+
(progn
9+
;;(require "package://jsk_footstep_planner/euslisp/footstep-planner-client-sample.l")
10+
(ros::load-ros-manifest "jsk_footstep_planner")
11+
(load "package://jsk_footstep_controller/euslisp/util.l")
12+
(initialize-eus-footstep-planning-client)
13+
*footstep-planning-client*)))
14+
15+
(deftest test-sample-without-obstacle
16+
(assert
17+
(progn
18+
;; Set empty point cloud == no obstacle
19+
(publish-footstep-planning-obstacle-model-from-eus-pointcloud (instance pointcloud :init))
20+
(let* ((result (plan-footstep-from-goal-coords (make-coords :pos (float-vector 3000 0 0)))))
21+
(and result (footstep-array->coords result))
22+
))))
23+
24+
(deftest test-sample-with-obstacle-1
25+
(assert
26+
(progn
27+
(let ((obstacle-point-cloud
28+
(get-pointcloud-within-bodies-2D (list (let ((bb (make-cube 400 400 50))) (send bb :translate (float-vector 400 0 0)) (send bb :worldcoords) bb)))))
29+
;; Set obstacle by cube
30+
(publish-footstep-planning-obstacle-model-from-eus-pointcloud obstacle-point-cloud)
31+
(let* ((result (plan-footstep-from-goal-coords (make-coords :pos (float-vector 3000 0 0)))))
32+
(and result (footstep-array->coords result))
33+
)))))
34+
35+
(deftest test-sample-with-obstacle-2
36+
(assert
37+
(progn
38+
(load "models/room73b2-scene")
39+
(Objects (list (room73b2)))
40+
(let ((obstacle-point-cloud
41+
(get-pointcloud-within-bodies-2D
42+
(list
43+
(send (make-bounding-box (flatten (send-all (send (send *room73b2* :object "room73b2-gifuplastic-900-cart") :bodies) :vertices))) :body)
44+
))))
45+
(publish-footstep-planning-obstacle-model-from-eus-pointcloud obstacle-point-cloud)
46+
(let ((result (plan-footstep-from-goal-coords
47+
(send (send (send (send *room73b2* :object "room73b2-gifuplastic-900-cart") :copy-worldcoords) :translate (float-vector -600 -500 0) :world) :rotate pi/2 :z)
48+
:start-coords (send (send (send *room73b2* :object "room73b2-gifuplastic-900-cart") :copy-worldcoords) :translate (float-vector 0 300 0) :world))))
49+
(and result (footstep-array->coords result))
50+
)))))
51+
52+
(run-all-tests)
53+
(exit 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<launch>
2+
<env name="ROBOT" value="JAXON_RED"/>
3+
<arg name="USE_RVIZ" default="false"/>
4+
<include file="$(find jsk_footstep_planner)/launch/cppplanner/optimistic_footstep_planner.launch">
5+
<arg name="USE_SIMPLE_FOOTSTEP_CONTROLLER" value="true"/>
6+
<arg name="USE_PERCEPTION" value="false"/>
7+
<arg name="USE_CONTROLLER" value="false"/>
8+
<arg name="USE_MARKER" value="false"/>
9+
<arg name="USE_OBSTACLE_MODEL" value="true"/>
10+
<arg name="USE_RVIZ" value="$(arg USE_RVIZ)"/>
11+
</include>
12+
<test test-name="test_footstep_planning_eus_client" pkg="jsk_footstep_planner" type="test_footstep_planning_eus_client.l" time-limit="60.0"/>
13+
</launch>

0 commit comments

Comments
 (0)
Please sign in to comment.