Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revive action primitives examples and tests #842

Merged
merged 87 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
421ca70
load robot bugfix
Aug 21, 2024
e7ef748
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2024
495f49f
add the comment back
Aug 21, 2024
8da4ee3
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Aug 21, 2024
609da8e
action primitive navigation fixed
Aug 26, 2024
2a70755
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
Aug 26, 2024
6db6e88
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2024
f7601e5
ik controller to joint controller
Aug 27, 2024
0544275
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Aug 27, 2024
1ac8497
ik control to joint control
Aug 27, 2024
51d0cf6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2024
aa58d9b
remove empty lines
Aug 27, 2024
bf24672
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Aug 27, 2024
53494c3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2024
6db2377
test functional 7/10
Sep 1, 2024
2b3278d
test 7/10 functional
Sep 1, 2024
a155e70
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2024
6b3c8ff
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
Sep 4, 2024
66970e2
primitives partially working
Sep 7, 2024
a5fdd04
pritives test runnable
Sep 10, 2024
782f759
symbolic primitives partially passed
Sep 11, 2024
254deb3
test all working
Sep 12, 2024
d685a57
test_tiago w/ transition_rule
Sep 13, 2024
61b629b
wip symbolic test
Sep 16, 2024
e54d544
most fixes addressed
Sep 16, 2024
d6263ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 16, 2024
c27f59e
two empty lines
Sep 16, 2024
e66c82d
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 16, 2024
d2bfecd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 16, 2024
53277f4
symbolic primitive and primitive passing
Sep 19, 2024
2cf3902
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 19, 2024
7dcdfd2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 19, 2024
8fe8ecf
control no op action
Sep 20, 2024
4f94198
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 20, 2024
35cbf69
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2024
7af7086
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
Sep 20, 2024
db7b0bd
test fixed
Sep 21, 2024
3d3d8dc
test passed
Sep 21, 2024
1e98daa
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 21, 2024
9bbeb99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 21, 2024
d91ea90
holonomic base wip
Sep 23, 2024
113ffe5
revived primitive and symbolic primitives
Sep 23, 2024
a9fdae5
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 23, 2024
6e5d186
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2024
6cea6d6
reformat empty action
Sep 23, 2024
3a806cf
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 23, 2024
83c1eea
reformat for github
Sep 23, 2024
b662788
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2024
2961164
empty action for no-op
Sep 24, 2024
ae49f5b
true no op action
Sep 24, 2024
527732c
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 24, 2024
ebdd758
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
Sep 25, 2024
e41a766
primitives fixed except for symbolic primitives
Sep 25, 2024
9744531
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2024
ca1b56e
test
Sep 26, 2024
9680210
primitives minor update
Sep 26, 2024
36b896a
minor primitives test update
Sep 26, 2024
7e05790
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
7c29f5a
all tests passed
Sep 26, 2024
f816bb0
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 26, 2024
809be5a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
5425627
ready for merge
Sep 27, 2024
126254e
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 27, 2024
8221732
test error resovled from IK controller
Sep 27, 2024
c583e43
multi finger gripper support added
Sep 27, 2024
f84d324
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 27, 2024
3f661e4
wip test controllers
Sep 30, 2024
22df2cd
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Sep 30, 2024
2f0734e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2024
0a4dc08
removed finger path
Sep 30, 2024
6e9f6f1
test without seeding
Sep 30, 2024
d145657
primitive test without seednig
Sep 30, 2024
aa1ec79
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2024
06c8bfc
test without seeding
Sep 30, 2024
97893eb
primitive test without seed
Sep 30, 2024
85a849e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2024
b5c254b
primitive with seeding
Oct 1, 2024
5f754ba
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Oct 1, 2024
0b245a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 1, 2024
79e0105
test with seeding
Oct 1, 2024
df38c80
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Oct 1, 2024
cc32e4e
Update usd_utils.py
yyf20001230 Oct 1, 2024
1954ad4
test controllers with relaxed bounds
Oct 1, 2024
eabc9f2
Merge branch 'curobo' of https://github.com/StanfordVL/OmniGibson int…
Oct 1, 2024
3232a45
Merge branch 'og-develop' into curobo
yyf20001230 Oct 1, 2024
893ad2c
revert back the tolerance relaxation, and give robots deterministic n…
ChengshuLi Oct 1, 2024
e88d4a4
Merge branch 'og-develop' into curobo
cgokmen Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 94 additions & 49 deletions omnigibson/action_primitives/starter_semantic_action_primitives.py
yyf20001230 marked this conversation as resolved.
Show resolved Hide resolved
cgokmen marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions omnigibson/action_primitives/symbolic_semantic_action_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives
from omnigibson.objects import DatasetObject
from omnigibson.robots.robot_base import BaseRobot
from omnigibson.transition_rules import REGISTERED_RULES, TransitionRuleAPI
from omnigibson.transition_rules import REGISTERED_RULES, SlicingRule, TransitionRuleAPI


