|
31 | 31 | import abc
|
32 | 32 | import functools
|
33 | 33 | import logging
|
| 34 | +import numpy |
34 | 35 | import openravepy
|
35 | 36 | from ..clone import Clone
|
36 | 37 | from ..util import CopyTrajectory, GetTrajectoryTags, SetTrajectoryTags
|
@@ -97,10 +98,35 @@ def __call__(self, instance, robot, *args, **kw_args):
|
97 | 98 | env = robot.GetEnv()
|
98 | 99 | defer = kw_args.get('defer')
|
99 | 100 |
|
| 101 | + # Store the original joint values and indices. |
| 102 | + joint_indices = [robot.GetActiveDOFIndices(), None] |
| 103 | + joint_values = [robot.GetActiveDOFValues(), None] |
| 104 | + |
100 | 105 | with Clone(env, clone_env=instance.env,
|
101 | 106 | lock=True, unlock=False) as cloned_env:
|
102 | 107 | cloned_robot = cloned_env.Cloned(robot)
|
103 | 108 |
|
| 109 | + # Store the cloned joint values and indices. |
| 110 | + joint_indices[1] = cloned_robot.GetActiveDOFIndices() |
| 111 | + joint_values[1] = cloned_robot.GetActiveDOFValues() |
| 112 | + |
| 113 | + # Check for mismatches in the cloning and hackily reset them. |
| 114 | + # (This is due to a possible bug in OpenRAVE environment cloning where in |
| 115 | + # certain situations, the Active DOF ordering and values do not match the |
| 116 | + # parent environment. It seems to be exacerbated by multirotation joints, |
| 117 | + # but the exact cause and repeatability is unclear at this point.) |
| 118 | + if not numpy.array_equal(joint_indices[0], joint_indices[1]): |
| 119 | + logger.warning("Cloned Active DOF index mismatch: %s != %s", |
| 120 | + str(joint_indices[0]), |
| 121 | + str(joint_indices[1])) |
| 122 | + cloned_robot.SetActiveDOFs(joint_indices[0]) |
| 123 | + |
| 124 | + if not numpy.allclose(joint_values[0], joint_values[1]): |
| 125 | + logger.warning("Cloned Active DOF value mismatch: %s != %s", |
| 126 | + str(joint_values[0]), |
| 127 | + str(joint_values[1])) |
| 128 | + cloned_robot.SetActiveDOFValues(joint_values[0]) |
| 129 | + |
104 | 130 | def call_planner():
|
105 | 131 | try:
|
106 | 132 | planner_traj = self.func(instance, cloned_robot,
|
|
0 commit comments