Skip to content

Commit f1dc055

Browse files
committed
Add integration test for lab_sim
Signed-off-by: Paul Gesel <[email protected]>
1 parent f47b6de commit f1dc055

11 files changed

+114
-18
lines changed

src/lab_sim/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ install(
4141
)
4242

4343
if(BUILD_TESTING)
44+
find_package(ament_cmake_pytest REQUIRED)
4445
find_package(ament_lint_auto REQUIRED)
4546
ament_lint_auto_find_test_dependencies()
47+
ament_add_pytest_test(
48+
test_objective_server_node_integration test/test_core_objectives.py
49+
TIMEOUT 600
50+
ENV STUDIO_CONFIG_PACKAGE=lab_sim STUDIO_HOST_USER_WORKSPACE=${CMAKE_SOURCE_DIR})
4651
endif()
4752

4853
ament_package()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DetectAprilTags:
2+
apriltag_family_name: 36h11
3+
apriltag_size: 0.04
4+
max_hamming: 0
5+
n_threads: 1
6+
quad_decimate: 2
7+
quad_sigma: 0.0
8+
refine_edges: true
9+
z_up: false

src/lab_sim/objectives/force_relaxation.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
publish_rate="50"
2727
twist_stamped="{zero_twist}"
2828
wrench_stamped="{zero_wrench}"
29+
velocity_controlled_axes="0;0;0;0;0;0"
30+
velocity_force_controller_command_topic="/velocity_force_controller/command"
2931
/>
3032
</Decorator>
3133
</Decorator>
@@ -39,19 +41,21 @@
3941
velocity_controlled_axes="1;1;1;0;0;0"
4042
wrench_stamped="{zero_wrench}"
4143
twist_stamped="{zero_twist}"
44+
velocity_force_controller_command_topic="/velocity_force_controller/command"
4245
/>
4346
</Decorator>
4447
</Decorator>
4548
</Control>
4649
</BehaviorTree>
4750
<TreeNodesModel>
4851
<SubTree ID="Force Relaxation">
49-
<input_port name="wrench_gain" default="0.01" />
50-
<input_port name="relaxation_time_ms" default="500" />
51-
<input_port name="tip_link" default="grasp_link" />
5252
<MetadataFields>
5353
<Metadata subcategory="Motion - Controls" />
54+
<Metadata runnable="false" />
5455
</MetadataFields>
56+
<input_port name="relaxation_time_ms" default="500" />
57+
<input_port name="tip_link" default="grasp_link" />
58+
<input_port name="wrench_gain" default="0.01" />
5559
</SubTree>
5660
</TreeNodesModel>
5761
</root>

src/lab_sim/objectives/grasp_planning.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<Action
6868
ID="SetupMTCConnectWithTrajectory"
6969
constraints="{constraints}"
70-
planner_interface="moveit_pro"
70+
planner_interface="pro_rrt"
7171
planning_group_name="manipulator"
7272
task="{pick_object_task}"
7373
/>

src/lab_sim/objectives/grasp_pose_tuning_with_april_tag.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<root BTCPP_format="4" main_tree_to_execute="Grasp Pose Tuning With April Tag">
33
<!--//////////-->
44
<BehaviorTree
@@ -94,7 +94,7 @@
9494
source_to_destination_pose="{relative_pose}"
9595
/>
9696
<Action
97-
ID="SavePoseToYaml"
97+
ID="SavePoseStampedToYaml"
9898
message="{relative_pose}"
9999
yaml_filename="relative_grasp_pose"
100100
namespace="RelativePose"

src/lab_sim/objectives/grasp_pose_using_yaml.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
ID="Pick from Pose"
9696
_collapsed="true"
9797
grasp_poses="{grasp_poses}"
98+
approach_distance="0.1"
99+
retract_xyz="0;0;-0.1"
98100
/>
99101
</Control>
100102
</BehaviorTree>

src/lab_sim/objectives/load_mesh_as_green_poincloud.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<input_port name="initial_pose" default="{stamped_pose}" />
3333
<MetadataFields>
3434
<Metadata subcategory="Perception - 3D Point Cloud" />
35+
<Metadata runnable="false" />
3536
</MetadataFields>
3637
</SubTree>
3738
</TreeNodesModel>

src/lab_sim/objectives/load_mesh_as_red_pointcloud.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<input_port name="initial_pose" default="{stamped_pose}" />
3333
<MetadataFields>
3434
<Metadata subcategory="Perception - 3D Point Cloud" />
35+
<Metadata runnable="false" />
3536
</MetadataFields>
3637
</SubTree>
3738
</TreeNodesModel>

