Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Minor Adjustments #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion studywolf_control/arms/two_link/arm_python_todorov.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

from arm2base import Arm2Base
from .arm2base import Arm2Base
import numpy as np

class Arm(Arm2Base):
Expand Down
14 changes: 7 additions & 7 deletions studywolf_control/arms/two_link/arm_todorov.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

from arm2base import Arm2Base
from .arm2base import Arm2Base
import numpy as np

class Arm(Arm2Base):
Expand Down Expand Up @@ -48,20 +48,20 @@ def apply_torque(self, u, dt=None):
a1 = i[0] + i[1] + m[1]*l[0]**2
a2 = m[1]*l[0]*s[1]
a3 = i[1]
I = np.array([[a1 + 2*a2*np.cos(q[1]), a3 + a2*np.cos(q[1])],
[a3 + a2*np.cos(q[1]), a3]])
I = np.array([[a1 + 2*a2*np.cos(self.q[1]), a3 + a2*np.cos(self.q[1])],
[a3 + a2*np.cos(self.q[1]), a3]])

# centripital and Coriolis effects
C = np.array([[-dq[1] * (2 * dq[0] + dq[1])],
[dq[0]]]) * a2 * np.sin(q[1])
C = np.array([-self.dq[1] * (2 * self.dq[0] + self.dq[1]),
self.dq[0]]) * a2 * np.sin(self.q[1])

# joint friction
B = np.array([[.05, .025],
[.025, .05]])

# calculate forward dynamics
ddq = np.linalg.pinv(I) * (u - C - np.dot(B, dq))

ddq = np.dot(np.linalg.pinv(I) , (u - C - np.dot(B, self.dq)))
# transfer to next time step
self.q += dt * self.dq
self.dq += dt * ddq
Expand Down
2 changes: 1 addition & 1 deletion studywolf_control/controllers/ahf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, **kwargs):
# this code goes into the weights folder, finds the most
# recent trial, and loads up the weights
files = sorted(glob.glob('controllers/weights/rnn*'))
print 'loading weights from %s'%files[-1]
print('loading weights from %s'%files[-1])
W = np.load(files[-1])['arr_0']
num_states = 4
self.rnn = RNNet(shape=[num_states * 2, 32, 32, num_states, num_states],
Expand Down
2 changes: 1 addition & 1 deletion studywolf_control/controllers/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def record(self, t, x):
self.signal.append(x.copy())

if self.write_out == True:
print 'saving'
print('saving')
np.savez_compressed(
'data/%s/%s/%s%.3i'%(self.task, \
self.controller, self.name, self.count),
Expand Down
2 changes: 1 addition & 1 deletion studywolf_control/tasks/follow_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def Task(arm, controller_class,
# generate control shell -----------------
additions = []
if force is not None:
print 'applying joint velocity based forcefield...'
print('applying joint velocity based forcefield...')
additions.append(forcefield.Addition(scale=force))
task = 'arm%i/forcefield'%arm.DOF

Expand Down
2 changes: 1 addition & 1 deletion studywolf_control/tasks/postural.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def Task(arm, controller_type, x_bias=0., y_bias=2., dist=.4,
# generate control shell -----------------
additions = []
force_index = np.random.randint(8) if force_index is None else force_index
print 'applying force %i...'%force_index
print('applying force %i...'%force_index)
additions.append(Addition(index=force_index))
task = 'arm%i/postural%i'%(arm.DOF, force_index)

Expand Down
2 changes: 1 addition & 1 deletion studywolf_control/tasks/random_movements.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def Task(arm, controller_class,
# generate control shell -----------------
additions = []
if force is not None:
print 'applying joint velocity based forcefield...'
print('applying joint velocity based forcefield...')
additions.append(forcefield.Addition(scale=force))
task = 'arm%i/forcefield'%arm.DOF

Expand Down