17 from copy
import deepcopy
19 from visualization_msgs.msg
import MarkerArray
20 from uuv_waypoints
import Waypoint, WaypointSet
22 quaternion_from_euler, rotation_matrix, quaternion_from_matrix
24 from ..trajectory_point
import TrajectoryPoint
25 from .._log
import get_logger
29 """Base class to be inherited by custom path generator 30 to generate paths from interpolated waypoints. 34 * `LABEL` (*type:* `str`): Name of the path generator 38 * `full_dof` (*type:* `bool`, *default:* `False`): If `True`, generate 39 6 DoF paths, if `False`, roll and pitch are set to zero. 65 self.
_init_rot = quaternion_about_axis(0.0, [0, 0, 1])
66 self.
_last_rot = quaternion_about_axis(0.0, [0, 0, 1])
73 """Factory method for all derived path generators. 77 * `name` (*type:* `str`): Name identifier of the path generator 78 * `args` (*type:* `list`): List of arguments for the path generator constructor 79 * `kwards` (*type:* `dict`): Keyword arguments for the path generator constructor 83 An instance of the desired path generator. If the `name` input 84 does not describe any of the derived path generator classes, an 85 `ValueError` will be raised. 87 for gen
in PathGenerator.__subclasses__():
89 return gen(*args, **kwargs)
91 msg =
'Invalid path generator method' 92 self._logger.error(msg)
97 """Get the name identifiers of all path generator classes. 104 for gen
in PathGenerator.__subclasses__():
105 generators.append(gen())
110 """`uuv_waypoints.WaypointSet`: Set of waypoints""" 115 """`float`: Absolute final timestamp assigned to the path in seconds""" 120 """`float`: Duration in seconds for the whole path""" 125 assert t > 0,
'Duration must be a positive value' 130 """`float`: Start timestamp assigned to the first waypoint""" 135 assert time >= 0,
'Invalid negative time' 140 """`uuv_waypoints.Waypoint`: Return the closest waypoint 141 to the current position on the path. 147 """Return the index of the closest waypoint to the current 148 position on the path. 154 return len(self.
_s) - 1
161 """`float`: Value of the step size for the path's parametric 173 """`data_type`: Property description""" 186 if len(self.
_s) == 0:
193 idx = self._s.size - 1
195 idx = (self.
_s - s >= 0).nonzero()[0][0]
202 return np.unique(wps)
204 self._logger.error(
'Invalid segment index')
217 raise NotImplementedError()
220 raise NotImplementedError()
226 """Add waypoint to the existing waypoint set. If no waypoint set has 227 been initialized, create new waypoint set structure and add the given 231 self._waypoints.add_waypoint(waypoint, add_to_beginning)
235 if waypoints
is not None:
239 self._logger.error(
'Waypoint list has not been initialized')
243 self._logger.info(
'Setting initial rotation as={}'.format(init_rot))
247 return self._interp_fcns[tag](s)
262 raise NotImplementedError()
265 raise NotImplementedError()
268 raise NotImplementedError()
271 raise NotImplementedError()
274 if np.isclose(dx, 0)
and np.isclose(dy, 0):
277 heading = np.arctan2(dy, dx)
278 rotq = quaternion_about_axis(heading, [0, 0, 1])
281 rote = quaternion_about_axis(
282 -1 * np.arctan2(dz, np.sqrt(dx**2 + dy**2)),
284 rotq = quaternion_multiply(rotq, rote)
def get_generator(name, args, kwargs)
def get_remaining_waypoints_idx(self, s)
def get_visual_markers(self)
def init_waypoints(self, waypoints=None, init_rot=np.array([0, 0, 0, 1]))
def __init__(self, full_dof=False)
def _compute_rot_quat(self, dx, dy, dz)
def init_interpolator(self)
def closest_waypoint(self)
def get_segment_idx(self, s)
def add_waypoint(self, waypoint, add_to_beginning=False)
def closest_waypoint_idx(self)
def interpolate(self, tag, s)
def generate_quat(self, s)
def get_samples(self, max_time, step=0.005)
def set_full_dof(self, flag)
def termination_by_time(self)
def generate_pnt(self, s)
def generate_pos(self, s)
def set_parameters(self, params)