src/lab_sim/objectives/plan_move_to_pose.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
task_id="move_to_pose"
1212
controller_names="/joint_trajectory_controller;/robotiq_gripper_controller"
1313
task="{move_to_pose_task}"
14+
trajectory_monitoring="false"
1415
/>
1516
<Action ID="SetupMTCCurrentState" task="{move_to_pose_task}" />
1617
<Action
@@ -19,6 +20,15 @@
1920
planning_group_name="manipulator"
2021
target_pose="{target_pose}"
2122
task="{move_to_pose_task}"
23+
acceleration_scale_factor="1.000000"
24+
keep_orientation="false"
25+
keep_orientation_link_names="grasp_link"
26+
keep_orientation_tolerance="0.100000"
27+
link_padding="0.000000"
28+
max_iterations="5000"
29+
monitored_stage="current state"
30+
trajectory_sampling_rate="100"
31+
velocity_scale_factor="1.000000"
2232
/>
2333
<Action
2434
ID="PlanMTCTask"
@@ -29,14 +39,15 @@
2939
</BehaviorTree>
3040
<TreeNodesModel>
3141
<SubTree ID="Plan Move To Pose">
32-
<input_port name="target_pose" default="{target_pose}" />
42+
<MetadataFields>
43+
<Metadata subcategory="Motion - Planning" />
44+
<Metadata runnable="false" />
45+
</MetadataFields>
3346
<output_port
3447
name="move_to_pose_solution"
3548
default="{move_to_pose_solution}"
3649
/>
37-
<MetadataFields>
38-
<Metadata subcategory="Motion - Planning" />
39-
</MetadataFields>
50+
<input_port name="target_pose" default="{target_pose}" />
4051
</SubTree>
4152
</TreeNodesModel>
4253
</root>
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
12
<root BTCPP_format="4" main_tree_to_execute="Add Poses to MTC Task">
23
<!--//////////-->
34
<BehaviorTree
@@ -10,10 +11,11 @@
1011
ID="InitializeMTCTask"
1112
controller_names="/joint_trajectory_controller;/robotiq_gripper_controller"
1213
task="{mtc_task}"
14+
trajectory_monitoring="false"
1315
/>
14-
<!-- Start the MTC task from the robot's current pose -->
16+
<!--Start the MTC task from the robot's current pose-->
1517
<Action ID="SetupMTCCurrentState" task="{mtc_task}" />
16-
<!-- Use a script with a pose counter so we can give a unique name to each marker (allowing multiple poses to be visualized) -->
18+
<!--Use a script with a pose counter so we can give a unique name to each marker (allowing multiple poses to be visualized)-->
1719
<Action ID="Script" code="pose_ctr := 0" />
1820
<Decorator
1921
ID="ForEach"
@@ -22,11 +24,13 @@
2224
index="{index}"
2325
>
2426
<Control ID="Sequence">
25-
<!-- Visualize and add each pose to the vector -->
27+
<!--Visualize and add each pose to the vector-->
2628
<Action
2729
ID="VisualizePose"
2830
marker_name="{pose_ctr}"
2931
pose="{target_pose}"
32+
marker_lifetime="0.000000"
33+
marker_size="0.100000"
3034
/>
3135
<Action ID="Script" code="pose_ctr += 1" />
3236
<Action
@@ -35,24 +39,34 @@
3539
planning_group_name="{planning_group_name}"
3640
target_pose="{target_pose}"
3741
task="{mtc_task}"
42+
acceleration_scale_factor="1.000000"
43+
keep_orientation="false"
44+
keep_orientation_link_names="grasp_link"
45+
keep_orientation_tolerance="0.100000"
46+
link_padding="0.000000"
47+
max_iterations="5000"
48+
monitored_stage="current state"
49+
trajectory_sampling_rate="100"
50+
velocity_scale_factor="1.000000"
3851
/>
3952
</Control>
4053
</Decorator>
4154
</Control>
4255
</BehaviorTree>
4356
<TreeNodesModel>
4457
<SubTree ID="Add Poses to MTC Task">
45-
<input_port name="target_poses" default="{target_poses}" />
58+
<MetadataFields>
59+
<Metadata subcategory="Motion - Task Planning" />
60+
<Metadata runnable="false" />
61+
</MetadataFields>
4662
<input_port
4763
name="controller_names"
4864
default="/joint_trajectory_controller;/robotiq_gripper_controller"
4965
/>
50-
<input_port name="planning_group_name" default="manipulator" />
5166
<input_port name="ik_frame" default="grasp_link" />
5267
<inout_port name="mtc_task" default="{mtc_task}" />
53-
<MetadataFields>
54-
<Metadata subcategory="Motion - Task Planning" />
55-
</MetadataFields>
68+
<input_port name="planning_group_name" default="manipulator" />
69+
<input_port name="target_poses" default="{target_poses}" />
5670
</SubTree>
5771
</TreeNodesModel>
5872
</root>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import time
2+
3+
import pytest
4+
from moveit_pro_test_utils.objective_test_fixture import (
5+
ExecuteObjectiveResource,
6+
execute_objective_resource as execute_objective_resource,
7+
get_objective_pytest_params,
8+
run_objective,
9+
)
10+
11+
cancel_objectives = {
12+
"3 Waypoints Pick and Place",
13+
"Cycle Between Waypoints",
14+
"Grasp Object from Text Prompt",
15+
"Grasp Planning",
16+
"Grasp Pose Tuning With April Tag",
17+
"Grasp Pose Using Yaml",
18+
"Joint Diagnostic",
19+
"Loop Detect AprilTag",
20+
"Pick And Place Example",
21+
"Pick April Tag Labeled Object With Approval",
22+
"Place Object",
23+
"Plan and Save Trajectory",
24+
"Record and Replay Scanning Motion",
25+
}
26+
skip_objectives = {
27+
"Grasp Planning",
28+
"Joint Diagnostic",
29+
"ML Segment Image from Text Prompt",
30+
"ML Segment Point Cloud from Clicked Point",
31+
"Pick up Cube",
32+
"Place Object",
33+
"Teleoperate",
34+
}
35+
36+
37+
@pytest.mark.parametrize(
38+
"objective_id, should_cancel",
39+
get_objective_pytest_params("lab_sim", cancel_objectives, skip_objectives),
40+
)
41+
def test_all_objectives(
42+
objective_id: str,
43+
should_cancel: bool,
44+
execute_objective_resource: ExecuteObjectiveResource,
45+
):
46+
if objective_id == "Close Gripper":
47+
time.sleep(60*2)
48+
49+
run_objective(objective_id, should_cancel, execute_objective_resource)

0 commit comments

Comments
 (0)