class SymbolicSemanticActionPrimitiveSet(IntEnum):
Expand Down Expand Up @@ -291,7 +291,7 @@ def _soak_under(self, obj):
producing_systems = {
ps
for ps in obj.scene.system_registry.objects
if obj.states[object_states.ParticleSource].check_conditions_for_system(ps)
if obj.states[object_states.ParticleSource].check_conditions_for_system(ps.name)
}
if not producing_systems:
raise ActionPrimitiveError(
Expand All @@ -309,8 +309,9 @@ def _soak_under(self, obj):
)

supported_systems = {
x for x in producing_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x)
x for x in producing_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
}

if not supported_systems:
raise ActionPrimitiveError(
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
Expand All @@ -328,7 +329,7 @@ def _soak_under(self, obj):
currently_removable_systems = {
x
for x in supported_systems
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x)
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
}
if not currently_removable_systems:
# TODO: This needs to be far more descriptive.
Expand All @@ -346,6 +347,9 @@ def _soak_under(self, obj):
for system in currently_removable_systems:
obj_in_hand.states[object_states.Saturated].set_value(system, True)

# Yield some actions
yield from self._settle_robot()

def _soak_inside(self, obj):
# Check that our current object is a particle remover
obj_in_hand = self._get_obj_in_hand()
Expand Down Expand Up @@ -382,7 +386,7 @@ def _soak_inside(self, obj):
)

supported_systems = {
x for x in contained_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x)
x for x in contained_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
}
if not supported_systems:
raise ActionPrimitiveError(
Expand All @@ -401,7 +405,7 @@ def _soak_inside(self, obj):
currently_removable_systems = {
x
for x in supported_systems
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x)
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
}
if not currently_removable_systems:
# TODO: This needs to be far more descriptive.
Expand All @@ -419,6 +423,9 @@ def _soak_inside(self, obj):
for system in currently_removable_systems:
obj_in_hand.states[object_states.Saturated].set_value(system, True)

# Yield some actions
yield from self._settle_robot()

def _wipe(self, obj):
# Check that our current object is a particle remover
obj_in_hand = self._get_obj_in_hand()
Expand All @@ -438,7 +445,7 @@ def _wipe(self, obj):

# Check if the target object has any particles on it
covering_systems = {
ps for ps in obj.scene.system_registry.objects if obj.states[object_states.Covered].get_value(ps.states)
ps for ps in obj.scene.system_registry.objects if obj.states[object_states.Covered].get_value(ps)
}
if not covering_systems:
raise ActionPrimitiveError(
Expand All @@ -456,7 +463,7 @@ def _wipe(self, obj):
)

supported_systems = {
x for x in covering_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x)
x for x in covering_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
}
if not supported_systems:
raise ActionPrimitiveError(
Expand All @@ -475,7 +482,7 @@ def _wipe(self, obj):
currently_removable_systems = {
x
for x in supported_systems
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x)
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
}
if not currently_removable_systems:
# TODO: This needs to be far more descriptive.
Expand All @@ -488,10 +495,12 @@ def _wipe(self, obj):
"particles the target object is covered by": sorted(x.name for x in covering_systems),
},
)

# If so, remove the particles.
# If so, remove the particles on the target object
for system in currently_removable_systems:
obj_in_hand.states[object_states.Covered].set_value(system, False)
obj.states[object_states.Covered].set_value(system, False)

# Yield some actions
yield from self._settle_robot()

