MCPcopy Create free account
hub / github.com/RoboCodeX-source/RoboCodeX_code / prepare_vars

Function prepare_vars

instruct_to_policy/scripts/src/utils.py:29–99  ·  view source on GitHub ↗

Prepare variables including APIs and objects for LMPs

(env, defined_functions:List[str]=[], detached_mode=False)

Source from the content-addressed store, hash-verified

27 }
28
29def prepare_vars(env, defined_functions:List[str]=[], detached_mode=False):
30 """Prepare variables including APIs and objects for LMPs """
31 fixed_vars = {
32 "os": os,
33 "rospy": rospy,
34 "np": np
35 }
36 # add geometry_msgs to fixed variables
37 fixed_vars.update(
38 {
39 k: getattr(geometry_msgs.msg, k)
40 for k in [
41 "Pose",
42 "PoseStamped",
43 "Point",
44 "Quaternion",
45 ]
46 }
47 )
48
49 # lambda function to select either getattr(env, key) or None depending on detached_mode
50 get_attr_or_none = lambda key: getattr(env, key) if not detached_mode else None
51
52 # Add env api to fixed variables
53 fixed_vars.update(
54 {
55 k: get_attr_or_none(k)
56 for k in [
57 "move_group",
58 "get_object_center_position",
59 "get_object_pose",
60 "get_3d_bbox",
61 "get_obj_name_list",
62 "detect_objects",
63 "get_object_joint_info",
64 "parse_adaptive_shape_grasp_pose",
65 "parse_horizontal_grasp_pose",
66 "parse_place_pose",
67 "get_gripper_pose",
68 "open_gripper",
69 "close_gripper",
70 "attach_object",
71 "detach_object",
72 "move_to_pose",
73 "move_in_direction",
74 "generate_arc_path_around_joint",
75 "follow_path",
76 "grasp",
77 ]
78 }
79 )
80
81 # add moveit interfaces to variables
82 # TODO: do we really need to add these instances handles?
83 fixed_vars.update(
84 {
85 k: get_attr_or_none(k)
86 for k in [

Callers 2

setup_LMPFunction · 0.90
run_evalMethod · 0.90

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected