code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def nsga2select(population, fitnesses, survivors, allowequality = True):
"""The NSGA-II selection strategy (Deb et al., 2002).
The number of individuals that survive is given by the survivors parameter."""
fronts = non_dominated_sort(population,
key=lambda x: fitnesses[x],
... | The NSGA-II selection strategy (Deb et al., 2002).
The number of individuals that survive is given by the survivors parameter. | nsga2select | python | pybrain/pybrain | pybrain/optimization/populationbased/multiobjective/nsga2.py | https://github.com/pybrain/pybrain/blob/master/pybrain/optimization/populationbased/multiobjective/nsga2.py | BSD-3-Clause |
def __init__(self, module, learner = None):
"""
:key module: the acting module
:key learner: the learner (optional) """
LoggingAgent.__init__(self, module.indim, module.outdim)
self.module = module
self.learner = learner
# if learner is available, tell it the m... |
:key module: the acting module
:key learner: the learner (optional) | __init__ | python | pybrain/pybrain | pybrain/rl/agents/learning.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/learning.py | BSD-3-Clause |
def _setLearning(self, flag):
""" Set whether or not the agent should learn from its experience """
if self.learner is not None:
self.__learning = flag
else:
self.__learning = False | Set whether or not the agent should learn from its experience | _setLearning | python | pybrain/pybrain | pybrain/rl/agents/learning.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/learning.py | BSD-3-Clause |
def getAction(self):
""" Activate the module with the last observation, add the exploration from
the explorer object and store the result as last action. """
LoggingAgent.getAction(self)
self.lastaction = self.module.activate(self.lastobs)
if self.learning:
self... | Activate the module with the last observation, add the exploration from
the explorer object and store the result as last action. | getAction | python | pybrain/pybrain | pybrain/rl/agents/learning.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/learning.py | BSD-3-Clause |
def newEpisode(self):
""" Indicate the beginning of a new episode in the training cycle. """
# reset the module when a new episode starts.
self.module.reset()
if self.logging:
self.history.newSequence()
# inform learner about the start of a new episode
... | Indicate the beginning of a new episode in the training cycle. | newEpisode | python | pybrain/pybrain | pybrain/rl/agents/learning.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/learning.py | BSD-3-Clause |
def reset(self):
""" Clear the history of the agent and resets the module and learner. """
LoggingAgent.reset(self)
self.module.reset()
if self.learning:
self.learner.reset() | Clear the history of the agent and resets the module and learner. | reset | python | pybrain/pybrain | pybrain/rl/agents/learning.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/learning.py | BSD-3-Clause |
def newEpisode(self):
""" Indicate the beginning of a new episode in the training cycle. """
if self.logging:
self.history.newSequence()
if self.learning and not self.learner.batchMode:
self.learner.newEpisode()
else:
self._temperature *= self.temperat... | Indicate the beginning of a new episode in the training cycle. | newEpisode | python | pybrain/pybrain | pybrain/rl/agents/linearfa.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/linearfa.py | BSD-3-Clause |
def integrateObservation(self, obs):
"""Step 1: store the observation received in a temporary variable until action is called and
reward is given. """
self.lastobs = obs
self.lastaction = None
self.lastreward = None | Step 1: store the observation received in a temporary variable until action is called and
reward is given. | integrateObservation | python | pybrain/pybrain | pybrain/rl/agents/logging.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/logging.py | BSD-3-Clause |
def getAction(self):
"""Step 2: store the action in a temporary variable until reward is given. """
assert self.lastobs != None
assert self.lastaction == None
assert self.lastreward == None
# implement getAction in subclass and set self.lastaction | Step 2: store the action in a temporary variable until reward is given. | getAction | python | pybrain/pybrain | pybrain/rl/agents/logging.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/logging.py | BSD-3-Clause |
def giveReward(self, r):
"""Step 3: store observation, action and reward in the history dataset. """
# step 3: assume that state and action have been set
assert self.lastobs != None
assert self.lastaction != None
assert self.lastreward == None
self.lastreward = r
... | Step 3: store observation, action and reward in the history dataset. | giveReward | python | pybrain/pybrain | pybrain/rl/agents/logging.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/logging.py | BSD-3-Clause |
def reset(self):
""" Clear the history of the agent. """
self.lastobs = None
self.lastaction = None
self.lastreward = None
self.history.clear() | Clear the history of the agent. | reset | python | pybrain/pybrain | pybrain/rl/agents/logging.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/agents/logging.py | BSD-3-Clause |
def addReward(self):
""" A filtered mapping towards performAction of the underlying environment. """
# by default, the cumulative reward is just the sum over the episode
if self.discount:
self.cumreward += power(self.discount, self.samples) * self.getReward()
else:
... | A filtered mapping towards performAction of the underlying environment. | addReward | python | pybrain/pybrain | pybrain/rl/environments/episodic.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/episodic.py | BSD-3-Clause |
def f(self, x):
""" An episodic task can be used as an evaluation function of a module that produces actions
from observations, or as an evaluator of an agent. """
r = 0.
for _ in range(self.batchSize):
if isinstance(x, Module):
x.reset()
self.... | An episodic task can be used as an evaluation function of a module that produces actions
from observations, or as an evaluator of an agent. | f | python | pybrain/pybrain | pybrain/rl/environments/episodic.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/episodic.py | BSD-3-Clause |
def __init__(self, environment):
""" All tasks are coupled to an environment. """
self.env = environment
# limits for scaling of sensors and actors (None=disabled)
self.sensor_limits = None
self.actor_limits = None
self.clipping = True | All tasks are coupled to an environment. | __init__ | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def setScaling(self, sensor_limits, actor_limits):
""" Expects scaling lists of 2-tuples - e.g. [(-3.14, 3.14), (0, 1), (-0.001, 0.001)] -
one tuple per parameter, giving min and max for that parameter. The functions
normalize and denormalize scale the parameters between -1 and 1 and vic... | Expects scaling lists of 2-tuples - e.g. [(-3.14, 3.14), (0, 1), (-0.001, 0.001)] -
one tuple per parameter, giving min and max for that parameter. The functions
normalize and denormalize scale the parameters between -1 and 1 and vice versa.
To disable this feature, use 'None'. | setScaling | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def performAction(self, action):
""" A filtered mapping towards performAction of the underlying environment. """
if self.actor_limits:
action = self.denormalize(action)
self.env.performAction(action) | A filtered mapping towards performAction of the underlying environment. | performAction | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def getObservation(self):
""" A filtered mapping to getSensors of the underlying environment. """
sensors = self.env.getSensors()
if self.sensor_limits:
sensors = self.normalize(sensors)
return sensors | A filtered mapping to getSensors of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def normalize(self, sensors):
""" The function scales the parameters to be between -1 and 1. e.g. [(-pi, pi), (0, 1), (-0.001, 0.001)] """
assert(len(self.sensor_limits) == len(sensors))
result = []
for l, s in zip(self.sensor_limits, sensors):
if not l:
resul... | The function scales the parameters to be between -1 and 1. e.g. [(-pi, pi), (0, 1), (-0.001, 0.001)] | normalize | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def denormalize(self, actors):
""" The function scales the parameters from -1 and 1 to the given interval (min, max) for each actor. """
assert(len(self.actor_limits) == len(actors))
result = []
for l, a in zip(self.actor_limits, actors):
if not l:
result.appe... | The function scales the parameters from -1 and 1 to the given interval (min, max) for each actor. | denormalize | python | pybrain/pybrain | pybrain/rl/environments/task.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/task.py | BSD-3-Clause |
def __init__(self, env=None, maxsteps=1000, desiredValue = 0):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
self.desiredValue = desiredValue
if env == None:
env... |
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
| __init__ | python | pybrain/pybrain | pybrain/rl/environments/cartpole/balancetask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/balancetask.py | BSD-3-Clause |
def __init__(self, env=None, maxsteps=1000):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
if env == None:
env = CartPoleEnvironment()
EpisodicTask.__init__(self... |
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
| __init__ | python | pybrain/pybrain | pybrain/rl/environments/cartpole/balancetask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/balancetask.py | BSD-3-Clause |
def getObservation(self):
""" a filtered mapping to getSample of the underlying environment. """
sensors = self.env.getSensors()
if self.sensor_limits:
sensors = self.normalize(sensors)
return sensors | a filtered mapping to getSample of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/cartpole/balancetask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/balancetask.py | BSD-3-Clause |
def __init__(self, env=None, maxsteps=1000):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
if env == None:
env = CartPoleEnvironment()
EpisodicTask.__init__(self... |
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
| __init__ | python | pybrain/pybrain | pybrain/rl/environments/cartpole/balancetask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/balancetask.py | BSD-3-Clause |
def getObservation(self):
""" a filtered mapping to getSample of the underlying environment. """
sensors = [self.env.getSensors()[0], self.env.getSensors()[2]]
if self.sensor_limits:
sensors = self.normalize(sensors)
return sensors | a filtered mapping to getSample of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/cartpole/balancetask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/balancetask.py | BSD-3-Clause |
def reset(self):
""" re-initializes the environment, setting the cart back in a random position.
"""
if self.randomInitialization:
angle = random.uniform(-0.2, 0.2)
pos = random.uniform(-0.5, 0.5)
else:
angle = -0.2
pos = 0.2
self.s... | re-initializes the environment, setting the cart back in a random position.
| reset | python | pybrain/pybrain | pybrain/rl/environments/cartpole/cartpole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/cartpole.py | BSD-3-Clause |
def _derivs(self, x, t):
""" This function is needed for the Runge-Kutta integration approximation method. It calculates the
derivatives of the state variables given in x. for each variable in x, it returns the first order
derivative at time t.
"""
F = self.action
... | This function is needed for the Runge-Kutta integration approximation method. It calculates the
derivatives of the state variables given in x. for each variable in x, it returns the first order
derivative at time t.
| _derivs | python | pybrain/pybrain | pybrain/rl/environments/cartpole/cartpole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/cartpole.py | BSD-3-Clause |
def getSensors(self):
""" returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 6 elements: theta1, theta1', theta2, theta2', s, s'
(s being the distance from the origi... | returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 6 elements: theta1, theta1', theta2, theta2', s, s'
(s being the distance from the origin).
| getSensors | python | pybrain/pybrain | pybrain/rl/environments/cartpole/doublepole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/doublepole.py | BSD-3-Clause |
def reset(self):
""" re-initializes the environment, setting the cart back in a random position.
"""
self.p1.reset()
self.p2.reset()
# put cart in the same place:
self.p2.sensors = (self.p2.sensors[0], self.p2.sensors[1], self.p1.sensors[2], self.p1.sensors[3])
se... | re-initializes the environment, setting the cart back in a random position.
| reset | python | pybrain/pybrain | pybrain/rl/environments/cartpole/doublepole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/doublepole.py | BSD-3-Clause |
def getSensors(self):
""" returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 3 elements: theta1, theta2, s
(s being the distance from the origin).
"""
... | returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 3 elements: theta1, theta2, s
(s being the distance from the origin).
| getSensors | python | pybrain/pybrain | pybrain/rl/environments/cartpole/nonmarkovdoublepole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/nonmarkovdoublepole.py | BSD-3-Clause |
def getSensors(self):
""" returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 2 elements: theta, s
(s being the distance from the origin).
"""
tmp = C... | returns the state one step (dt) ahead in the future. stores the state in
self.sensors because it is needed for the next calculation. The sensor return
vector has 2 elements: theta, s
(s being the distance from the origin).
| getSensors | python | pybrain/pybrain | pybrain/rl/environments/cartpole/nonmarkovpole.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/nonmarkovpole.py | BSD-3-Clause |
def __init__(self, numPoles=1, markov=True, verbose=False,
extraObservations=False, extraRandoms=0, maxSteps=100000):
""" @extraObservations: if this flag is true, the observations include the Cartesian coordinates
of the pole(s).
"""
if self.__single != None:
... | @extraObservations: if this flag is true, the observations include the Cartesian coordinates
of the pole(s).
| __init__ | python | pybrain/pybrain | pybrain/rl/environments/cartpole/fast_version/cartpoleenv.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/cartpole/fast_version/cartpoleenv.py | BSD-3-Clause |
def performAction(self, action):
""" a filtered mapping towards performAction of the underlying environment. """
# scaling
self.incStep()
action = (action + 1.0) / 2.0 * self.dif + self.env.fraktMin * self.env.dists[0]
#Clipping the maximal change in actions (max force clipping)
... | a filtered mapping towards performAction of the underlying environment. | performAction | python | pybrain/pybrain | pybrain/rl/environments/flexcube/tasks.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/flexcube/tasks.py | BSD-3-Clause |
def drawScene(self):
''' This methode describes the complete scene.'''
# clear the buffer
if self.zDis < 10: self.zDis += 0.25
if self.lastz > 200: self.lastz -= self.zDis
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
# Point of view... | This methode describes the complete scene. | drawScene | python | pybrain/pybrain | pybrain/rl/environments/flexcube/viewer.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/flexcube/viewer.py | BSD-3-Clause |
def getSensors(self):
""" the one sensor is the function result. """
tmp = self.result
assert tmp is not None
self.result = None
return array([tmp]) | the one sensor is the function result. | getSensors | python | pybrain/pybrain | pybrain/rl/environments/functions/function.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/functions/function.py | BSD-3-Clause |
def _exampleConfig(self, numatoms, noise=0.05, edge=2.):
""" Arranged in an approximate cube of certain edge length. """
assert numatoms % 8 == 0
x0 = randn(3, 2, 2, 2, numatoms / 8) * noise * edge - edge / 2
x0[0, 0] += edge
x0[1, :, 0] += edge
x0[2, :, :, 0] += edge
... | Arranged in an approximate cube of certain edge length. | _exampleConfig | python | pybrain/pybrain | pybrain/rl/environments/functions/lennardjones.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/functions/lennardjones.py | BSD-3-Clause |
def __init__(self, basef, distance=0.1, offset=None):
""" by default the offset is random, with a distance of 0.1 to the old one """
FunctionEnvironment.__init__(self, basef.xdim, basef.xopt)
if offset == None:
self._offset = rand(basef.xdim)
self._offset *= distance / no... | by default the offset is random, with a distance of 0.1 to the old one | __init__ | python | pybrain/pybrain | pybrain/rl/environments/functions/transformations.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/functions/transformations.py | BSD-3-Clause |
def __init__(self, basef, rotMat=None):
""" by default the rotation matrix is random. """
FunctionEnvironment.__init__(self, basef.xdim, basef.xopt)
if rotMat == None:
# make a random orthogonal rotation matrix
self._M = orth(rand(basef.xdim, basef.xdim))
else:
... | by default the rotation matrix is random. | __init__ | python | pybrain/pybrain | pybrain/rl/environments/functions/transformations.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/functions/transformations.py | BSD-3-Clause |
def _freePos(self):
""" produce a list of the free positions. """
res = []
for i, row in enumerate(self.mazeTable):
for j, p in enumerate(row):
if p == False:
res.append((i, j))
return res | produce a list of the free positions. | _freePos | python | pybrain/pybrain | pybrain/rl/environments/mazes/maze.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/maze.py | BSD-3-Clause |
def __str__(self):
""" Ascii representation of the maze, with the current state """
s = ''
for r, row in reversed(list(enumerate(self.mazeTable))):
for c, p in enumerate(row):
if (r, c) == self.goal:
s += '*'
elif (r, c) == self.per... | Ascii representation of the maze, with the current state | __str__ | python | pybrain/pybrain | pybrain/rl/environments/mazes/maze.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/maze.py | BSD-3-Clause |
def getObservation(self):
""" observations are encoded in a 1-n encoding of possible wall combinations. """
res = zeros(7)
obs = self.env.getSensors()
if self.env.perseus == self.env.goal:
res[6] = 1
elif sum(obs) == 3:
res[0] = 1
elif sum(obs) == ... | observations are encoded in a 1-n encoding of possible wall combinations. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/mazes/tasks/cheesemaze.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/tasks/cheesemaze.py | BSD-3-Clause |
def getObservation(self):
"""only walls on w, E, both or neither are observed. """
res = zeros(4)
all = self.env.getSensors()
res[0] = all[3]
res[1] = all[1]
res[2] = all[3] and all[1]
res[3] = not all[3] and not all[1]
return res | only walls on w, E, both or neither are observed. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/mazes/tasks/maze4x3.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/tasks/maze4x3.py | BSD-3-Clause |
def getReward(self):
""" compute and return the current reward (i.e. corresponding to the last action performed) """
if self.env.goal == self.env.perseus:
self.env.reset()
reward = 1.
else:
reward = 0.
return reward | compute and return the current reward (i.e. corresponding to the last action performed) | getReward | python | pybrain/pybrain | pybrain/rl/environments/mazes/tasks/mdp.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/tasks/mdp.py | BSD-3-Clause |
def performAction(self, action):
""" POMDP tasks, as they have discrete actions, can me used by providing either an index,
or an array with a 1-in-n coding (which can be stochastic). """
if type(action) == ndarray:
action = drawIndex(action, tolerant = True)
self.steps += 1
... | POMDP tasks, as they have discrete actions, can me used by providing either an index,
or an array with a 1-in-n coding (which can be stochastic). | performAction | python | pybrain/pybrain | pybrain/rl/environments/mazes/tasks/pomdp.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/tasks/pomdp.py | BSD-3-Clause |
def getObservation(self):
""" do we think we heard something on the left or on the right? """
if self.tigerLeft:
obs = array([1, 0])
else:
obs = array([0, 1])
if random() < self.stochObs:
obs = 1 - obs
return obs | do we think we heard something on the left or on the right? | getObservation | python | pybrain/pybrain | pybrain/rl/environments/mazes/tasks/tiger.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/mazes/tasks/tiger.py | BSD-3-Clause |
def __init__(self, render=True, realtime=True, ip="127.0.0.1", port="21590", buf='16384'):
""" initializes the virtual world, variables, the frame rate and the callback functions."""
print("ODEEnvironment -- based on Open Dynamics Engine.")
# initialize base class
self.render = render
... | initializes the virtual world, variables, the frame rate and the callback functions. | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def resetAttributes(self):
"""resets the class attributes to their default values"""
# initialize root node
self.root = None
# A list with (body, geom) tuples
self.body_geom = [] | resets the class attributes to their default values | resetAttributes | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def reset(self):
"""resets the model and all its parameters to their original values"""
self.loadXODE(self._currentXODEfile, reload=True)
self.stepCounter = 0 | resets the model and all its parameters to their original values | reset | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _setWorldParameters(self):
""" sets parameters for ODE world object: gravity, error correction (ERP, default=0.2),
constraint force mixing (CFM, default=1e-5). """
self.world.setGravity((0, -9.81, 0))
# self.world.setERP(0.2)
# self.world.setCFM(1e-9) | sets parameters for ODE world object: gravity, error correction (ERP, default=0.2),
constraint force mixing (CFM, default=1e-5). | _setWorldParameters | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _create_box(self, space, density, lx, ly, lz):
"""Create a box body and its corresponding geom."""
# Create body and mass
body = ode.Body(self.world)
M = ode.Mass()
M.setBox(density, lx, ly, lz)
body.setMass(M)
body.name = None
# Create a box geom for ... | Create a box body and its corresponding geom. | _create_box | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _create_sphere(self, space, density, radius):
"""Create a sphere body and its corresponding geom."""
# Create body and mass
body = ode.Body(self.world)
M = ode.Mass()
M.setSphere(density, radius)
body.setMass(M)
body.name = None
# Create a sphere geom... | Create a sphere body and its corresponding geom. | _create_sphere | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def drop_object(self):
"""Drops a random object (box, sphere) into the scene."""
# choose between boxes and spheres
if random.uniform() > 0.5:
(body, geom) = self._create_sphere(self.space, 10, 0.4)
else:
(body, geom) = self._create_box(self.space, 10, 0.5, 0.5, 0... | Drops a random object (box, sphere) into the scene. | drop_object | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def addSensor(self, sensor):
""" adds a sensor object to the list of sensors """
if not isinstance(sensor, sensors.Sensor):
raise TypeError("the given sensor is not an instance of class 'Sensor'.")
# add sensor to sensors list
self.sensors.append(sensor)
# connect sen... | adds a sensor object to the list of sensors | addSensor | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def addActuator(self, actuator):
""" adds a sensor object to the list of sensors """
if not isinstance(actuator, actuators.Actuator):
raise TypeError("the given actuator is not an instance of class 'Actuator'.")
# add sensor to sensors list
self.actuators.append(actuator)
... | adds a sensor object to the list of sensors | addActuator | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def loadXODE(self, filename, reload=False):
""" loads an XODE file (xml format) and parses it. """
f = open(filename)
self._currentXODEfile = filename
p = xode.parser.Parser()
self.root = p.parseFile(f)
f.close()
try:
# filter all xode "world" objects ... | loads an XODE file (xml format) and parses it. | loadXODE | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _parseBodies(self, node):
""" parses through the xode tree recursively and finds all bodies and geoms for drawing. """
# body (with nested geom)
if isinstance(node, xode.body.Body):
body = node.getODEObject()
body.name = node.getName()
try:
... | parses through the xode tree recursively and finds all bodies and geoms for drawing. | _parseBodies | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def performAction(self, action):
""" sets the values for all actuators combined. """
pointer = 0
for a in self.actuators:
val = a.getNumValues()
a._update(action[pointer:pointer + val])
pointer += val
for _ in range(self.stepsPerAction):
s... | sets the values for all actuators combined. | performAction | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _near_callback(self, args, geom1, geom2):
"""Callback function for the collide() method.
This function checks if the given geoms do collide and
creates contact joints if they do."""
# only check parse list, if objects have name
if geom1.name != None and geom2.name != None:
... | Callback function for the collide() method.
This function checks if the given geoms do collide and
creates contact joints if they do. | _near_callback | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def step(self):
""" Here the ode physics is calculated by one step. """
# call additional callback functions for all kinds of tasks (e.g. printing)
self._printfunc()
# Detect collisions and create contact joints
self.space.collide((self.world, self.contactgroup), self._near_cal... | Here the ode physics is calculated by one step. | step | python | pybrain/pybrain | pybrain/rl/environments/ode/environment.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/environment.py | BSD-3-Clause |
def _connect(self, world):
""" Connects the sensor to the world and initializes the value list. """
Sensor._connect(self, world)
# initialize object list - this should not change during runtime
self._joints = []
self._parseJoints()
# do initial update to get numValues
... | Connects the sensor to the world and initializes the value list. | _connect | python | pybrain/pybrain | pybrain/rl/environments/ode/sensors.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/sensors.py | BSD-3-Clause |
def _connect(self, world):
""" Connects the sensor to the world and initializes the value list. """
Sensor._connect(self, world)
# initialize object list - this should not change during runtime
self._joints = []
self._parseJoints()
# do initial update to get numValues
... | Connects the sensor to the world and initializes the value list. | _connect | python | pybrain/pybrain | pybrain/rl/environments/ode/sensors.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/sensors.py | BSD-3-Clause |
def _connect(self, world):
""" Connects the sensor to the world and initializes the value list. """
Sensor._connect(self, world)
# initialize object list - this should not change during runtime
self._bodies = []
self._parseBodies()
# do initial update to get numValues
... | Connects the sensor to the world and initializes the value list. | _connect | python | pybrain/pybrain | pybrain/rl/environments/ode/sensors.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/sensors.py | BSD-3-Clause |
def init_GL(self, width=800, height=600):
""" initialize OpenGL. This function has to be called only once before drawing. """
glutInit([])
# Open a window
glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
self.width = width
self.height = height
glutInitWi... | initialize OpenGL. This function has to be called only once before drawing. | init_GL | python | pybrain/pybrain | pybrain/rl/environments/ode/viewer.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/viewer.py | BSD-3-Clause |
def prepare_GL(self):
"""Prepare drawing. This function is called in every step. It clears the screen and sets the new camera position"""
# Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# Projection mode
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
... | Prepare drawing. This function is called in every step. It clears the screen and sets the new camera position | prepare_GL | python | pybrain/pybrain | pybrain/rl/environments/ode/viewer.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/viewer.py | BSD-3-Clause |
def draw_item(self, item):
""" draws an object (spere, cube, plane, ...) """
glDisable(GL_TEXTURE_2D)
glPushMatrix()
if item['type'] in ['GeomBox', 'GeomSphere', 'GeomCylinder', 'GeomCCylinder']:
# set color of object (currently dark gray)
if 'color' in item:
... | draws an object (spere, cube, plane, ...) | draw_item | python | pybrain/pybrain | pybrain/rl/environments/ode/viewer.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/viewer.py | BSD-3-Clause |
def _screenshot(self, path_prefix='.', format='PNG'):
"""Saves a screenshot of the current frame buffer.
The save path is <path_prefix>/.screenshots/shot<num>.png
The path is automatically created if it does not exist.
Shots are automatically numerated based on how many files
are... | Saves a screenshot of the current frame buffer.
The save path is <path_prefix>/.screenshots/shot<num>.png
The path is automatically created if it does not exist.
Shots are automatically numerated based on how many files
are already in the directory. | _screenshot | python | pybrain/pybrain | pybrain/rl/environments/ode/viewer.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/viewer.py | BSD-3-Clause |
def _near_callback(self, args, geom1, geom2):
"""Callback function for the collide() method.
This function checks if the given geoms do collide and
creates contact joints if they do."""
# only check parse list, if objects have name
if geom1.name != None and geom2.name != None:
... | Callback function for the collide() method.
This function checks if the given geoms do collide and
creates contact joints if they do. | _near_callback | python | pybrain/pybrain | pybrain/rl/environments/ode/instances/ccrl.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/instances/ccrl.py | BSD-3-Clause |
def loadXODE(self, filename, reload=False):
""" loads an XODE file (xml format) and parses it. """
f = open(filename)
self._currentXODEfile = filename
p = xode.parser.Parser()
self.root = p.parseFile(f)
f.close()
try:
# filter all xode "world" objects ... | loads an XODE file (xml format) and parses it. | loadXODE | python | pybrain/pybrain | pybrain/rl/environments/ode/instances/ccrl.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/instances/ccrl.py | BSD-3-Clause |
def getObservation(self):
""" a filtered mapping to getSample of the underlying environment. """
sensors = self.env.getSensors()
#Sensor hand to target object
for i in range(3):
self.dist[i] = ((sensors[self.env.obsLen - 9 + i] + sensors[self.env.obsLen - 6 + i] + sensors[sel... | a filtered mapping to getSample of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/ode/tasks/ccrl.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tasks/ccrl.py | BSD-3-Clause |
def getObservation(self):
""" a filtered mapping to getSample of the underlying environment. """
sensors = self.env.getSensors()
sensSort = []
#Angle and angleVelocity
for i in range(32):
sensSort.append(sensors[i])
#Angles wanted (old action)
for i in... | a filtered mapping to getSample of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/ode/tasks/ccrl.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tasks/ccrl.py | BSD-3-Clause |
def getObservation(self):
""" a filtered mapping to getSample of the underlying environment. """
sensors = self.env.getSensors()
sensSort = []
#Angle and angleVelocity
for i in range(32):
sensSort.append(sensors[i])
#Angles wanted (old action)
for i in... | a filtered mapping to getSample of the underlying environment. | getObservation | python | pybrain/pybrain | pybrain/rl/environments/ode/tasks/ccrl.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tasks/ccrl.py | BSD-3-Clause |
def __init__(self, name, attr=None):
"""create a new tag at the topmost level using given name
and (optional) attribute dictionary"""
# XML tag structure is a dictionary containing all attributes plus
# two special tags:
# myName = name of the tag
# Icontain = list of... | create a new tag at the topmost level using given name
and (optional) attribute dictionary | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def insert(self, name, attr=None):
"""Insert a new tag into the current one. The name can be either the
new tag name or an XMLstruct object (in which case attr is ignored).
Unless name is None, we descend into the new tag as a side effect.
A dictionary is expected for attr."""
if... | Insert a new tag into the current one. The name can be either the
new tag name or an XMLstruct object (in which case attr is ignored).
Unless name is None, we descend into the new tag as a side effect.
A dictionary is expected for attr. | insert | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def insertMulti(self, attrlist):
"""Inserts multiple subtags at once. A list of XMLstruct objects
must be given; the tag hierarchy is not descended into."""
if not self.current.hasSubtag():
self.current.tag['Icontain'] = []
self.current.tag['Icontain'] += attrlist | Inserts multiple subtags at once. A list of XMLstruct objects
must be given; the tag hierarchy is not descended into. | insertMulti | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def downTo(self, name, stack=None, current=None):
"""Traverse downward from current tag, until given named tag is found. Returns
true if found and sets stack and current tag correspondingly."""
if stack is None:
stack = self.stack
current = self.current
if self.na... | Traverse downward from current tag, until given named tag is found. Returns
true if found and sets stack and current tag correspondingly. | downTo | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def up(self, steps=1):
"""traverse upward a number of steps in tag stack"""
for _ in range(steps):
if self.stack != []:
self.current = self.stack.pop() | traverse upward a number of steps in tag stack | up | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def hasSubtag(self, name=None):
"""determine whether current tag contains other tags, and returns
the tag with a matching name (if name is given) or True (if not)"""
if 'Icontain' in self.tag:
if name is None:
return(True)
else:
for subtag ... | determine whether current tag contains other tags, and returns
the tag with a matching name (if name is given) or True (if not) | hasSubtag | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def getSubtag(self, name=None):
"""determine whether current tag contains other tags, and returns
the tag with a matching name (if name is given) or None (if not)"""
if 'Icontain' in self.tag:
for subtag in self.tag['Icontain']:
if subtag.name == name: return(subtag)
... | determine whether current tag contains other tags, and returns
the tag with a matching name (if name is given) or None (if not) | getSubtag | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def nbAttributes(self):
"""return number of user attributes the current tag has"""
nAttr = len(list(self.tag.keys())) - 1
if self.hasSubtag():
nAttr -= 1
return nAttr | return number of user attributes the current tag has | nbAttributes | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def scale(self, sc, scaleset=set([]), exclude=set([])):
"""for all tags not in the exclude set, scale all attributes whose names are in scaleset by the given factor"""
if self.name not in exclude:
for name, val in self.tag.items():
if name in scaleset:
sel... | for all tags not in the exclude set, scale all attributes whose names are in scaleset by the given factor | scale | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def write(self, file, depth=0):
"""parse XML structure recursively and append to the output fileID,
increasing the offset (tabs) while descending into the tree"""
if 'myName' not in self.tag:
print("Error parsing XML structure: Tag name missing!")
sys.exit(1)
# fi... | parse XML structure recursively and append to the output fileID,
increasing the offset (tabs) while descending into the tree | write | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xmltools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xmltools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""initialize the XODE structure with a name and the world and
space tags"""
self._xodename = name
self._centerOn = None
self._affixToEnvironment = None
# sensors is a list of ['type', [args], {kwargs}]
self.sensors = []
... | initialize the XODE structure with a name and the world and
space tags | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertBody(self, bname, shape, size, density, pos=[0, 0, 0], passSet=None, euler=None, mass=None, color=None):
"""Inserts a body with the given custom name and one of the standard
shapes. The size and pos parameters are given as xyz-lists or tuples.
euler are three rotation angles (degrees),... | Inserts a body with the given custom name and one of the standard
shapes. The size and pos parameters are given as xyz-lists or tuples.
euler are three rotation angles (degrees),
if mass is given, density is calculated automatically | insertBody | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertJoint(self, body1, body2, type, axis=None, anchor=(0, 0, 0), rel=False, name=None):
"""Inserts a joint of given type linking the two bodies. Default name is
a "_"-concatenation of the body names. The anchor is a xyz-tuple, rel is
a boolean specifying whether the anchor coordinates ref... | Inserts a joint of given type linking the two bodies. Default name is
a "_"-concatenation of the body names. The anchor is a xyz-tuple, rel is
a boolean specifying whether the anchor coordinates refer to the body's origin,
axis parameters have to be provided as a dictionary. | insertJoint | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertFloor(self, y= -0.5):
"""inserts a bodiless floor at given y offset"""
self.insert('geom', {'name': 'floor'})
self.insert('plane', {'a': 0, 'b': 1, 'c': 0, 'd': y})
self.up(2) | inserts a bodiless floor at given y offset | insertFloor | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertPressureSensorElement(self, parent, name=None, shape='cappedCylinder', size=[0.16, 0.5], pos=[0, 0, 0], euler=[0, 0, 0], dens=1, \
mass=None, passSet=[], stiff=10.0):
"""Insert one single pressure sensor element of the given shape, size, density, etc.
The sliding a... | Insert one single pressure sensor element of the given shape, size, density, etc.
The sliding axis is by default oriented along the z-axis, which is also the default for cylinder shapes.
You have to rotate the sensor into the correct orientation - the sliding axis will be rotated accordingly.
St... | insertPressureSensorElement | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def merge(self, xodefile, joinLevel='space'):
"""Merge a second XODE file into this one, at the specified
level (which must exist in both files). The passpair lists are
also joined. Upon return, the current tag for both objects
is the one given."""
self.top()
if not self.... | Merge a second XODE file into this one, at the specified
level (which must exist in both files). The passpair lists are
also joined. Upon return, the current tag for both objects
is the one given. | merge | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def scaleModel(self, sc):
"""scales all spatial dimensions by the given factor
FIXME: quaternions may cause problems, which are currently ignored"""
# scale these attributes...
scaleset = set(['x', 'y', 'z', 'a', 'b', 'c', 'd', 'sizex', 'sizey', 'sizez', 'length', 'radius'])
# .... | scales all spatial dimensions by the given factor
FIXME: quaternions may cause problems, which are currently ignored | scaleModel | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def writeCustomParameters(self, f):
"""writes our custom parameters into an XML comment"""
f.write('<!--odeenvironment parameters\n')
if len(self._pass) > 0:
f.write('<passpairs>\n')
for pset in self._pass.values():
f.write(str(tuple(pset)) + '\n')
... | writes our custom parameters into an XML comment | writeCustomParameters | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def writeXODE(self, filename=None):
"""writes the created structure (plus header and footer) to file with
the given basename (.xode is appended)"""
if filename is None: filename = self._xodename
f = open(filename + '.xode', 'wb') # <-- wb here ensures Linux compatibility
f.write... | writes the created structure (plus header and footer) to file with
the given basename (.xode is appended) | writeXODE | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""Creates one finger on a fixed palm, and adds some sensors"""
XODEfile.__init__(self, name, **kwargs)
# create the hand and finger
self.insertBody('palm', 'box', [10, 2, 10], 5, pos=[3.75, 4, 0], passSet=['pal'])
self.insertBody('sample', 'bo... | Creates one finger on a fixed palm, and adds some sensors | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertHapticSensorsRandom(self):
"""insert haptic sensors at random locations"""
self.sensorGroupName = 'haptic'
for _ in range(5):
self.insertHapticSensor(dx=random.uniform(-0.65, 0.65), dz=random.uniform(-0.4, 0.2))
##self.insertHapticSensor(dx=-0.055) | insert haptic sensors at random locations | insertHapticSensorsRandom | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertHapticSensors(self):
"""insert haptic sensors at predetermined locations
(check using testhapticsensorslocations.py)"""
self.sensorGroupName = 'haptic'
x = [0.28484253596392306, -0.59653176701550947, -0.36877718203650889, 0.50549219349016294, -0.22467390532644882, 0.05197861269... | insert haptic sensors at predetermined locations
(check using testhapticsensorslocations.py) | insertHapticSensors | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""Creates hand with fingertip and palm sensors -- palm up"""
XODEfile.__init__(self, name, **kwargs)
# create the hand and finger
self.insertBody('palm', 'box', [10, 2, 10], 30, pos=[0, 0, 0], passSet=['pal'])
self.insertBody('pressure', 'box'... | Creates hand with fingertip and palm sensors -- palm up | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""Creates hand with fingertip and palm sensors -- palm down"""
XODEfile.__init__(self, name, **kwargs)
# create the hand and finger
self.insertBody('palm', 'box', [10, 2, 10], 10, pos=[0, 0, 0], passSet=['pal'])
self.insertBody('pressure', 'bo... | Creates hand with fingertip and palm sensors -- palm down | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertSampleStructure(self, angle=30, std=0.05, dist=0.9, **kwargs):
"""create some ridges on the sample"""
for i in range(16):
name = 'ridge' + str(i)
self.insertBody(name, 'cappedCylinder', [0.2, 10], 5, pos=[0, 0.5, random.gauss(15 - dist * i, std)], euler=[0, angle, 0], p... | create some ridges on the sample | insertSampleStructure | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def insertSampleStructure(self, xoffs=0.0, std=0.025, dist=0.9, **kwargs):
"""create four rows of spheres on the sample"""
dx = [dist * k for k in [-1, 0, 1]]
dz = [dist * k * 0.5 for k in [0, 1, 0]]
for i in range(16):
for k in range(3):
x = random.gauss(dx[k... | create four rows of spheres on the sample | insertSampleStructure | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""Creates hand with fingertip and palm sensors -- palm up"""
XODEfile.__init__(self, name, **kwargs)
# create the hand and finger
self.insertBody('palm', 'box', [4.12, 3.0, 2], 30, pos=[0, 0, 0], passSet=['total'], mass=3.356)
self.insertBody(... | Creates hand with fingertip and palm sensors -- palm up | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def __init__(self, name, **kwargs):
"""Creates hand with fingertip and palm sensors -- palm up"""
XODEfile.__init__(self, name, **kwargs)
# create the hand and finger
self.insertBody('body', 'box', [7.0, 16.0, 10.0], 30, pos=[0, 0, 2.0], passSet=['total'], mass=15.0, color=(0.5, 0.5, 0.4... | Creates hand with fingertip and palm sensors -- palm up | __init__ | python | pybrain/pybrain | pybrain/rl/environments/ode/tools/xodetools.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/tools/xodetools.py | BSD-3-Clause |
def _setObject(self, kclass, **kwargs):
"""
Create the Geom object and apply transforms. Only call for placeable
Geoms.
"""
if (self._body is None):
# The Geom is independant so it can have its own transform
kwargs['space'] = self._space
obj ... |
Create the Geom object and apply transforms. Only call for placeable
Geoms.
| _setObject | python | pybrain/pybrain | pybrain/rl/environments/ode/xode_changes/geom.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/ode/xode_changes/geom.py | BSD-3-Clause |
def __init__(self, env=None, maxsteps=1000):
"""
:key env: (optional) an instance of a ShipSteeringEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
if env == None:
env = ShipSteeringEnvironment(render=False)
Episod... |
:key env: (optional) an instance of a ShipSteeringEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
| __init__ | python | pybrain/pybrain | pybrain/rl/environments/shipsteer/northwardtask.py | https://github.com/pybrain/pybrain/blob/master/pybrain/rl/environments/shipsteer/northwardtask.py | BSD-3-Clause |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.