fix pi value
This commit is contained in:
parent
842b2cedaa
commit
17bede3778
|
@ -10,7 +10,7 @@ import inspect
|
|||
import logging
|
||||
import random
|
||||
from functools import cached_property
|
||||
from math import ceil
|
||||
import math
|
||||
|
||||
import cv2
|
||||
import gymnasium as gym
|
||||
|
@ -1037,7 +1037,7 @@ class StarterSemanticActionPrimitives(BaseActionPrimitiveSet):
|
|||
interpolated_plan = []
|
||||
for i in range(len(plan) - 1):
|
||||
max_diff = max(plan[i + 1] - plan[i])
|
||||
num_intervals = ceil(max_diff / max_inter_dist)
|
||||
num_intervals = math.ceil(max_diff / max_inter_dist)
|
||||
interpolated_plan += th.linspace(plan[i], plan[i + 1], num_intervals, endpoint=False).tolist()
|
||||
interpolated_plan.append(plan[-1].tolist())
|
||||
return interpolated_plan
|
||||
|
@ -1720,14 +1720,14 @@ class StarterSemanticActionPrimitives(BaseActionPrimitiveSet):
|
|||
|
||||
distance_lo, distance_hi = 0.0, 5.0
|
||||
distance = (th.rand(1) * (distance_hi - distance_lo) + distance_lo).item()
|
||||
yaw_lo, yaw_hi = -3.1415, 3.1415
|
||||
yaw_lo, yaw_hi = -math.pi, math.pi
|
||||
yaw = (th.rand(1) * (yaw_hi - yaw_lo) + yaw_lo).item()
|
||||
avg_arm_workspace_range = th.mean(self.robot.arm_workspace_range[self.arm])
|
||||
pose_2d = th.Tensor(
|
||||
[
|
||||
pose_on_obj[0][0] + distance * th.cos(yaw),
|
||||
pose_on_obj[0][1] + distance * th.sin(yaw),
|
||||
yaw + 3.1415 - avg_arm_workspace_range,
|
||||
yaw + math.pi - avg_arm_workspace_range,
|
||||
]
|
||||
)
|
||||
# Check room
|
||||
|
@ -1789,7 +1789,7 @@ class StarterSemanticActionPrimitives(BaseActionPrimitiveSet):
|
|||
# # TODO(MP): Bias the sampling near the agent.
|
||||
# for _ in range(m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_IN_ROOM):
|
||||
# _, pos = self.env.scene.get_random_point_by_room_instance(room)
|
||||
# yaw_lo, yaw_hi = -3.1415, 3.1415
|
||||
# yaw_lo, yaw_hi = -math.pi, math.pi
|
||||
# yaw = (th.rand(1) * (yaw_hi - yaw_lo) + yaw_lo).item()
|
||||
# pose = (pos[0], pos[1], yaw)
|
||||
# if self._test_pose(pose):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import torch as th
|
||||
import math
|
||||
|
||||
import omnigibson.utils.transform_utils as T
|
||||
from omnigibson.controllers import ControlType, ManipulationController
|
||||
|
@ -155,21 +156,21 @@ class InverseKinematicsController(JointController, ManipulationController):
|
|||
if command_input_limits is not None:
|
||||
if type(command_input_limits) == str and command_input_limits == "default":
|
||||
command_input_limits = [
|
||||
[-1.0, -1.0, -1.0, -3.1415, -3.1415, -3.1415],
|
||||
[1.0, 1.0, 1.0, 3.1415, 3.1415, 3.1415],
|
||||
[-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi],
|
||||
[1.0, 1.0, 1.0, math.pi, math.pi, math.pi],
|
||||
]
|
||||
else:
|
||||
command_input_limits[0][3:] = -3.1415
|
||||
command_input_limits[1][3:] = 3.1415
|
||||
command_input_limits[0][3:] = -math.pi
|
||||
command_input_limits[1][3:] = math.pi
|
||||
if command_output_limits is not None:
|
||||
if type(command_output_limits) == str and command_output_limits == "default":
|
||||
command_output_limits = [
|
||||
[-1.0, -1.0, -1.0, -3.1415, -3.1415, -3.1415],
|
||||
[1.0, 1.0, 1.0, 3.1415, 3.1415, 3.1415],
|
||||
[-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi],
|
||||
[1.0, 1.0, 1.0, math.pi, math.pi, math.pi],
|
||||
]
|
||||
else:
|
||||
command_output_limits[0][3:] = -3.1415
|
||||
command_output_limits[1][3:] = 3.1415
|
||||
command_output_limits[0][3:] = -math.pi
|
||||
command_output_limits[1][3:] = math.pi
|
||||
|
||||
# Run super init
|
||||
super().__init__(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import torch as th
|
||||
import math
|
||||
|
||||
import omnigibson.utils.transform_utils as T
|
||||
from omnigibson.controllers import ControlType, ManipulationController
|
||||
|
@ -158,21 +159,21 @@ class OperationalSpaceController(ManipulationController):
|
|||
if command_input_limits is not None:
|
||||
if type(command_input_limits) == str and command_input_limits == "default":
|
||||
command_input_limits = [
|
||||
[-1.0, -1.0, -1.0, -3.1415, -3.1415, -3.1415],
|
||||
[1.0, 1.0, 1.0, 3.1415, 3.1415, 3.1415],
|
||||
[-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi],
|
||||
[1.0, 1.0, 1.0, math.pi, math.pi, math.pi],
|
||||
]
|
||||
else:
|
||||
command_input_limits[0][3:] = -3.1415
|
||||
command_input_limits[1][3:] = 3.1415
|
||||
command_input_limits[0][3:] = -math.pi
|
||||
command_input_limits[1][3:] = math.pi
|
||||
if command_output_limits is not None:
|
||||
if type(command_output_limits) == str and command_output_limits == "default":
|
||||
command_output_limits = [
|
||||
[-1.0, -1.0, -1.0, -3.1415, -3.1415, -3.1415],
|
||||
[1.0, 1.0, 1.0, 3.1415, 3.1415, 3.1415],
|
||||
[-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi],
|
||||
[1.0, 1.0, 1.0, math.pi, math.pi, math.pi],
|
||||
]
|
||||
else:
|
||||
command_output_limits[0][3:] = -3.1415
|
||||
command_output_limits[1][3:] = 3.1415
|
||||
command_output_limits[0][3:] = -math.pi
|
||||
command_output_limits[1][3:] = math.pi
|
||||
|
||||
is_input_limits_numeric = not (command_input_limits is None or isinstance(command_input_limits, str))
|
||||
is_output_limits_numeric = not (command_output_limits is None or isinstance(command_output_limits, str))
|
||||
|
@ -501,7 +502,7 @@ def _compute_osc_torques(
|
|||
# roboticsproceedings.org/rss07/p31.pdf
|
||||
if rest_qpos is not None:
|
||||
j_eef_inv = m_eef @ j_eef @ mm_inv
|
||||
u_null = kd_null * -qd + kp_null * ((rest_qpos - q + 3.1415) % (2 * 3.1415) - 3.1415)
|
||||
u_null = kd_null * -qd + kp_null * ((rest_qpos - q + math.pi) % (2 * math.pi) - math.pi)
|
||||
u_null = mm @ th.unsqueeze(u_null, dim=-1).float()
|
||||
u += (th.eye(control_dim, dtype=th.float32) - j_eef.T @ j_eef_inv) @ u_null
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import torch as th
|
||||
|
||||
import omnigibson as og
|
||||
|
@ -90,7 +91,7 @@ def main(random_selection=False, headless=False, short_exec=False):
|
|||
knife.keep_still()
|
||||
knife.set_position_orientation(
|
||||
position=apple.get_position() + th.Tensor([-0.15, 0.0, 0.2]),
|
||||
orientation=T.euler2quat([-3.1415 / 2, 0, 0]),
|
||||
orientation=T.euler2quat([-math.pi / 2, 0, 0]),
|
||||
)
|
||||
|
||||
input("The knife will fall on the apple and dice it. Press [ENTER] to continue.")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import torch as th
|
||||
|
||||
import omnigibson as og
|
||||
|
@ -88,7 +89,7 @@ def main(random_selection=False, headless=False, short_exec=False):
|
|||
knife.keep_still()
|
||||
knife.set_position_orientation(
|
||||
position=apple.get_position() + th.Tensor([-0.15, 0.0, 0.2]),
|
||||
orientation=T.euler2quat([-3.1415 / 2, 0, 0]),
|
||||
orientation=T.euler2quat([-math.pi / 2, 0, 0]),
|
||||
)
|
||||
|
||||
input("The knife will fall on the apple and slice it. Press [ENTER] to continue.")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import argparse
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -121,7 +122,7 @@ def main(random_selection=False, headless=False, short_exec=False):
|
|||
steps_per_joint = steps_per_rotate / 10
|
||||
max_steps = 100 if short_exec else 10000
|
||||
for i in range(max_steps):
|
||||
z_angle = 2 * 3.1415 * (i % steps_per_rotate) / steps_per_rotate
|
||||
z_angle = 2 * math.pi * (i % steps_per_rotate) / steps_per_rotate
|
||||
quat = T.euler2quat(th.Tensor([0, 0, z_angle]))
|
||||
pos = T.quat2mat(quat) @ center_offset
|
||||
if obj.n_dof > 0:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from collections import namedtuple
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -33,7 +34,7 @@ def get_equidistant_coordinate_planes(n_planes):
|
|||
|
||||
The samples will cover all 360 degrees (although rotational symmetry
|
||||
is assumed, e.g. if you take into account the axis index and the
|
||||
positive/negative directions, only 1/4 of the possible coordinate (1 quadrant, 3.1415 / 2.0)
|
||||
positive/negative directions, only 1/4 of the possible coordinate (1 quadrant, math.pi / 2.0)
|
||||
planes will be sampled: the ones where the first axis' positive direction
|
||||
is in the first quadrant).
|
||||
|
||||
|
@ -47,7 +48,7 @@ def get_equidistant_coordinate_planes(n_planes):
|
|||
corresponding to the axis.
|
||||
"""
|
||||
# Compute the positive directions of the 1st axis of each plane.
|
||||
first_axis_angles = th.linspace(0, 3.1415 / 2, n_planes)
|
||||
first_axis_angles = th.linspace(0, math.pi / 2, n_planes)
|
||||
first_axes = th.stack(
|
||||
[th.cos(first_axis_angles), th.sin(first_axis_angles), th.zeros_like(first_axis_angles)], dim=1
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from abc import abstractmethod
|
||||
from collections import defaultdict
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -1086,7 +1087,7 @@ class ParticleApplier(ParticleModifier):
|
|||
self.projection_source_sphere.initialize()
|
||||
self.projection_source_sphere.visible = False
|
||||
# Rotate by 90 degrees in y-axis so that the projection visualization aligns with the projection mesh
|
||||
self.projection_source_sphere.set_local_pose(orientation=T.euler2quat([0, 3.1415 / 2, 0]))
|
||||
self.projection_source_sphere.set_local_pose(orientation=T.euler2quat([0, math.pi / 2, 0]))
|
||||
|
||||
# Make sure the meta mesh is aligned with the meta link if visualizing
|
||||
# This corresponds to checking (a) position of tip of projection mesh should align with origin of
|
||||
|
@ -1388,7 +1389,7 @@ class ParticleApplier(ParticleModifier):
|
|||
n_samples = self._get_max_particles_limit_per_step(system=system)
|
||||
r, h = self._projection_mesh_params["extents"][0] / 2, self._projection_mesh_params["extents"][2]
|
||||
sampled_r_theta = th.rand(n_samples, 2)
|
||||
sampled_r_theta = sampled_r_theta * th.Tensor([r, 3.1415 * 2]).reshape(1, 2)
|
||||
sampled_r_theta = sampled_r_theta * th.Tensor([r, math.pi * 2]).reshape(1, 2)
|
||||
# Get start, end points in local link frame, start points to end points along the -z direction
|
||||
end_points = th.stack(
|
||||
[
|
||||
|
|
|
@ -3,6 +3,7 @@ import os
|
|||
from abc import ABC
|
||||
from collections import OrderedDict
|
||||
from typing import Iterable, List, Tuple
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
from scipy.spatial.transform import Rotation as R
|
||||
|
@ -46,7 +47,7 @@ m.ARM_JOINT_STIFFNESS = 1e6
|
|||
m.ARM_JOINT_MAX_EFFORT = 300
|
||||
m.FINGER_JOINT_STIFFNESS = 1e3
|
||||
m.FINGER_JOINT_MAX_EFFORT = 50
|
||||
m.FINGER_JOINT_MAX_VELOCITY = 3.1415 * 4
|
||||
m.FINGER_JOINT_MAX_VELOCITY = math.pi * 4
|
||||
|
||||
|
||||
class BehaviorRobot(ManipulationRobot, LocomotionRobot, ActiveCameraRobot):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -500,4 +501,4 @@ class Fetch(ManipulationRobot, TwoWheelRobot, ActiveCameraRobot):
|
|||
|
||||
@property
|
||||
def teleop_rotation_offset(self):
|
||||
return {self.default_arm: euler2quat([0, 3.1415 / 2, 3.1415])}
|
||||
return {self.default_arm: euler2quat([0, math.pi / 2, math.pi])}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -30,7 +31,7 @@ RESET_JOINT_OPTIONS = {
|
|||
}
|
||||
|
||||
m.MAX_LINEAR_VELOCITY = 1.5 # linear velocity in meters/second
|
||||
m.MAX_ANGULAR_VELOCITY = 3.1415 # angular velocity in radians/second
|
||||
m.MAX_ANGULAR_VELOCITY = math.pi # angular velocity in radians/second
|
||||
|
||||
|
||||
class Tiago(ManipulationRobot, LocomotionRobot, ActiveCameraRobot):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -221,7 +222,7 @@ class VX300S(ManipulationRobot):
|
|||
|
||||
@property
|
||||
def teleop_rotation_offset(self):
|
||||
return {self.default_arm: euler2quat([-3.1415, 0, 0])}
|
||||
return {self.default_arm: euler2quat([-math.pi, 0, 0])}
|
||||
|
||||
@property
|
||||
def assisted_grasp_start_points(self):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import torch as th
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -230,7 +231,7 @@ class PointNavigationTask(BaseTask):
|
|||
initial_pos = self._initial_pos
|
||||
|
||||
# Possibly sample initial ori
|
||||
quat_lo, quat_hi = 0, 3.1415 * 2
|
||||
quat_lo, quat_hi = 0, math.pi * 2
|
||||
initial_quat = (
|
||||
T.euler2quat(th.Tensor([0, 0, (th.rand(1) * (quat_hi - quat_lo) + quat_lo).item()]))
|
||||
if self._randomize_initial_quat
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import itertools
|
||||
import json
|
||||
import operator
|
||||
|
@ -1782,7 +1783,7 @@ class RecipeRule(BaseTransitionRule):
|
|||
if container.states[Contains].get_value(system):
|
||||
volume += (
|
||||
contained_particles_state.get_value(system).n_in_volume
|
||||
* 3.1415
|
||||
* math.pi
|
||||
* (system.particle_radius**3)
|
||||
* 4
|
||||
/ 3
|
||||
|
@ -1796,7 +1797,7 @@ class RecipeRule(BaseTransitionRule):
|
|||
# Remove the particles that are involved in this execution
|
||||
for system_name, particle_idxs in execution_info["relevant_systems"].items():
|
||||
system = get_system(system_name)
|
||||
volume += len(particle_idxs) * 3.1415 * (system.particle_radius**3) * 4 / 3
|
||||
volume += len(particle_idxs) * math.pi * (system.particle_radius**3) * 4 / 3
|
||||
system.remove_particles(idxs=th.Tensor(list(particle_idxs)))
|
||||
|
||||
if not cls.is_multi_instance:
|
||||
|
@ -1869,7 +1870,7 @@ class RecipeRule(BaseTransitionRule):
|
|||
# When ignore_nonrecipe_objects is True, we don't necessarily remove all objects in the container.
|
||||
# Therefore, we need to check for contact when generating output systems.
|
||||
check_contact=cls.ignore_nonrecipe_objects,
|
||||
max_samples=int(volume / (3.1415 * (out_system.particle_radius**3) * 4 / 3)),
|
||||
max_samples=int(volume / (math.pi * (out_system.particle_radius**3) * 4 / 3)),
|
||||
)
|
||||
|
||||
# Return transition results
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import random
|
||||
from math import ceil
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
from scipy.spatial.transform import Rotation as R
|
||||
|
@ -38,7 +38,7 @@ def get_grasp_poses_for_object_sticky(target_obj):
|
|||
towards_object_in_world_frame = bbox_center_in_world - grasp_center_pos
|
||||
towards_object_in_world_frame /= th.norm(towards_object_in_world_frame)
|
||||
|
||||
grasp_quat = T.euler2quat([0, 3.1415 / 2, 0])
|
||||
grasp_quat = T.euler2quat([0, math.pi / 2, 0])
|
||||
|
||||
grasp_pose = (grasp_center_pos, grasp_quat)
|
||||
grasp_candidate = [(grasp_pose, towards_object_in_world_frame)]
|
||||
|
@ -424,7 +424,7 @@ def grasp_position_for_open_on_revolute_joint(robot, target_obj, relevant_joint,
|
|||
|
||||
# Get the arc length and divide it up to 10cm segments
|
||||
arc_length = abs(required_yaw_change) * th.norm(grasp_pose_in_origin_frame[0])
|
||||
turn_steps = int(ceil(arc_length / m.ROTATION_ARC_SEGMENT_LENGTHS))
|
||||
turn_steps = int(math.ceil(arc_length / m.ROTATION_ARC_SEGMENT_LENGTHS))
|
||||
targets = []
|
||||
|
||||
for i in range(turn_steps):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import heapq
|
||||
from math import ceil
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -27,7 +27,7 @@ def _wrap_angle(theta):
|
|||
Returns:
|
||||
float: angle in radians in range [-pi, pi)
|
||||
"""
|
||||
return (theta + 3.1415) % (2 * 3.1415) - 3.1415
|
||||
return (theta + math.pi) % (2 * math.pi) - math.pi
|
||||
|
||||
|
||||
def plan_base_motion(
|
||||
|
@ -72,7 +72,7 @@ def plan_base_motion(
|
|||
|
||||
# Navigation
|
||||
dist = th.norm(goal[:2] - start[:2])
|
||||
num_points = ceil(dist / m.DIST_DIFF) + 1
|
||||
num_points = math.ceil(dist / m.DIST_DIFF) + 1
|
||||
nav_x = th.linspace(start[0], goal[0], num_points).tolist()
|
||||
nav_y = th.linspace(start[1], goal[1], num_points).tolist()
|
||||
for i in range(num_points):
|
||||
|
@ -91,7 +91,7 @@ def plan_base_motion(
|
|||
diff = _wrap_angle(final_orientation - start_conf[2])
|
||||
direction = th.sign(diff)
|
||||
diff = abs(diff)
|
||||
num_points = ceil(diff / m.ANGLE_DIFF) + 1
|
||||
num_points = math.ceil(diff / m.ANGLE_DIFF) + 1
|
||||
nav_angle = th.linspace(0.0, diff, num_points) * direction
|
||||
angles = nav_angle + start_conf[2]
|
||||
for i in range(num_points):
|
||||
|
@ -391,8 +391,8 @@ def plan_arm_motion_ik(
|
|||
|
||||
# # set lower and upper bounds for eef orientation (axis angle bounds)
|
||||
for i in range(3, 6):
|
||||
bounds.setLow(i, -3.1415)
|
||||
bounds.setHigh(i, 3.1415)
|
||||
bounds.setLow(i, -math.pi)
|
||||
bounds.setHigh(i, math.pi)
|
||||
space.setBounds(bounds)
|
||||
|
||||
# create a simple setup object
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import cv2
|
||||
import torch as th
|
||||
from IPython import embed
|
||||
from scipy.spatial import ConvexHull, distance_matrix
|
||||
from scipy.spatial.transform import Rotation as R
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -297,7 +297,7 @@ def sample_cloth_on_rigid(obj, other, max_trials=40, z_offset=0.05, randomize_xy
|
|||
# Sample a random position
|
||||
pos = th.rand(low.size()) * (high - low) + low
|
||||
# Sample a random orientation in the z-axis
|
||||
z_lo, z_hi = 0, 3.1415 * 2
|
||||
z_lo, z_hi = 0, math.pi * 2
|
||||
orn = T.euler2quat(th.Tensor([0.0, 0.0, (th.rand(1) * (z_hi - z_lo) + z_lo).item()]))
|
||||
|
||||
obj.set_position_orientation(pos, orn)
|
||||
|
|
|
@ -2,6 +2,7 @@ import itertools
|
|||
import random
|
||||
import time
|
||||
from collections import Counter, defaultdict
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
import trimesh
|
||||
|
@ -24,7 +25,7 @@ m.DEBUG_SAMPLING = False
|
|||
m.DEFAULT_AABB_OFFSET_FRACTION = 0.02
|
||||
m.DEFAULT_PARALLEL_RAY_NORMAL_ANGLE_TOLERANCE = 1.0 # Around 60 degrees
|
||||
m.DEFAULT_HIT_TO_PLANE_THRESHOLD = 0.05
|
||||
m.DEFAULT_MAX_ANGLE_WITH_Z_AXIS = 3 * 3.1415 / 4
|
||||
m.DEFAULT_MAX_ANGLE_WITH_Z_AXIS = 3 * math.pi / 4
|
||||
m.DEFAULT_MAX_SAMPLING_ATTEMPTS = 10
|
||||
m.DEFAULT_CUBOID_BOTTOM_PADDING = 0.005
|
||||
# We will cast an additional parallel ray for each additional this much distance.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from collections import namedtuple
|
||||
from collections.abc import Iterable
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -359,7 +360,7 @@ def land_object(obj, pos, quat=None, z_offset=None):
|
|||
assert og.sim.is_playing(), "Cannot land object while sim is not playing!"
|
||||
|
||||
# Set the object's pose
|
||||
quat_lo, quat_hi = 0, 3.1415 * 2
|
||||
quat_lo, quat_hi = 0, math.pi * 2
|
||||
quat = T.euler2quat([0, 0, (th.rand(1) * (quat_hi - quat_lo) + quat_lo).item()]) if quat is None else quat
|
||||
place_base_pose(obj, pos, quat, z_offset)
|
||||
obj.keep_still()
|
||||
|
|
|
@ -9,7 +9,7 @@ import math
|
|||
import torch as th
|
||||
from scipy.spatial.transform import Rotation as R
|
||||
|
||||
PI = 3.1415
|
||||
PI = math.pi
|
||||
EPS = th.finfo(th.float32).eps * 4.0
|
||||
|
||||
# axis sequences for Euler angles
|
||||
|
@ -319,7 +319,7 @@ def random_axis_angle(angle_limit=None, random_state=None):
|
|||
AssertionError: [Invalid RNG]
|
||||
"""
|
||||
if angle_limit is None:
|
||||
angle_limit = 2.0 * 3.1415
|
||||
angle_limit = 2.0 * math.pi
|
||||
|
||||
if random_state is not None:
|
||||
assert isinstance(random_state, th.Generator)
|
||||
|
@ -1096,7 +1096,7 @@ def perspective(fovy, aspect, znear, zfar):
|
|||
"""Create perspective projection matrix."""
|
||||
# fovy is in degree
|
||||
assert znear != zfar
|
||||
h = th.tan(fovy / 360.0 * 3.1415) * znear
|
||||
h = th.tan(fovy / 360.0 * math.pi) * znear
|
||||
w = h * aspect
|
||||
return frustum(-w, w, -h, h, znear, zfar)
|
||||
|
||||
|
@ -1120,11 +1120,11 @@ def cartesian_to_polar(x, y):
|
|||
|
||||
|
||||
def deg2rad(deg):
|
||||
return deg * 3.1415 / 180.0
|
||||
return deg * math.pi / 180.0
|
||||
|
||||
|
||||
def rad2deg(rad):
|
||||
return rad * 180.0 / 3.1415
|
||||
return rad * 180.0 / math.pi
|
||||
|
||||
|
||||
def check_quat_right_angle(quat, atol=5e-2):
|
||||
|
|
|
@ -8,6 +8,7 @@ import logging
|
|||
import random
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import math
|
||||
|
||||
import imageio
|
||||
import torch as th
|
||||
|
@ -487,7 +488,7 @@ class CameraMover:
|
|||
pan_angle = th.arctan2(-xy_direction[0], xy_direction[1])
|
||||
tilt_angle = th.arcsin(z)
|
||||
# Infer global quat orientation from these angles
|
||||
quat = T.euler2quat([3.1415 / 2 + tilt_angle, 0.0, pan_angle])
|
||||
quat = T.euler2quat([math.pi / 2 + tilt_angle, 0.0, pan_angle])
|
||||
poses.append([positions[j], quat])
|
||||
|
||||
# Record the generated trajectory
|
||||
|
|
|
@ -642,7 +642,7 @@ class FlatcacheAPI:
|
|||
for joint, joint_pos in zip(prim.joints.values(), joints_pos):
|
||||
state_name = "linear" if joint.joint_type == JointType.JOINT_PRISMATIC else "angular"
|
||||
joint_pos = (
|
||||
joint_pos if joint.joint_type == JointType.JOINT_PRISMATIC else joint_pos * 180.0 / 3.1415
|
||||
joint_pos if joint.joint_type == JointType.JOINT_PRISMATIC else joint_pos * 180.0 / math.pi
|
||||
)
|
||||
joint.set_attribute(f"state:{state_name}:physics:position", float(joint_pos))
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import argparse
|
|||
import json
|
||||
import os
|
||||
import time
|
||||
import math
|
||||
|
||||
import torch as th
|
||||
|
||||
|
@ -143,7 +144,7 @@ def main():
|
|||
for n, knife in enumerate(knifes):
|
||||
knife.set_position_orientation(
|
||||
position=apples[n].get_position() + th.Tensor([-0.15, 0.0, 0.1 * (n + 2)]),
|
||||
orientation=T.euler2quat([-3.1415 / 2, 0, 0]),
|
||||
orientation=T.euler2quat([-math.pi / 2, 0, 0]),
|
||||
)
|
||||
knife.keep_still()
|
||||
if args.fluids:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
import torch as th
|
||||
from utils import SYSTEM_EXAMPLES, get_random_pose, og_test, place_obj_on_floor_plane, place_objA_on_objB_bbox
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -313,7 +314,7 @@ def test_temperature(env):
|
|||
assert dishtowel.states[Temperature].get_value() == m.object_states.temperature.DEFAULT_TEMPERATURE
|
||||
|
||||
# Open the microwave
|
||||
microwave.joints["j_link_0"].set_pos(3.1415 / 2)
|
||||
microwave.joints["j_link_0"].set_pos(math.pi / 2)
|
||||
|
||||
# Set the objects to be inside the microwave
|
||||
bagel.set_position_orientation([0, 0, 0.11], [0, 0, 0, 1])
|
||||
|
@ -453,7 +454,7 @@ def test_heat_source_or_sink(env):
|
|||
assert microwave.states[HeatSourceOrSink].requires_closed
|
||||
assert microwave.states[HeatSourceOrSink].requires_toggled_on
|
||||
|
||||
microwave.joints["j_link_0"].set_pos(3.1415 / 2)
|
||||
microwave.joints["j_link_0"].set_pos(math.pi / 2)
|
||||
microwave.states[ToggledOn].set_value(False)
|
||||
|
||||
og.sim.step()
|
||||
|
@ -471,7 +472,7 @@ def test_heat_source_or_sink(env):
|
|||
assert fridge.states[HeatSourceOrSink].requires_closed
|
||||
assert not fridge.states[HeatSourceOrSink].requires_toggled_on
|
||||
|
||||
fridge.joints["j_link_0"].set_pos(3.1415 / 2)
|
||||
fridge.joints["j_link_0"].set_pos(math.pi / 2)
|
||||
|
||||
og.sim.step()
|
||||
assert not fridge.states[HeatSourceOrSink].get_value()
|
||||
|
@ -641,7 +642,7 @@ def test_toggled_on(env):
|
|||
stove = env.scene.object_registry("name", "stove")
|
||||
robot = env.scene.object_registry("name", "robot0")
|
||||
|
||||
stove.set_position_orientation([1.48, 0.3, 0.443], T.euler2quat([0, 0, -3.1415 / 2.0]))
|
||||
stove.set_position_orientation([1.48, 0.3, 0.443], T.euler2quat([0, 0, -math.pi / 2.0]))
|
||||
robot.set_position_orientation([0.0, 0.38, 0.0], [0, 0, 0, 1])
|
||||
|
||||
assert not stove.states[ToggledOn].get_value()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
import torch as th
|
||||
from utils import SYSTEM_EXAMPLES, og_test, place_obj_on_floor_plane
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -14,7 +15,7 @@ def test_seg(env):
|
|||
robot = env.scene.robots[0]
|
||||
place_obj_on_floor_plane(breakfast_table)
|
||||
dishtowel.set_position_orientation([-0.4, 0.0, 0.55], [0, 0, 0, 1])
|
||||
robot.set_position_orientation([0, 0.8, 0.0], T.euler2quat([0, 0, -3.1415 / 2]))
|
||||
robot.set_position_orientation([0, 0.8, 0.0], T.euler2quat([0, 0, -math.pi / 2]))
|
||||
robot.reset()
|
||||
|
||||
systems = [env.scene.get_system(system_name) for system_name in SYSTEM_EXAMPLES.keys()]
|
||||
|
|
|
@ -9,6 +9,7 @@ from utils import (
|
|||
remove_all_systems,
|
||||
retrieve_obj_cfg,
|
||||
)
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -96,7 +97,7 @@ def test_washer_rule(env):
|
|||
|
||||
# Place the two objects inside the washer
|
||||
# (Hacky) use baking_sheet as a stepping stone to elevate the objects so that they are inside the container volume.
|
||||
baking_sheet.set_position_orientation([0.0, 0.0, 0.04], T.euler2quat([3.1415, 0, 0]))
|
||||
baking_sheet.set_position_orientation([0.0, 0.0, 0.04], T.euler2quat([math.pi, 0, 0]))
|
||||
remover_dishtowel.set_position_orientation([0.0, 0.0, 0.05], [0, 0, 0, 1])
|
||||
bowl.set_position_orientation([0.10, 0.0, 0.08], [0, 0, 0, 1])
|
||||
og.sim.step()
|
||||
|
@ -161,7 +162,7 @@ def test_slicing_rule(env):
|
|||
place_obj_on_floor_plane(apple)
|
||||
og.sim.step()
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
assert not table_knife.states[Touching].get_value(apple)
|
||||
final_half_apples = env.scene.object_registry("category", "half_apple", set()).copy()
|
||||
|
@ -169,7 +170,7 @@ def test_slicing_rule(env):
|
|||
for obj in deleted_objs:
|
||||
assert env.scene.object_registry("name", obj.name) is not None
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.10], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.10], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
final_half_apples = env.scene.object_registry("category", "half_apple", set()).copy()
|
||||
assert len(final_half_apples) > len(initial_half_apples)
|
||||
|
@ -204,7 +205,7 @@ def test_dicing_rule_cooked(env):
|
|||
deleted_objs = [half_apple]
|
||||
deleted_objs_cfg = [retrieve_obj_cfg(obj) for obj in deleted_objs]
|
||||
|
||||
half_apple.set_orientation(T.euler2quat([0, -3.1415 / 2, 0]))
|
||||
half_apple.set_orientation(T.euler2quat([0, -math.pi / 2, 0]))
|
||||
place_obj_on_floor_plane(half_apple)
|
||||
og.sim.step()
|
||||
|
||||
|
@ -212,7 +213,7 @@ def test_dicing_rule_cooked(env):
|
|||
|
||||
assert cooked_diced_apple.n_particles == 0
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
assert not table_knife.states[Touching].get_value(half_apple)
|
||||
|
@ -220,7 +221,7 @@ def test_dicing_rule_cooked(env):
|
|||
for obj in deleted_objs:
|
||||
assert env.scene.object_registry("name", obj.name) is not None
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.07], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.07], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
assert cooked_diced_apple.n_particles > 0
|
||||
|
@ -228,7 +229,7 @@ def test_dicing_rule_cooked(env):
|
|||
assert env.scene.object_registry("name", obj.name) is None
|
||||
|
||||
# Move the knife away so that it doesn't immediately dice the half_apple again once it's imported back
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 1.15], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 1.15], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
# Clean up
|
||||
|
@ -250,13 +251,13 @@ def test_dicing_rule_uncooked(env):
|
|||
deleted_objs = [half_apple]
|
||||
deleted_objs_cfg = [retrieve_obj_cfg(obj) for obj in deleted_objs]
|
||||
|
||||
half_apple.set_orientation(T.euler2quat([0, -3.1415 / 2, 0]))
|
||||
half_apple.set_orientation(T.euler2quat([0, -math.pi / 2, 0]))
|
||||
place_obj_on_floor_plane(half_apple)
|
||||
og.sim.step()
|
||||
|
||||
assert diced_apple.n_particles == 0
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.15], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
assert not table_knife.states[Touching].get_value(half_apple)
|
||||
|
@ -264,7 +265,7 @@ def test_dicing_rule_uncooked(env):
|
|||
for obj in deleted_objs:
|
||||
assert env.scene.object_registry("name", obj.name) is not None
|
||||
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.07], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 0.07], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
assert diced_apple.n_particles > 0
|
||||
|
@ -272,7 +273,7 @@ def test_dicing_rule_uncooked(env):
|
|||
assert env.scene.object_registry("name", obj.name) is None
|
||||
|
||||
# Move the knife away so that it doesn't immediately dice the half_apple again once it's imported back
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 1.15], T.euler2quat([-3.1415 / 2, 0, 0]))
|
||||
table_knife.set_position_orientation([-0.05, 0.0, 1.15], T.euler2quat([-math.pi / 2, 0, 0]))
|
||||
og.sim.step()
|
||||
|
||||
# Clean up
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import torch as th
|
||||
import math
|
||||
|
||||
import omnigibson as og
|
||||
import omnigibson.utils.transform_utils as T
|
||||
|
@ -205,7 +206,7 @@ def assert_test_env():
|
|||
|
||||
def get_random_pose(pos_low=10.0, pos_hi=20.0):
|
||||
pos = th.rand(3) * (pos_hi - pos_low) + pos_low
|
||||
ori_lo, ori_hi = -3.1415, 3.1415
|
||||
ori_lo, ori_hi = -math.pi, math.pi
|
||||
orn = T.euler2quat(th.rand(3) * (ori_hi - ori_lo) + ori_lo)
|
||||
return pos, orn
|
||||
|
||||
|
|
Loading…
Reference in New Issue