Skip to content

Commit 946e1dc

Browse files
author
Michael Koval
committed
Merge branch 'master' into bugfix/postprocess_path_params
2 parents 997f475 + 40f7894 commit 946e1dc

File tree

12 files changed

+364
-642
lines changed

12 files changed

+364
-642
lines changed

CHANGELOG.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22
Changelog for package prpy
33
^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
0.5.1 (2015-04-15)
6+
------------------
7+
* Merge branch 'feature/MICORefactor' of github.com:personalrobotics/prpy into feature/MICORefactor
8+
* Fixed ParabolicSmoother bug (thanks @rdiankov)
9+
* added code to cleanup ik solver, changed acceleration to 1.5
10+
* Added some hacks for ParabolicSmoother.
11+
* More retiming fixes.
12+
* Added a few useful log messages.
13+
* Cleaned up wrappers for OpenRAVE retimers.
14+
* Fixed Open/Close/CloseTight functions on MicoHand.
15+
* Set acceleration limits by default.
16+
* Convert CBiRRT "direction" to a NumPy array.
17+
* Merge branch 'master' into feature/MICORefactor
18+
Conflicts:
19+
src/prpy/base/robot.py
20+
* Merge pull request `#95 <https://github.com/personalrobotics/prpy/issues/95>`_ from personalrobotics/feature/SmoothingRefactor2
21+
Trajectory timing/smoothing refactor 2.0.
22+
* Merge pull request `#108 <https://github.com/personalrobotics/prpy/issues/108>`_ from personalrobotics/bugfix/issue99
23+
Fixed two bugs in vectorfield planner.
24+
* Made robot.simplifier optional.
25+
* Load an IdealController in simulation.
26+
* Fixed two bugs in planner
27+
Fixed two bugs:
28+
1. Missing `abs`
29+
2. Changed default `dt_multiplier` to 1.01 so that `numsteps` floors to 1 by default.
30+
* Fixed weird superclass issue.
31+
* Removed multi-controller references from Mico.
32+
* More MicoHand cleanup.
33+
* Started removing BH-specific code from MicoHand
34+
* Removed MICORobot, since it does nothing.
35+
* Load or_nlopt_ik by default.
36+
* PEP-8 fixes.
37+
* Removed more dead code from Mico.
38+
* Rearranged Mico file.
39+
* Removed PlanToNamedConfiguration from Mico.
40+
* Removed OWD-specific code from the Mico.
41+
* Documented ExecutePath and ExecuteTrajectory.
42+
* Simplified PostProcessPath with defer=True.
43+
* Rough PostProcessPath function.
44+
* Contributors: Michael Koval, Siddhartha Srinivasa, Stefanos Nikolaidis
45+
546
0.5.0 (2015-04-07)
647
------------------
748
* Fixed the OMPL planner creation test.

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package>
33
<name>prpy</name>
4-
<version>0.5.0</version>
4+
<version>0.5.1</version>
55
<description>
66
Python utilities used by the Personal Robotics Laboratory.
77
</description>

src/prpy/base/mico.py

Lines changed: 41 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -28,231 +28,71 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31-
import numpy, openravepy, rospy
31+
import openravepy
3232
from manipulator import Manipulator
33-
from prpy.clone import Clone
34-
from .. import util
35-
from .. import exceptions
36-
from IPython import embed
3733

