diff --git a/.gitignore b/.gitignore index 1b85453..efc6e98 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.gitignore~ saved_experiments/ *.ipynb_checkpoints/ +maddux.egg-info/ diff --git a/README.md b/README.md index 385a2fc..79f285d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/maddux/__init__.py b/maddux/__init__.py index 9d8fe43..90f9962 100644 --- a/maddux/__init__.py +++ b/maddux/__init__.py @@ -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 diff --git a/maddux/environment.py b/maddux/environment.py index 777d970..875c968 100644 --- a/maddux/environment.py +++ b/maddux/environment.py @@ -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 @@ -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() diff --git a/maddux/objects/__init__.py b/maddux/objects/__init__.py index fa8a063..fb29af0 100644 --- a/maddux/objects/__init__.py +++ b/maddux/objects/__init__.py @@ -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 diff --git a/maddux/objects/ball.py b/maddux/objects/ball.py index fb1551a..b6196fb 100644 --- a/maddux/objects/ball.py +++ b/maddux/objects/ball.py @@ -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 diff --git a/maddux/objects/obstacle.py b/maddux/objects/obstacle.py index abce276..15d713d 100644 --- a/maddux/objects/obstacle.py +++ b/maddux/objects/obstacle.py @@ -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): @@ -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 diff --git a/maddux/objects/target.py b/maddux/objects/target.py index af68081..b9f32eb 100644 --- a/maddux/objects/target.py +++ b/maddux/objects/target.py @@ -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 @@ -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): """ diff --git a/maddux/objects/throwable.py b/maddux/objects/throwable.py index 557b03a..3cf0aa5 100644 --- a/maddux/objects/throwable.py +++ b/maddux/objects/throwable.py @@ -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 @@ -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)) diff --git a/maddux/robots/__init__.py b/maddux/robots/__init__.py index 87daeff..614d969 100644 --- a/maddux/robots/__init__.py +++ b/maddux/robots/__init__.py @@ -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 diff --git a/maddux/robots/arm.py b/maddux/robots/arm.py index 361b1a9..811d11a 100644 --- a/maddux/robots/arm.py +++ b/maddux/robots/arm.py @@ -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: @@ -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 @@ -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) diff --git a/maddux/robots/link.py b/maddux/robots/link.py index cb85c53..03b96bb 100644 --- a/maddux/robots/link.py +++ b/maddux/robots/link.py @@ -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 diff --git a/maddux/robots/predefined_robots.py b/maddux/robots/predefined_robots.py index f9f7ee1..122e698 100644 --- a/maddux/robots/predefined_robots.py +++ b/maddux/robots/predefined_robots.py @@ -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 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d28519b..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -matplotlib -mplot3d diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f583cf0 --- /dev/null +++ b/setup.py @@ -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 + +)