def _cut(self, obj):
# Check that our current object is a slicer
Expand Down Expand Up @@ -523,7 +532,8 @@ def _cut(self, obj):
# TODO: Do some more validation
added_obj_attrs = []
removed_objs = []
output = REGISTERED_RULES["SlicingRule"].transition({"sliceable": [obj]})
(slicing_rule,) = [rule for rule in obj.scene.transition_rule_api.active_rules if isinstance(rule, SlicingRule)]
output = slicing_rule.transition({"sliceable": [obj]})
added_obj_attrs += output.add
removed_objs += output.remove

Expand Down
13 changes: 5 additions & 8 deletions omnigibson/configs/fetch_primitives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,16 @@ robots:
base:
name: DifferentialDriveController
arm_0:
name: InverseKinematicsController
command_input_limits: default
command_output_limits:
- [-0.2, -0.2, -0.2, -0.5, -0.5, -0.5]
- [0.2, 0.2, 0.2, 0.5, 0.5, 0.5]
mode: pose_absolute_ori
kp: 300.0
name: JointController
motor_type: position
command_input_limits: null
use_delta_commands: false
gripper_0:
name: JointController
motor_type: position
command_input_limits: [-1, 1]
command_output_limits: null
use_delta_commands: true
use_delta_commands: false
camera:
name: JointController
use_delta_commands: False
Expand Down
82 changes: 82 additions & 0 deletions omnigibson/configs/tiago_primitives.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
env:
action_frequency: 30 # (int): environment executes action at the action_frequency rate
physics_frequency: 120 # (int): physics frequency (1 / physics_timestep for physx)
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
automatic_reset: false # (bool): whether to automatic reset after an episode finishes
flatten_action_space: false # (bool): whether to flatten the action space as a sinle 1D-array
flatten_obs_space: false # (bool): whether the observation space should be flattened when generated
use_external_obs: false # (bool): Whether to use external observations or not
initial_pos_z_offset: 0.1
external_sensors: null # (None or list): If specified, list of sensor configurations for external sensors to add. Should specify sensor "type" and any additional kwargs to instantiate the sensor. Each entry should be the kwargs passed to @create_sensor, in addition to position, orientation

render:
viewer_width: 1280
viewer_height: 720

scene:
type: InteractiveTraversableScene
scene_model: Rs_int
trav_map_resolution: 0.1
default_erosion_radius: 0.0
trav_map_with_objects: true
num_waypoints: 1
waypoint_resolution: 0.2
load_object_categories: null
not_load_object_categories: null
load_room_types: null
load_room_instances: null
load_task_relevant_only: false
seg_map_resolution: 0.1
scene_source: OG
include_robots: false

robots:
- type: Tiago
obs_modalities: [rgb, depth, seg_semantic, normal, seg_instance, seg_instance_id]
scale: 1.0
self_collisions: true
action_normalize: false
action_type: continuous
grasping_mode: sticky
rigid_trunk: false
default_trunk_offset: 0.15
default_arm_pose: vertical
sensor_config:
VisionSensor:
sensor_kwargs:
image_height: 128
image_width: 128
controller_config:
base:
name: JointController
arm_left:
name: JointController
motor_type: position
command_input_limits: null
command_output_limits: null
use_delta_commands: false
yyf20001230 marked this conversation as resolved.
Show resolved Hide resolved
arm_right:
name: JointController
motor_type: position
command_input_limits: null
command_output_limits: null
use_delta_commands: false
gripper_left:
name: JointController
motor_type: position
command_input_limits: [-1, 1]
command_output_limits: null
use_delta_commands: false
gripper_right:
name: JointController
motor_type: position
command_input_limits: [-1, 1]
command_output_limits: null
use_delta_commands: false
camera:
name: JointController

objects: []

