repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
USCL | USCL-main/train_USCL/simclr.py | import torch
from models.resnet_simclr import ResNetSimCLR
# from torch.utils.tensorboard import SummaryWriter
import torch.nn.functional as F
from loss.nt_xent import NTXentLoss
import os
import shutil
import sys
import time
import torch.nn as nn
apex_support = False
try:
sys.path.append('./apex')
from apex i... | 8,478 | 37.716895 | 127 | py |
USCL | USCL-main/train_USCL/run.py | from simclr import SimCLR
import yaml
import random
import numpy as np
import math
from data_aug.dataset_wrapper_Ultrasound_Video_Mixup import DataSetWrapper # Video_Mixup
def main():
# Totalcases = 1051 # US-4
# Totalcases = 63 # CLUST
# Totalcases = 296 # Liver
Totalcases = 22 ... | 1,352 | 33.692308 | 116 | py |
USCL | USCL-main/train_USCL/linear_eval.py | import os
import yaml
import pickle
import torch
import numpy as np
from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LogisticRegression
from sklearn import preprocessing
import importlib.util
##################################### 设定 ####################################
fold = 1
self_... | 4,071 | 26.890411 | 104 | py |
USCL | USCL-main/train_USCL/NMI_loss.py | # -*- coding:utf-8 -*-
'''
Created on 2017年10月28日
@summary: 利用Python实现NMI计算
@author: dreamhome
'''
import math
import numpy as np
from sklearn import metrics
import time
import random
import torch
def MILoss(TensorA=None, TensorB=None):
# TensorA, TensorB = range(112*512*7*7), range(112*512*7*7)
#
# Tens... | 2,477 | 29.219512 | 100 | py |
USCL | USCL-main/train_USCL/models/model_resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.nn import init
from .cbam import *
from .bam import *
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet18_cbam', 'resnet34_cbam', 'resnet50_cbam', 'resnet101_cbam',
'resnet152_cbam']
model_urls =... | 10,063 | 32.658863 | 119 | py |
USCL | USCL-main/train_USCL/models/resnet_simclr.py | import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
from .model_resnet import resnet18_cbam, resnet50_cbam
class ResNetSimCLR(nn.Module):
''' The ResNet feature extractor + projection head for SimCLR '''
def __init__(self, base_model, out_dim, pretrained=False):
... | 2,664 | 31.108434 | 101 | py |
USCL | USCL-main/train_USCL/models/bam.py | import torch
import math
import torch.nn as nn
import torch.nn.functional as F
class Flatten(nn.Module):
def forward(self, x):
return x.view(x.size(0), -1)
class ChannelGate(nn.Module):
def __init__(self, gate_channel, reduction_ratio=16, num_layers=1):
super(ChannelGate, self).__init__()
... | 2,729 | 53.6 | 147 | py |
USCL | USCL-main/train_USCL/models/cbam.py | import torch
import math
import torch.nn as nn
import torch.nn.functional as F
class BasicConv(nn.Module):
def __init__(self, in_planes, out_planes, kernel_size, stride=1, padding=0, dilation=1, groups=1, relu=True, bn=True, bias=False):
super(BasicConv, self).__init__()
self.out_channels = out_pla... | 4,038 | 37.836538 | 154 | py |
USCL | USCL-main/train_USCL/models/baseline_encoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
class Encoder(nn.Module):
''' The 4 layer convolutional network backbone + 2 layer fc projection head '''
def __init__(self, out_dim=64):
super(Encoder, self).__init__()
self.conv1 = nn.Conv... | 1,184 | 24.76087 | 83 | py |
USCL | USCL-main/train_USCL/loss/nt_xent.py | import torch
import numpy as np
class NTXentLoss(torch.nn.Module):
def __init__(self, device, batch_size, temperature, use_cosine_similarity):
super(NTXentLoss, self).__init__()
self.batch_size = batch_size
self.temperature = temperature
self.device = device
self.softmax =... | 3,708 | 41.147727 | 130 | py |
USCL | USCL-main/train_USCL/data_aug/outpainting.py | import torch
import numpy as np
import random
class Outpainting(object):
"""Randomly mask out one or more patches from an image, we only need mask regions.
Args:
n_holes (int): Number of patches to cut out of each image.
length (int): The length (in pixels) of each square patch.
"""
def... | 1,491 | 33.697674 | 100 | py |
USCL | USCL-main/train_USCL/data_aug/sharpen.py | import torch
import numpy as np
from PIL import Image
from PIL import ImageFilter
class Sharpen(object):
""" Sharpen an image before inputing it to networks
Args:
degree (int): The sharpen intensity, from -1 to 5.
0 represents original image.
"""
def __init__(self, degree=0... | 2,260 | 34.888889 | 80 | py |
USCL | USCL-main/train_USCL/data_aug/dataset_wrapper_Ultrasound_Video_Mixup.py | import os
import random
from PIL import Image
import numpy as np
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
from torch.utils.data.sampler import SubsetRandomSampler
import torchvision.transforms as transforms
from data_aug.gaussian_blur import GaussianBlur
from data_aug.cutout import ... | 13,707 | 45.310811 | 167 | py |
USCL | USCL-main/train_USCL/data_aug/cutout.py | import torch
import numpy as np
class Cutout(object):
"""Randomly mask out one or more patches from an image.
Args:
n_holes (int): Number of patches to cut out of each image.
length (int): The length (in pixels) of each square patch.
"""
def __init__(self, n_holes, length):
sel... | 1,213 | 26.590909 | 84 | py |
USCL | USCL-main/train_USCL/data_aug/nonlin_trans.py | from __future__ import print_function
import random
import numpy as np
import torch
try: # SciPy >= 0.19
from scipy.special import comb
except ImportError:
from scipy.misc import comb
def bernstein_poly(i, n, t):
"""
The Bernstein polynomial of n, i as a function of t
"""
return comb(n, i) ... | 2,817 | 25.584906 | 101 | py |
USCL | USCL-main/train_USCL/data_aug/gaussian_blur.py | import cv2
import numpy as np
np.random.seed(0)
class GaussianBlur(object):
# Implements Gaussian blur as described in the SimCLR paper
def __init__(self, kernel_size, min=0.1, max=2.0):
self.min = min
self.max = max
# kernel size is set to be 5% of the image height/width
self... | 827 | 29.666667 | 90 | py |
USCL | USCL-main/eval_pretrained_model/eval_pretrained_model.py | import os
import sys
import time
import random
import argparse
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
import torch.optim as optim
from tools.my_dataset import COVIDDataset
from resnet_uscl import ResNetUSCL
apex_support... | 12,878 | 42.218121 | 136 | py |
USCL | USCL-main/eval_pretrained_model/resnet_uscl.py | import torch.nn as nn
import torchvision.models as models
class ResNetUSCL(nn.Module):
''' The ResNet feature extractor + projection head + classifier for USCL '''
def __init__(self, base_model, out_dim, pretrained=False):
super(ResNetUSCL, self).__init__()
self.resnet_dict = {"resnet18": mod... | 1,383 | 30.454545 | 101 | py |
USCL | USCL-main/eval_pretrained_model/tools/my_dataset.py | import os
import random
import pickle
from PIL import Image
from torch.utils.data import Dataset
random.seed(1)
class COVIDDataset(Dataset):
def __init__(self, data_dir, train=True, transform=None):
"""
POCUS Dataset
param data_dir: str
param transform: torch.transform
... | 1,079 | 29 | 77 | py |
Autopilot-TensorFlow | Autopilot-TensorFlow-master/model.py | import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import scipy
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial)
def conv2d(x, W, stride):
return tf.... | 2,265 | 24.177778 | 88 | py |
Autopilot-TensorFlow | Autopilot-TensorFlow-master/run.py | import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import model
import cv2
from subprocess import call
import os
#check if on windows OS
windows = False
if os.name == 'nt':
windows = True
sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore(sess, "save/model.ckpt")
img = cv2.imread('stee... | 1,236 | 29.925 | 136 | py |
Autopilot-TensorFlow | Autopilot-TensorFlow-master/run_dataset.py | import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import model
import cv2
from subprocess import call
import os
#check if on windows OS
windows = False
if os.name == 'nt':
windows = True
sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore(sess, "save/model.ckpt")
img = cv2.imread('stee... | 1,270 | 30.775 | 136 | py |
Autopilot-TensorFlow | Autopilot-TensorFlow-master/train.py | import os
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from tensorflow.core.protobuf import saver_pb2
import driving_data
import model
LOGDIR = './save'
sess = tf.InteractiveSession()
L2NormConst = 0.001
train_vars = tf.trainable_variables()
loss = tf.reduce_mean(tf.square(tf.subtract(model.y_, model... | 2,006 | 33.603448 | 129 | py |
Autopilot-TensorFlow | Autopilot-TensorFlow-master/driving_data.py | import cv2
import random
import numpy as np
xs = []
ys = []
#points to the end of the last batch
train_batch_pointer = 0
val_batch_pointer = 0
#read data.txt
with open("driving_dataset/data.txt") as f:
for line in f:
xs.append("driving_dataset/" + line.split()[0])
#the paper by Nvidia uses the in... | 1,668 | 28.280702 | 126 | py |
real-robot-challenge | real-robot-challenge-main/setup.py | from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=["code", "pybullet_planning"],
package_dir={"": "python"},
)
setup(**d)
| 215 | 20.6 | 60 | py |
real-robot-challenge | real-robot-challenge-main/python/code/align_rotation.py | import numpy as np
from scipy.spatial.transform import Rotation as R
def project_cube_xy_plane(orientation):
rot = R.from_quat(orientation)
axes = np.eye(3)
axes_rotated = rot.apply(axes)
# calculate the angle between each rotated axis and xy plane
cos = axes_rotated[:, 2] # dot product with z_a... | 4,330 | 28.263514 | 82 | py |
real-robot-challenge | real-robot-challenge-main/python/code/const.py | #!/usr/bin/env python3
import numpy as np
from trifinger_simulation.tasks import move_cube
from trifinger_simulation.trifinger_platform import TriFingerPlatform
COLLISION_TOLERANCE = 3.5 * 1e-03
MU = 0.5
CUBOID_SIZE = move_cube._CUBOID_SIZE
CUBOID_HALF_SIZE = move_cube._CUBOID_HALF_SIZE
CUBOID_MASS = 0.016
VIRTUAL_CUB... | 1,257 | 38.3125 | 100 | py |
real-robot-challenge | real-robot-challenge-main/python/code/state_machine.py | from code.env.cube_env import ActionType
from code.const import INIT_JOINT_CONF, CONTRACTED_JOINT_CONF, AVG_POSE_STEPS
from code.utils import action_type_to, frameskip_to, Transform
from code.utils import get_yaw_diff, estimate_object_pose, get_rotation_between_vecs
from code.action_sequences import ScriptedActions
fro... | 17,527 | 40.535545 | 123 | py |
real-robot-challenge | real-robot-challenge-main/python/code/action_sequences.py | #!/usr/bin/env python3
from code.utils import frameskip_to, action_type_to, repeat, get_yaw_diff
from code.const import TRANSLU_CYAN, CUBOID_SIZE, INIT_JOINT_CONF
from code.align_rotation import project_cube_xy_plane
from code.env.cube_env import ActionType
from scipy.spatial.transform import Rotation as R
import numpy... | 10,330 | 40.48996 | 93 | py |
real-robot-challenge | real-robot-challenge-main/python/code/utils.py | import random
import numpy as np
import pybullet as p
from scipy.spatial.transform import Rotation
import time
def set_seed(seed=0):
import random
import numpy as np
random.seed(seed)
np.random.seed(seed)
def get_rotation_between_vecs(v1, v2):
"""Rotation from v1 to v2."""
v1 = v1 / np.linal... | 16,789 | 32.850806 | 109 | py |
real-robot-challenge | real-robot-challenge-main/python/code/make_env.py | from code.env.cube_env import RealRobotCubeEnv, ActionType
from code import wrappers
def get_initializer(name):
from code.env import initializers
if name is None:
return None
if hasattr(initializers, name):
return getattr(initializers, name)
else:
raise ValueError(f"Can't find ... | 2,848 | 36 | 96 | py |
real-robot-challenge | real-robot-challenge-main/python/code/wrappers.py | """Gym environment for the Real Robot Challenge Phase 1 (Simulation)."""
import pybullet as p
import numpy as np
import gym
from trifinger_simulation import camera
import cv2
EXCEP_MSSG = "================= captured exception =================\n" + \
"{message}\n" + "{error}\n" + '================================... | 5,635 | 43.377953 | 116 | py |
real-robot-challenge | real-robot-challenge-main/python/code/__init__.py | 0 | 0 | 0 | py | |
real-robot-challenge | real-robot-challenge-main/python/code/base_policies/fc.py | #!/usr/bin/env python3
import numpy as np
import pybullet as p
from trifinger_simulation import TriFingerPlatform
class ZeroTorquePolicy(object):
def __call__(self, *args, **kwargs):
return np.zeros(9)
class CancelGravityPolicy(object):
def __init__(self, env):
self.id = env.platform.simfing... | 763 | 32.217391 | 72 | py |
real-robot-challenge | real-robot-challenge-main/python/code/base_policies/__init__.py | from .fc import ZeroTorquePolicy, CancelGravityPolicy
from .mpfc import PlanningAndForceControlPolicy
| 102 | 33.333333 | 53 | py |
real-robot-challenge | real-robot-challenge-main/python/code/base_policies/mpfc.py | #!/usr/bin/env python3
import pybullet as p
import numpy as np
from code.utils import get_rotation_between_vecs, slerp, Transform
from trifinger_simulation import TriFingerPlatform
from scipy.spatial.transform import Rotation
DEBUG = False
if DEBUG:
color_set = ((1, 0, 0, 0.5), (0, 1, 0, 0.5), (0, 0, 1, 0.5))
cl... | 6,893 | 40.781818 | 139 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/grasp_sampling.py | #!/usr/bin/env python3
from code.utils import Transform, keep_state
from code.const import MU, VIRTUAL_CUBOID_HALF_SIZE, INIT_JOINT_CONF
from .ik import IKUtils
from .force_closure import CuboidForceClosureTest, CoulombFriction
import itertools
import numpy as np
class Grasp(object):
def __init__(self, cube_tip_p... | 16,496 | 35.66 | 116 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/collision_config.py | #!/usr/bin/env python3
from code.const import COLLISION_TOLERANCE
workspace_id = 0
class CollisionConfig:
def __init__(self, env):
self.env = env
self.finger_id = env.platform.simfinger.finger_id
self.tip_ids = env.platform.simfinger.pybullet_tip_link_indices
self.link_ids = env.pla... | 2,484 | 42.596491 | 87 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/wholebody_planning.py | #!/usr/bin/env python3
import pybullet as p
import numpy as np
import time
from code.utils import Transform, filter_none_elements, repeat
from pybullet_planning import plan_wholebody_motion
from collections import namedtuple
from trifinger_simulation.tasks.move_cube import _ARENA_RADIUS, _min_height, _max_height
from c... | 10,705 | 41.995984 | 156 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/force_closure.py | import numpy as np
from scipy.spatial import Delaunay
from scipy.spatial.qhull import QhullError
from code.utils import Transform, get_rotation_between_vecs
class FrictionModel:
def wrench_basis(self):
pass
def is_valid(self, wrench):
pass
def approximate_cone(self, contacts):
pa... | 4,210 | 31.145038 | 77 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/__init__.py | from .grasp_functions import *
from .grasp_motions import execute_grasp_approach
from .collision_config import CollisionConfig
| 127 | 31 | 49 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/grasp_functions.py | from code.grasping.grasp_sampling import GraspSampler
from code.grasping.wholebody_planning import WholeBodyPlanner
from code.const import VIRTUAL_CUBOID_HALF_SIZE
from code.align_rotation import align_z, project_cube_xy_plane
from scipy.spatial.transform import Rotation as R
import copy
import numpy as np
def get_he... | 3,538 | 37.467391 | 110 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/grasp_motions.py | from .ik import IKUtils
from code.action_sequences import ScriptedActions
from code.const import INIT_JOINT_CONF
import numpy as np
def execute_grasp_approach(env, obs, grasp):
action_sequence = ScriptedActions(env, obs['robot_tip_positions'], grasp)
pregrasp_joint_conf, pregrasp_tip_pos = get_safe_pregrasp(
... | 3,127 | 37.146341 | 84 | py |
real-robot-challenge | real-robot-challenge-main/python/code/grasping/ik.py | from code.utils import keep_state
from code.const import INIT_JOINT_CONF
import numpy as np
class IKUtils:
def __init__(self, env, yawing_grasp=False):
self.fk = env.pinocchio_utils.forward_kinematics
self.ik = env.pinocchio_utils.inverse_kinematics
self.finger_id = env.platform.simfinger.... | 6,040 | 39.543624 | 132 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/initializers.py | """Place initializers here.
These will be passed as an arguement to the training env, allowing us to
easily try out different cube initializations (i.e. for cirriculum learning).
"""
import os
from collections import namedtuple
from trifinger_simulation.tasks import move_cube
from trifinger_simulation.tasks.move_cube... | 8,271 | 37.119816 | 164 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/pinocchio_utils.py | import numpy as np
import pinocchio
class PinocchioUtils:
"""
Consists of kinematic methods for the finger platform.
"""
def __init__(self):
"""
Initializes the finger model on which control's to be performed.
"""
self.urdf_path = '/opt/blmc_ei/src/robot_properties_fi... | 6,137 | 36.2 | 95 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/cube_env.py | """Gym environment for the Real Robot Challenge Phase 1 (Simulation)."""
import os
import enum
import shelve
import gym
import numpy as np
import robot_interfaces
import robot_fingers
import trifinger_simulation
import trifinger_simulation.visual_objects
from trifinger_simulation import trifingerpro_limits
from trifi... | 16,706 | 37.944056 | 111 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/termination_fns.py | import numpy as np
from scipy.spatial.transform import Rotation
def no_termination(observation):
return False
def position_close_to_goal(observation):
dist_to_goal = np.linalg.norm(
observation["desired_goal"]["position"]
- observation["achieved_goal"]["position"]
)
return dist_to_go... | 1,509 | 29.2 | 93 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/viz.py | from code.utils import Transform, get_rotation_between_vecs
from scipy.spatial.transform import Rotation as R
import numpy as np
import pybullet as p
class VisualMarkers:
'''Visualize spheres on the specified points'''
def __init__(self):
self.markers = []
def add(self, points, radius=0.015, col... | 7,319 | 32.272727 | 99 | py |
real-robot-challenge | real-robot-challenge-main/python/code/env/__init__.py | 0 | 0 | 0 | py | |
real-robot-challenge | real-robot-challenge-main/python/code/env/reward_fns.py | """Place reward functions here.
These will be passed as an arguement to the training env, allowing us to
easily try out new reward functions.
"""
import numpy as np
from trifinger_simulation.tasks import move_cube
from scipy.spatial.transform import Rotation
###############################
# Competition Reward Fun... | 3,320 | 35.097826 | 99 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/__version__.py | __title__ = 'pybullet_planning'
__description__ = 'a suite of utility functions to facilitate robotic planning related research on the pybullet physics simulation engine.'
__url__ = 'https://github.com/yijiangh/pybullet_planning'
__version__ = '0.5.0'
__author__ = 'Caelan Garrett'
__author_email__ = 'yijiangh@mit.edu' ... | 620 | 50.75 | 139 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/__init__.py | """
********************************************************************************
pybullet_planning
********************************************************************************
.. currentmodule:: pybullet_planning
This library is a suite of utility functions to facilitate robotic planning related research on t... | 954 | 31.931034 | 181 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/multi_rrt.py | from collections import Mapping
from random import random
from .rrt import TreeNode, configs
from .utils import irange, argmin, pairs, randomize, take, enum
ts = enum('ALL', 'SUCCESS', 'PATH', 'NONE')
# TODO - resample and use nearest neighbors when the tree is large
# TODO - possible bug if a node is already in the... | 5,389 | 33.33121 | 102 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/lazy_prm.py | from scipy.spatial.kdtree import KDTree
from heapq import heappush, heappop
from collections import namedtuple
from .utils import INF, elapsed_time
from .rrt_connect import direct_path
from .smoothing import smooth_path
import random
import time
import numpy as np
__all__ = [
'lazy_prm'
]
Node = namedtuple('... | 6,980 | 41.054217 | 107 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/star_roadmap.py | from collections import Mapping
#class StarRoadmap(Mapping, object):
class StarRoadmap(Mapping, object):
def __init__(self, center, planner):
self.center = center
self.planner = planner
self.roadmap = {}
"""
def __getitem__(self, q):
return self.roadmap[q]
def __len__... | 859 | 23.571429 | 64 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/utils.py | from random import shuffle
from itertools import islice
import time
INF = float('inf')
RRT_ITERATIONS = 20
RRT_RESTARTS = 2
RRT_SMOOTHING = 20
# INCR_RRT_RESTARTS = 10
INCR_RRT_ITERATIONS = 30
def irange(start, stop=None, step=1): # np.arange
if stop is None:
stop = start
start = 0
while s... | 4,538 | 25.086207 | 78 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/graph.py | from collections import namedtuple, Mapping
from heapq import heappush, heappop
class Vertex(object):
def __init__(self, value):
self.value = value
self.edges = []
def __repr__(self):
return self.__class__.__name__ + '(' + str(self.value) + ')'
class Edge(object):
def __init__... | 2,335 | 27.144578 | 101 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/rrt_connect.py | import time
from itertools import takewhile
from .smoothing import smooth_path
from .rrt import TreeNode, configs
from .utils import irange, argmin, RRT_ITERATIONS, RRT_RESTARTS, RRT_SMOOTHING, INF, elapsed_time, negate
__all__ = [
'rrt_connect',
'birrt',
'direct_path',
]
def asymmetric_extend(q1, q2... | 7,456 | 38.041885 | 153 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/rrt_star.py | from random import random
from time import time
from .utils import INF, argmin
class OptimalNode(object):
def __init__(self, config, parent=None, d=0, path=[], iteration=None):
self.config = config
self.parent = parent
self.children = set()
self.d = d
self.path = path
... | 4,382 | 33.511811 | 141 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/rrt.py | from random import random
from .utils import irange, argmin, RRT_ITERATIONS
class TreeNode(object):
def __init__(self, config, parent=None, ik_solution=None, group=None):
self.config = config
self.parent = parent
self.ik_solution = ik_solution
if group is None:
self.g... | 2,699 | 29.337079 | 140 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/discrete.py | from collections import deque
from heapq import heappop, heappush
from recordclass import recordclass
import numpy as np
from .utils import INF
Node = recordclass('Node', ['g', 'parent'])
def retrace(visited, q):
if q is None:
return []
return retrace(visited, visited[tuple(q)].parent) + [q]
def ... | 2,285 | 35.285714 | 103 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/__init__.py | """
********************************************************************************
motion_planners
********************************************************************************
.. currentmodule:: pybullet_planning.motion_planners
Python implementations of several robotic motion planners
Sampling-based:
- Proba... | 1,149 | 17.852459 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/wholebody_rrt_connect.py | import time
from random import random
from itertools import takewhile
from .smoothing import wholebody_smooth_path
from .rrt import TreeNode, configs, extract_ik_solutions
from .utils import irange, argmin, INCR_RRT_ITERATIONS, RRT_ITERATIONS, RRT_RESTARTS, RRT_SMOOTHING, INF, elapsed_time, negate
__all__ = [
'wh... | 28,124 | 43.713831 | 170 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/prm.py | from collections import namedtuple, Mapping
from heapq import heappop, heappush
import operator
from .utils import INF, pairs, merge_dicts, flatten
# TODO - Lazy-PRM, Visibility-PRM, PRM*
class Vertex(object):
def __init__(self, q):
self.q = q
self.edges = {}
self._handle = None
de... | 7,620 | 30.36214 | 147 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/motion_planners/smoothing.py | from random import randint
def smooth_path(path, extend, collision, iterations=200):
"""smooth a trajectory path, randomly replace jigged subpath with shortcuts
Parameters
----------
path : list
[description]
extend : function
[description]
collision : function
[descri... | 2,818 | 34.683544 | 125 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/shared_const.py | import numpy as np
import pybullet as p
# constants
INF = np.inf
PI = np.pi
EPS = 1e-12
CIRCULAR_LIMITS = -PI, PI
UNBOUNDED_LIMITS = -INF, INF
DEFAULT_TIME_STEP = 1./240. # seconds
# pybullet setup parameters
CLIENTS = {} # TODO: rename to include locked
CLIENT = 0
INFO_FROM_BODY = {}
# colors
RED = (1, 0, 0, 1)
GR... | 1,664 | 18.360465 | 91 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/transformations.py | # -*- coding: utf-8 -*-
# transformations.py
# Copyright (c) 2006, Christoph Gohlke
# Copyright (c) 2006-2009, The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions a... | 58,641 | 35.355859 | 79 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/file_io.py | """
file I/O
"""
import os
import pickle
import json
import datetime
from .shared_const import DATE_FORMAT
SEPARATOR = '\n' + 50*'-' + '\n'
#def inf_generator():
# return iter(int, 1)
# inf_generator = count
def print_separator(n=50):
print('\n' + n*'-' + '\n')
def read(filename):
with open(filename, 'r... | 1,655 | 19.7 | 84 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/_file_path_archived.py | import os
#####################################
# TODO: clean up these data paths
DRAKE_PATH = 'models/drake/'
# Models
# Robots
MODEL_DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'models/'))
ROOMBA_URDF = 'models/turtlebot/roomba.urdf'
TURTLEBOT_URDF = 'models/turtlebot/turtlebot_... | 1,584 | 36.738095 | 130 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/numeric_sample.py | import numpy as np
import random
from .shared_const import INF
def clip(value, min_value=-INF, max_value=+INF):
"""clamp a value
"""
return min(max(min_value, value), max_value)
def randomize(iterable): # TODO: bisect
sequence = list(iterable)
random.shuffle(sequence)
return sequence
def get... | 686 | 21.16129 | 52 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/__init__.py | """
********************************************************************************
utils
********************************************************************************
.. currentmodule:: pybullet_planning.utils
Package containing a set of utility functions and variables
File system functions
====================... | 1,091 | 16.901639 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/debug_utils.py | import os
import platform
import math
import inspect
import signal
from contextlib import contextmanager
from .shared_const import INF
def is_remote():
return 'SSH_CONNECTION' in os.environ
def is_darwin(): # TODO: change loading accordingly
return platform.system() == 'Darwin' # platform.release()
#retu... | 3,384 | 35.793478 | 120 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/utils/iter_utils.py | from itertools import cycle, islice
def implies(p1, p2):
return not p1 or p2
def roundrobin(*iterables):
"""roundrobin('ABC', 'D', 'EF') --> A D E B F C
https://docs.python.org/3.1/library/itertools.html#recipes
Recipe credited to George Sakkis
"""
pending = len(iterables)
nexts = cycle(i... | 1,022 | 25.921053 | 62 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/__init__.py | """
********************************************************************************
interfaces
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces
.. toctree::
:maxdepth: 2
pybullet_planning.interfaces.control
pybullet_planning... | 934 | 26.5 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/user_io.py | import os
import sys
import time
import numpy as np
import pybullet as p
from collections import namedtuple
from pybullet_planning.utils import INF, CLIENT, CLIENTS
from pybullet_planning.utils import is_darwin
# from future_builtins import map, filter
# from builtins import input # TODO - use future
try:
user_in... | 6,712 | 32.068966 | 128 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/savers.py | import os
import pybullet as p
from pybullet_planning.utils import CLIENT, set_client
#####################################
# Savers
# TODO: contextlib
class Saver(object):
def restore(self):
raise NotImplementedError()
def __enter__(self):
# TODO: move the saving to enter?
pass
d... | 3,449 | 29.530973 | 111 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/simulation.py | import os
from collections import namedtuple
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT, CLIENTS, GRAVITY, INFO_FROM_BODY, STATIC_MASS
from pybullet_planning.utils import is_darwin, is_windows, get_client
from pybullet_planning.interfaces.env_manager.savers import Saver
from py... | 9,866 | 38.947368 | 120 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/__init__.py | """
********************************************************************************
interfaces.env_manager
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces.env_manager
pose transformation, shape creation, and interacting with the pb envi... | 1,264 | 17.880597 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/pose_transformation.py | import math
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT, unit_vector, quaternion_from_matrix, clip, euler_from_quaternion
#####################################
# Geometry
#Pose = namedtuple('Pose', ['position', 'orientation'])
def Point(x=0., y=0., z=0.):
"""Representing a... | 7,668 | 25.444828 | 123 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/env_manager/shape_creation.py | import os
import numpy as np
import pybullet as p
from collections import defaultdict, namedtuple
from itertools import count
from pybullet_planning.utils import CLIENT, DEFAULT_EXTENTS, DEFAULT_HEIGHT, DEFAULT_RADIUS, \
DEFAULT_MESH, DEFAULT_SCALE, DEFAULT_NORMAL, BASE_LINK, INFO_FROM_BODY, STATIC_MASS, UNKNOWN_F... | 19,613 | 36.791908 | 140 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/control/control.py |
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT
from pybullet_planning.interfaces.env_manager.pose_transformation import unit_point
from pybullet_planning.interfaces.robots.joint import get_max_velocity, get_max_force, get_joint_positions, get_movable_joints, \
movable_from_join... | 7,457 | 39.313514 | 129 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/control/__init__.py | """
"""
from .control import *
__all__ = [name for name in dir() if not name.startswith('_')]
| 97 | 11.25 | 62 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/link.py | from itertools import product, combinations
from collections import defaultdict, deque, namedtuple
import pybullet as p
from pybullet_planning.utils import BASE_LINK, CLIENT
from pybullet_planning.interfaces.robots.joint import get_num_joints, get_joints, get_joint_info, is_movable, prune_fixed_joints
###############... | 9,404 | 35.312741 | 128 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/collision.py | import warnings
from collections import namedtuple
from itertools import product
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT, BASE_LINK, MAX_DISTANCE, UNKNOWN_FILE
from pybullet_planning.utils import get_client
from pybullet_planning.interfaces.env_manager.user_io import step_sim... | 23,083 | 39.216028 | 152 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/joint.py | from collections import namedtuple
import pybullet as p
from pybullet_planning.utils import CLIENT, CIRCULAR_LIMITS, UNBOUNDED_LIMITS, INF
#####################################
# Joints
JOINT_TYPES = {
p.JOINT_REVOLUTE: 'revolute', # 0
p.JOINT_PRISMATIC: 'prismatic', # 1
p.JOINT_SPHERICAL: 'spherical', #... | 7,886 | 33.592105 | 107 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/__init__.py | """
********************************************************************************
interfaces.robots
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces.robots
TODO: module description
Body
--------------
.. autosummary::
:toctree: g... | 1,116 | 15.426471 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/dynamics.py |
from collections import defaultdict, deque, namedtuple
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT, BASE_LINK, STATIC_MASS
#####################################
# https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit#
DynamicsInfo = namedtuple('D... | 3,123 | 40.653333 | 148 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/robots/body.py | import numpy as np
from collections import namedtuple
import pybullet as p
from pybullet_planning.utils import CLIENT, INFO_FROM_BODY, STATIC_MASS, BASE_LINK, OBJ_MESH_CACHE, NULL_ID
from pybullet_planning.utils import implies
from pybullet_planning.interfaces.env_manager.pose_transformation import Pose, Point, Euler
... | 14,761 | 40.466292 | 148 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/debug_utils/__init__.py | """
********************************************************************************
interfaces.debug_utils
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces.debug_utils
TODO: module description
Debug utils
--------------------
.. autosu... | 842 | 17.326087 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/debug_utils/debug_utils.py | import math
import numpy as np
import pybullet as p
from itertools import product, combinations
from pybullet_planning.utils import CLIENT, BASE_LINK, GREEN, RED, BLUE, BLACK, WHITE, NULL_ID, YELLOW
from pybullet_planning.interfaces.env_manager.pose_transformation import unit_pose, tform_point, unit_from_theta, get_d... | 9,414 | 35.634241 | 126 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/kinematics/ik_interface.py |
from pybullet_planning.interfaces.env_manager.pose_transformation import multiply, invert, quat_from_matrix, matrix_from_quat, \
point_from_pose, quat_from_pose, get_distance, unit_pose
from pybullet_planning.interfaces.robots.joint import joints_from_names, get_joint_positions, violates_limits
from pybullet_plann... | 7,171 | 34.156863 | 128 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/kinematics/ik_utils.py | import math
import numpy as np
import pybullet as p
from pybullet_planning.utils import CLIENT
def inverse_kinematics_helper(robot, link, target_pose, null_space=None):
(target_point, target_quat) = target_pose
assert target_point is not None
if null_space is not None:
assert target_quat is not No... | 8,797 | 38.990909 | 133 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/kinematics/reachability.py | import numpy as np
from pybullet_planning.utils import CIRCULAR_LIMITS
#####################################
# Reachability
def sample_reachable_base(robot, point, reachable_range=(0.25, 1.0)):
from pybullet_planning.interfaces.env_manager.pose_transformation import unit_from_theta, point_from_pose
radius = ... | 1,007 | 36.333333 | 109 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/kinematics/__init__.py | """
********************************************************************************
interfaces.kinematics
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces.kinematics
Kinematics interface
--------------------
.. autosummary::
:toctre... | 653 | 20.8 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/task_modeling/placement.py | import numpy as np
import pybullet as p
from pybullet_planning.utils import CIRCULAR_LIMITS
from pybullet_planning.interfaces.env_manager.pose_transformation import Euler, Pose, unit_pose, multiply, set_pose, get_pose
from pybullet_planning.interfaces.geometry.bounding_box import get_center_extent, get_aabb, aabb_cont... | 3,265 | 45 | 131 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/task_modeling/path_interpolation.py |
import math
import numpy as np
import pybullet as p
from pybullet_planning.interfaces.env_manager.pose_transformation import get_length, get_unit_vector, quat_angle_between, get_distance
#####################################
def get_position_waypoints(start_point, direction, quat, step_size=0.01):
distance = ge... | 2,522 | 39.047619 | 134 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/task_modeling/constraint.py |
from collections import namedtuple
import pybullet as p
from pybullet_planning.utils import CLIENT, BASE_LINK
#####################################
# Constraints - applies forces when not satisfied
def get_constraints():
"""
getConstraintUniqueId will take a serial index in range 0..getNumConstraints, and ... | 3,760 | 48.486842 | 127 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/task_modeling/__init__.py | """
********************************************************************************
interfaces.task_modeling
********************************************************************************
.. currentmodule:: pybullet_planning.interfaces.task_modeling
TODO: module description
Attachment
--------------------
.. aut... | 791 | 18.317073 | 80 | py |
real-robot-challenge | real-robot-challenge-main/python/pybullet_planning/interfaces/task_modeling/grasp.py | import warnings
from collections import namedtuple
import pybullet as p
from pybullet_planning.utils import CLIENT, BASE_LINK
from pybullet_planning.interfaces.env_manager.pose_transformation import multiply, invert, set_pose, get_pose
from pybullet_planning.interfaces.robots.link import get_link_subtree, get_link_pos... | 6,002 | 34.311765 | 134 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.