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

Migrate most of the code to python3 & enable installation via pip #13

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.gitignore~
saved_experiments/
*.ipynb_checkpoints/
maddux.egg-info/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Created to use in a project for [Robert Platt's Robotics Course](http://www.ccs.
- End Effector Position, Velocity


### Installation

```bash
pip3 install -e .
```


### Arm Visualization and Animations
```python
import numpy as np
Expand Down
12 changes: 6 additions & 6 deletions maddux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import robots
import objects
import plot
import utils
import examples
from environment import Environment
from maddux import robots
from maddux import objects
from maddux import plot
from maddux import utils
from maddux import examples
from maddux.environment import Environment
4 changes: 2 additions & 2 deletions maddux/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run(self, duration):
"""
duration_ms = int(duration * 1000)

for _ in xrange(duration_ms):
for _ in range(duration_ms):
map(lambda obj: obj.step(), self.dynamic_objects)
if self.collision():
break
Expand Down Expand Up @@ -79,7 +79,7 @@ def animate(self, duration=None, save_path=None):

def update(i):
ax.clear()
for _ in xrange(dynamic_iter_per_frame):
for _ in range(dynamic_iter_per_frame):
map(lambda obj: obj.step(), self.dynamic_objects)
# Check for collisions
self.collision()
Expand Down
6 changes: 3 additions & 3 deletions maddux/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ball import Ball
from target import Target
from obstacle import Obstacle
from maddux.objects.ball import Ball
from maddux.objects.target import Target
from maddux.objects.obstacle import Obstacle
2 changes: 1 addition & 1 deletion maddux/objects/ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A ball object to throw.
"""
import numpy as np
from throwable import ThrowableObject
from maddux.objects.throwable import ThrowableObject
from maddux.plot import plot_sphere


Expand Down
10 changes: 5 additions & 5 deletions maddux/objects/obstacle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import numpy as np
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from static import StaticObject
from maddux.objects.static import StaticObject


class Obstacle(StaticObject):
Expand Down Expand Up @@ -116,10 +116,10 @@ def display(self):

:rtype: None
"""
print "Center: {}".format(self.center)
print "Width: {}".format(self.width)
print "Height: {}".format(self.height)
print "Depth: {}".format(self.depth)
print("Center: {}".format(self.center))
print("Width: {}".format(self.width))
print("Height: {}".format(self.height))
print("Depth: {}".format(self.depth))

def plot(self, ax):
"""Plots the obstacle at its location
Expand Down
6 changes: 3 additions & 3 deletions maddux/objects/target.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
A stationary object that something may collide with.
"""
from static import StaticObject
from maddux.objects.static import StaticObject
import numpy as np

HIT_ERROR = 0.01
Expand Down Expand Up @@ -45,8 +45,8 @@ def display(self):
Display target properties
:rtpye: None
"""
print "Position: {}".format(self.position)
print "Radius: {}".format(self.radius)
print("Position: {}".format(self.position))
print("Radius: {}".format(self.radius))

def plot_data(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions maddux/objects/throwable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
velocity, etc.
"""
import numpy as np
from dynamic import DynamicObject
from maddux.objects.dynamic import DynamicObject

GRAVITY = -9.81
TIME = 0.001
Expand Down Expand Up @@ -44,6 +44,6 @@ def attach(self):

def display(self):
"""Display information about object"""
print "Positon: {}".format(self.position)
print "Velocity: {}".format(self.velocity)
print "Attached: {}".format(self.attached)
print("Positon: {}".format(self.position))
print("Velocity: {}".format(self.velocity))
print("Attached: {}".format(self.attached))
6 changes: 3 additions & 3 deletions maddux/robots/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from link import Link
from arm import Arm
from predefined_robots import simple_human_arm, noodle_arm
from maddux.robots.link import Link
from maddux.robots.arm import Arm
from maddux.robots.predefined_robots import simple_human_arm, noodle_arm
8 changes: 4 additions & 4 deletions maddux/robots/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A robot arm defined by a sequence of DH links
"""
import numpy as np
import utils
from maddux.robots import utils


class Arm:
Expand Down Expand Up @@ -252,14 +252,14 @@ def ikine(self, p, num_iterations=1000, alpha=0.1):
"""
# Check to make sure alpha is between 0 and 1
if not (0.0 <= alpha <= 1.0):
print "Invalid alpha. Defaulting to 0.1"
print("Invalid alpha. Defaulting to 0.1")
alpha = 0.1

q = self.get_current_joint_config()
self.qs = np.array([q.copy()])

goal = utils.create_homogeneous_transform_from_point(p)
for i in xrange(num_iterations):
for i in range(num_iterations):
# Calculate position error of the end effector
curr = self.fkine(q)
err = goal - curr
Expand Down Expand Up @@ -394,5 +394,5 @@ def save_path(self, filename):
:type filename: str
"""
if len(self.qs) == 0:
print "No path to save"
print("No path to save")
np.save(filename, self.qs)
8 changes: 4 additions & 4 deletions maddux/robots/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def display(self):

:rtype: None
"""
print 'Link angle: {}'.format(self.theta)
print 'Link offset: {}'.format(self.offset)
print 'Link length: {}'.format(self.length)
print 'Link twist: {}'.format(self.twist)
print('Link angle: {}'.format(self.theta))
print('Link offset: {}'.format(self.offset))
print('Link length: {}'.format(self.length))
print('Link twist: {}'.format(self.twist))

def plot(self, ax):
"""Plots the link on the given matplotlib figure
Expand Down
4 changes: 2 additions & 2 deletions maddux/robots/predefined_robots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from link import Link
from arm import Arm
from maddux.robots.link import Link
from maddux.robots.arm import Arm
import numpy as np


Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from setuptools import setup

setup(name='maddux',
version='1.0.0',
install_requires=['numpy', 'matplotlib'] # And any other dependencies foo needs

)