3834
class Mico(Manipulator):
39-
def _load_controllers(self, controllers, timeout=10):
40-
from controller_manager_msgs.srv import SwitchController, ListControllers
41-
"""Load a list of ros_control controllers by name."""
42-
43-
rospy.wait_for_service('controller_manager/switch_controller', timeout=10)
44-
rospy.wait_for_service('controller_manager/list_controllers', timeout=10)
45-
46-
switch_controllers = rospy.ServiceProxy(
47-
'controller_manager/switch_controller', SwitchController)
48-
list_controllers = rospy.ServiceProxy(
49-
'controller_manager/list_controllers', ListControllers)
50-
51-
running = set([c.name for c in list_controllers().controller if c.state == "running"])
52-
controllers = set(controllers)
53-
switch_controllers(list(controllers - running), list(running - controllers), 2)
54-
55-
def _unload_controllers(self, controllers):
56-
from controller_manager_msgs.srv import SwitchController, ListControllers
57-
"""Unload a list of ros_control controllers by name"""
58-
59-
rospy.wait_for_service('controller_manager/switch_controller')
60-
rospy.wait_for_service('controller_manager/list_controllers')
61-
62-
switch_controllers = rospy.ServiceProxy(
63-
'controller_manager/switch_controller', SwitchController)
64-
list_controllers = rospy.ServiceProxy(
65-
'controller_manager/list_controllers', ListControllers)
66-
67-
running = set([c.name for c in list_controllers().controller
68-
if c.state == "running"])
69-
controllers = set(controllers)
70-
switch_controllers([], list(controllers & running), 2)
71-
72-
73-
def __init__(self, sim, controller_namespace,
35+
def __init__(self, sim,
7436
iktype=openravepy.IkParameterization.Type.Transform6D):
7537
Manipulator.__init__(self)
7638

7739
self.simulated = sim
78-
# TODO: learn how to attach an ideal controller controller
79-
#self.controller = self.GetRobot().AttachController(name=self.GetName(),
80-
#args='OWDController {0:s} {1:s}'.format('prpy', owd_namespace),
81-
#dof_indices=self.GetArmIndices(), affine_dofs=0, simulated=sim)
82-
# self.controller = self.GetRobot().AttachController(name=self.GetName(),
83-
# args='MicoController {0:s} {1:s}'.format('prpy', controller_namespace),
84-
# dof_indices=self.GetArmIndices(), affine_dofs=0, simulated=sim)
85-
# Load the IK database.
86-
robot = self.GetRobot()
87-
if (sim == True):
88-
self.controller = self.GetRobot().AttachController(name=self.GetName(),
89-
args='idealcontroller'.format('prpy', controller_namespace),
90-
dof_indices=self.GetArmIndices(), affine_dofs=0, simulated=sim)
91-
else:
92-
#self.controller = self.GetRobot().AttachController(name=self.GetName(),
93-
#args='roscontroller openrave {0} 1'.format(rospy.get_namespace()),
40+
self.iktype = iktype
9441

95-
self.or_physical_controller = ('roscontroller openrave {0} 1'.format(rospy.get_namespace()))
96-
self.ros_controllers = [
97-
"traj_controller",
98-
"joint_state_controller",
99-
]
100-
or_controller_string = self.or_physical_controller
101-
self._load_controllers(self.ros_controllers)
102-
env = robot.GetEnv()
103-
with env:
104-
self.controller = openravepy.RaveCreateController(env,
105-
or_controller_string)
106-
m = robot.GetActiveDOFIndices()
107-
c = self.controller
108-
robot.SetController(c, m, 0)
109-
110-
#self.hand_controller = self.GetRobot().AttachController(name=self.GetRobot().GetName(),
111-
#args='MicoHandController {0:s} {1:s}'.format('prpy', '/mico_hand_controller'),
112-
#dof_indices=self.GetGripperIndices(), affine_dofs=0, simulated=sim)
42+
robot = self.GetRobot()
43+
env = robot.GetEnv()
11344

114-
45+
with env:
46+
dof_indices = self.GetIndices()
47+
accel_limits = robot.GetDOFAccelerationLimits()
48+
accel_limits[dof_indices[0:3]] = 1.2
49+
accel_limits[dof_indices[3:6]] = 1.0
50+
robot.SetDOFAccelerationLimits(accel_limits)
11551

116-
'''
52+
# Load or_nlopt_ik as the IK solver. Unfortunately, IKFast doesn't work
53+
# on the Mico.
11754
if iktype is not None:
118-
with robot:
119-
self.SetActive()
120-
self.ikmodel = openravepy.databases.inversekinematics.InverseKinematicsModel(robot, iktype=iktype)
121-
if not self.ikmodel.load():
122-
self.ikmodel.autogenerate()
123-
'''
124-
# Enable servo motions in simulation mode.
125-
from prpy.simulation import ServoSimulator
126-
self.servo_simulator = ServoSimulator(self, rate=20, watchdog_timeout=0.1)
127-
128-
def CloneBindings(self, parent):
129-
self.__init__(True, None)
130-
131-
def PlanToNamedConfiguration(self, name, execute=True, **kw_args):
132-
"""
133-
Plan this arm to saved configuration stored in robot.configurations by
134-
ignoring any other DOFs specified in the named configuration.
135-
@param name name of a saved configuration
136-
@param **kw_args optional arguments passed to PlanToConfiguration
137-
@returns traj trajectory
138-
"""
139-
robot = self.GetRobot()
140-
saved_dof_indices, saved_dof_values = robot.configurations.get_configuration(name)
141-
142-
with Clone(robot.GetEnv()) as cloned_env:
143-
cloned_env.Cloned(self).SetActive()
144-
cloned_robot = cloned_env.Cloned(robot)
55+
self.iksolver = openravepy.RaveCreateIkSolver(env, 'NloptIK')
56+
self.SetIKSolver(self.iksolver)
14557

146-
arm_dof_indices = cloned_robot.GetActiveDOFIndices()
147-
arm_dof_values = cloned_robot.GetActiveDOFValues()
58+
# Load simulation controllers.
59+
if sim:
60+
from prpy.simulation import ServoSimulator
14861

149-
for arm_dof_index, arm_dof_value in zip(saved_dof_indices, saved_dof_values):
150-
if arm_dof_index in arm_dof_indices:
151-
i = list(arm_dof_indices).index(arm_dof_index)
152-
arm_dof_values[i] = arm_dof_value
62+
self.controller = robot.AttachController(
63+
self.GetName(), '', self.GetArmIndices(), 0, True)
64+
self.servo_simulator = ServoSimulator(self, rate=20,
65+
watchdog_timeout=0.1)
15366

154-
traj = cloned_robot.PlanToConfiguration(arm_dof_values, execute=False, **kw_args)
67+
def CloneBindings(self, parent):
68+
super(Mico, self).CloneBindings(parent)
15569

156-
# Copy the trajectory back to the original environment.
157-
from ..util import CopyTrajectory
158-
live_traj = CopyTrajectory(traj, env=robot.GetEnv())
70+
self.simulated = True
71+
self.iktype = parent.iktype
15972

160-
if execute:
161-
return robot.ExecuteTrajectory(live_traj, **kw_args)
162-
else:
163-
return live_traj
73+
self.servo_simulator = None
16474

165-
def SetStiffness(manipulator, stiffness):
75+
# TODO: This is broken on nlopt_ik
16676
"""
167-
Set the Mico's stiffness. This enables or disables gravity compensation.
168-
Values between 0 and 1 are experimental.
169-
@param stiffness value between 0.0 and 1.0
77+
if parent.iktype is not None:
78+
self.iksolver = openravepy.RaveCreateIkSolver(env, 'NloptIK')
79+
self.SetIKSolver(self.iksolver)
17080
"""
171-
if not (0 <= stiffness <= 1):
172-
raise Exception('Stiffness must in the range [0, 1]; got %f.' % stiffness)
173-
174-
if not manipulator.simulated:
175-
manipulator.controller.SendCommand('SetStiffness {0:f}'.format(stiffness))
17681

177-
def Servo(manipulator, velocities):
82+
def Servo(self, velocities):
17883
"""
17984
Servo with an instantaneous vector of joint velocities.
18085
@param velocities instantaneous joint velocities in radians per second
18186
"""
182-
num_dof = len(manipulator.GetArmIndices())
183-
if len(velocities) != num_dof:
184-
raise ValueError('Incorrect number of joint velocities. Expected {0:d}; got {0:d}.'.format(
185-
num_dof, len(velocities)))
186-
187-
if not manipulator.simulated:
188-
manipulator.controller.SendCommand('Servo ' + ' '.join([ str(qdot) for qdot in velocities ]))
189-
else:
190-
manipulator.controller.Reset(0)
191-
manipulator.servo_simulator.SetVelocity(velocities)
192-
193-
def ServoTo(manipulator, target, duration, timeStep = 0.05, collisionChecking= True):
194-
"""
195-
Servo's the Mico to the target taking the duration passed to it
196-
@param target desired joint angles
197-
@param duration duration in seconds
198-
@param timestep period of the control loop
199-
@param collisionchecking check collisions in the simulation environment
200-
"""
201-
steps = int(math.ceil(duration/timeStep))
202-
original_dofs = manipulator.GetRobot().GetDOFValues(manipulator.GetArmIndices())
203-
velocity = numpy.array(target-manipulator.GetRobot().GetDOFValues(manipulator.GetArmIndices()))
204-
velocities = v/steps#[v/steps for v in velocity]
205-
inCollision = False
206-
if collisionChecking==True:
207-
inCollision = manipulator.CollisionCheck(target)
208-
if inCollision == False:
209-
for i in range(1,steps):
210-
manipulator.Servo(velocities)
211-
time.sleep(timeStep)
212-
manipulator.Servo([0] * len(manipulator.GetArmIndices()))
213-
new_dofs = manipulator.GetRobot().GetDOFValues(manipulator.GetArmIndices())
214-
return True
215-
return False
87+
num_dof = len(self.GetArmIndices())
21688

217-
def SetVelocityLimits(self, velocity_limits, min_accel_time,
218-
openrave=True, owd=True):
219-
"""
220-
Change the OpenRAVE and OWD joint velocity limits. Joint velocities
221-
that exceed these limits will trigger a velocity fault.
222-
@param velocity_limits vector of joint velocity limits in radians per second
223-
@param min_accel_time minimum acceleration time used to compute acceleration limits
224-
@param openrave flag to set the OpenRAVE velocity limits
225-
@param owd flag to set the OWD velocity limits
226-
"""
227-
# Update the OpenRAVE limits.
228-
if openrave:
229-
Manipulator.SetVelocityLimits(self, velocity_limits, min_accel_time)
230-
231-
# Update the OWD limits.
232-
if owd and not self.simulated:
233-
args = [ 'SetSpeed' ]
234-
args += [ str(min_accel_time) ]
235-
args += [ str(velocity) for velocity in velocity_limits ]
236-
args_str = ' '.join(args)
237-
self.controller.SendCommand(args_str)
89+
if len(velocities) != num_dof:
90+
raise ValueError(
91+
'Incorrect number of joint velocities.'
92+
' Expected {:d}; got {:d}.'.format(num_dof, len(velocities)))
23893

239-
def GetTrajectoryStatus(manipulator):
240-
"""
241-
Gets the status of the current (or previous) trajectory executed by the
242-
controller.
243-
@return status of the current (or previous) trajectory executed
244-
"""
245-
if not manipulator.simulated:
246-
return manipulator.controller.SendCommand('GetStatus')
94+
if self.simulated:
95+
self.GetRobot().GetController().Reset(0)
96+
self.servo_simulator.SetVelocity(velocities)
24797
else:
248-
if manipulator.controller.IsDone():
249-
return 'done'
250-
else:
251-
return 'active'
252-
253-
def ClearTrajectoryStatus(manipulator):
254-
"""
255-
Clears the current trajectory execution status.
256-
"""
257-
if not manipulator.simulated:
258-
manipulator.controller.SendCommand('ClearStatus')
98+
raise NotImplementedError('Servo is not implemented.')

0 commit comments

Comments
 (0)