task:
type: DummyTask
5 changes: 3 additions & 2 deletions omnigibson/controllers/controller_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _preprocess_command(self, command):
Array[float]: Processed command vector
"""
# Make sure command is a th.tensor
command = th.tensor([command]) if type(command) in {int, float} else command
command = th.tensor([command], dtype=th.float32) if type(command) in {int, float} else command
# We only clip and / or scale if self.command_input_limits exists
if self._command_input_limits is not None:
# Clip
Expand Down Expand Up @@ -336,7 +336,8 @@ def compute_no_op_goal(self, control_dict):

def compute_no_op_action(self, control_dict):
"""
Compute no-op action given the goal
Compute a no-op action that updates the goal to match the current position
Disclaimer: this no-op might cause drift under external load (e.g. when the controller cannot reach the goal position)
"""
if self._goal is None:
self._goal = self.compute_no_op_goal(control_dict=control_dict)
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/controllers/dd_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def compute_no_op_goal(self, control_dict):
return dict(vel=th.zeros(2))

def _compute_no_op_action(self, control_dict):
return self._goal["vel"]
return th.zeros(2, dtype=th.float32)

def _get_goal_shapes(self):
# Add (2, )-array representing linear, angular velocity
Expand Down
24 changes: 7 additions & 17 deletions omnigibson/controllers/ik_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,34 +352,24 @@ def compute_no_op_goal(self, control_dict):
)

def _compute_no_op_action(self, control_dict):

target_pos = self._goal["target_pos"]
target_quat = self._goal["target_quat"]
pos_relative = control_dict[f"{self.task_name}_pos_relative"]
quat_relative = control_dict[f"{self.task_name}_quat_relative"]

command = th.zeros(6, dtype=th.float32, device=target_pos.device)
command = th.zeros(6, dtype=th.float32, device=pos_relative.device)

# Handle position
if self.mode == "absolute_pose":
command[:3] = target_pos
command[:3] = pos_relative
else:
command[:3] = target_pos - pos_relative
# We can leave it as zero for delta mode.
pass

# Handle orientation
if self.mode == "position_fixed_ori" or self.mode == "position_compliant_ori":
if self.mode in ("pose_absolute_ori", "absolute_pose"):
command[3:] = T.quat2axisangle(quat_relative)
else:
# For these modes, we don't need to add orientation to the command
pass
elif self.mode == "pose_absolute_ori" or self.mode == "absolute_pose":
command[3:] = T.quat2axisangle(target_quat)
else: # pose_delta_ori control
current_rot = T.quat2mat(quat_relative)
target_rot = T.quat2mat(target_quat)
delta_rot = target_rot @ (current_rot.T)

# Convert delta rotation to axis-angle representation
delta_axisangle = T.quat2axisangle(T.mat2quat(delta_rot))
command[3:] = delta_axisangle

return command

Expand Down
20 changes: 12 additions & 8 deletions omnigibson/controllers/joint_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,18 @@ def compute_no_op_goal(self, control_dict):
return dict(target=target)

def _compute_no_op_action(self, control_dict):
if self._use_delta_commands:
base_value = control_dict[f"joint_{self._motor_type}"][self.dof_idx]
# TODO: do we need to care about the entire gimbal lock situation?
command = self._goal["target"] - base_value
else:
command = self._goal["target"]

return command
if self.motor_type == "position":
if self._use_delta_commands:
return th.zeros(self.command_dim)
else:
return control_dict[f"joint_position"][self.dof_idx]
elif self.motor_type == "velocity":
if self._use_delta_commands:
return -control_dict[f"joint_velocity"][self.dof_idx]
else:
return th.zeros(self.command_dim)

raise ValueError("Cannot compute noop action for effort motor type.")

def _get_goal_shapes(self):
return dict(target=(self.control_dim,))
Expand Down
20 changes: 19 additions & 1 deletion omnigibson/controllers/multi_finger_gripper_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,25 @@ def compute_no_op_goal(self, control_dict):
return dict(target=th.zeros(self.command_dim))

def _compute_no_op_action(self, control_dict):
return self._goal["target"]
# Take care of the special case of binary control
if self._mode == "binary":
command_val = -1 if self.is_grasping() == IsGraspingState.TRUE else 1
if self._inverted:
command_val = -1 * command_val
return th.tensor([command_val], dtype=th.float32)

if self._motor_type == "position":
command = control_dict[f"joint_position"][self.dof_idx]
elif self._motor_type == "velocity":
command = th.zeros(self.command_dim)
else:
raise ValueError("Cannot compute noop action for effort motor type.")

# Convert to binary / smooth mode if necessary
if self._mode == "smooth":
command = th.mean(command, dim=-1, keepdim=True)

return command

def _get_goal_shapes(self):
return dict(target=(self.command_dim,))
Expand Down
Loading
Loading