15
15
from overrides import override
16
16
import py_trees
17
17
from py_trees .blackboard import Blackboard
18
+ from py_trees .behaviours import Success
18
19
import py_trees_ros
19
20
from rcl_interfaces .srv import SetParameters
20
21
import rclpy
@@ -162,14 +163,14 @@ def create_tree(
162
163
name + "RemoveWheelchairWall" ,
163
164
),
164
165
workers = [
165
- py_trees_ros .service_clients .FromConstant (
166
- name = "ClearOctomap" ,
167
- service_name = "/clear_octomap" ,
168
- service_type = Empty ,
169
- service_request = Empty .Request (),
170
- # Default fail if service is down
171
- wait_for_server_timeout_sec = 0.0 ,
172
- ),
166
+ # py_trees_ros.service_clients.FromConstant(
167
+ # name="ClearOctomap",
168
+ # service_name="/clear_octomap",
169
+ # service_type=Empty,
170
+ # service_request=Empty.Request(),
171
+ # # Default fail if service is down
172
+ # wait_for_server_timeout_sec=0.0,
173
+ # ),
173
174
MoveIt2JointConstraint (
174
175
name = "RestingConstraint" ,
175
176
ns = name ,
@@ -323,7 +324,8 @@ def create_tree(
323
324
) # End RecoverySequence
324
325
325
326
def move_above_plan (
326
- flip_food_frame : bool = False , action : Optional [BlackboardKey ] = None ,
327
+ flip_food_frame : bool = False ,
328
+ action : Optional [BlackboardKey ] = None ,
327
329
) -> py_trees .behaviour .Behaviour :
328
330
return py_trees .composites .Sequence (
329
331
name = "MoveAbovePlanningSeq" ,
@@ -380,7 +382,8 @@ def move_above_plan(
380
382
inputs = {
381
383
"action_select_response" : BlackboardKey (
382
384
"action_response"
383
- ), "action" : action ,
385
+ ),
386
+ "action" : action ,
384
387
# Default move_above_dist_m = 0.05
385
388
# Default food_frame_id = "food"
386
389
# Default approach_frame_id = "approach"
@@ -469,43 +472,77 @@ def move_above_plan(
469
472
scoped_behavior (
470
473
name = "TableCollision" ,
471
474
# Set Approach F/T Thresh
472
- pre_behavior = ToggleCollisionObject (
473
- name = "AllowTable" ,
474
- ns = name ,
475
- inputs = {
476
- "collision_object_ids" : ["table" ],
477
- "allow" : True ,
478
- },
475
+ pre_behavior = (
476
+ Success ()
477
+ # ToggleCollisionObject(
478
+ # name="AllowTable",
479
+ # ns=name,
480
+ # inputs={
481
+ # "collision_object_ids": ["table"],
482
+ # "allow": True,
483
+ # },
484
+ # )
479
485
),
480
- post_behavior = ToggleCollisionObject (
481
- name = "DisallowTable" ,
482
- ns = name ,
483
- inputs = {
484
- "collision_object_ids" : ["table" ],
485
- "allow" : False ,
486
- },
486
+ post_behavior = (
487
+ Success ()
488
+ # ToggleCollisionObject(
489
+ # name="DisallowTable",
490
+ # ns=name,
491
+ # inputs={
492
+ # "collision_object_ids": ["table"],
493
+ # "allow": False,
494
+ # },
495
+ # )
487
496
),
488
497
on_preempt_timeout = 5.0 ,
489
498
# Starts a new Sequence w/ Memory internally
490
499
workers = [
491
500
scoped_behavior (
492
501
name = "OctomapCollision" ,
493
502
# Set Approach F/T Thresh
494
- pre_behavior = ToggleCollisionObject (
495
- name = "AllowOctomap" ,
496
- ns = name ,
497
- inputs = {
498
- "collision_object_ids" : ["<octomap>" ],
499
- "allow" : True ,
500
- },
503
+ pre_behavior = py_trees .composites .Sequence (
504
+ name = "AllowOctomapAndTable" ,
505
+ memory = True ,
506
+ children = [
507
+ ToggleCollisionObject (
508
+ name = "AllowOctomap" ,
509
+ ns = name ,
510
+ inputs = {
511
+ "collision_object_ids" : ["<octomap>" ],
512
+ "allow" : True ,
513
+ },
514
+ ),
515
+ ToggleCollisionObject (
516
+ name = "AllowTable" ,
517
+ ns = name ,
518
+ inputs = {
519
+ "collision_object_ids" : ["table" ],
520
+ "allow" : True ,
521
+ },
522
+ ),
523
+ ],
501
524
),
502
- post_behavior = ToggleCollisionObject (
503
- name = "DisallowOctomap" ,
504
- ns = name ,
505
- inputs = {
506
- "collision_object_ids" : ["<octomap>" ],
507
- "allow" : False ,
508
- },
525
+ post_behavior = py_trees .composites .Sequence (
526
+ name = "DisallowOctomapAndTable" ,
527
+ memory = True ,
528
+ children = [
529
+ ToggleCollisionObject (
530
+ name = "DisallowOctomap" ,
531
+ ns = name ,
532
+ inputs = {
533
+ "collision_object_ids" : ["<octomap>" ],
534
+ "allow" : False ,
535
+ },
536
+ ),
537
+ ToggleCollisionObject (
538
+ name = "DisallowTable" ,
539
+ ns = name ,
540
+ inputs = {
541
+ "collision_object_ids" : ["table" ],
542
+ "allow" : False ,
543
+ },
544
+ ),
545
+ ],
509
546
),
510
547
on_preempt_timeout = 5.0 ,
511
548
workers = [
@@ -522,8 +559,8 @@ def move_above_plan(
522
559
name = "BackupFlipFoodFrameSel" ,
523
560
memory = True ,
524
561
children = [
525
- move_above_plan (False ),
526
- move_above_plan (True , BlackboardKey ("action" )),
562
+ move_above_plan (True ),
563
+ move_above_plan (False , BlackboardKey ("action" )),
527
564
],
528
565
),
529
566
MoveIt2Execute (
@@ -849,7 +886,7 @@ def move_above_plan(
849
886
), # OctomapCollision
850
887
]
851
888
+ resting_position_behaviors , # End TableCollision.workers
852
- ), # End TableCollision
889
+ ), # End Success # TableCollision
853
890
], # End root_seq.children
854
891
) # End root_seq
855
892
0 commit comments