16 from uuv_control_msgs.msg
import Waypoint
as WaypointMessage
20 """Waypoint data structure 24 * `FINAL_WAYPOINT_COLOR` (*type:* list of `float`, *value:* `[1.0, 0.5737, 0.0]`): RGB color for marker of the final waypoint in RViz 25 * `OK_WAYPOINT` (*type:* list of `float`, *value:* `[0.1216, 0.4157, 0.8863]`): RGB color for marker of a successful waypoint in RViz 26 * `FAILED_WAYPOINT` (*type:* list of `float`, *value:* `[1.0, 0.0, 0.0]`): RGB color for marker of a failed waypoint in RViz 30 * `x` (*type:* `float`, *default:* `0`): X coordinate in meters 31 * `y` (*type:* `float`, *default:* `0`): Y coordinate in meters 32 * `z` (*type:* `float`, *default:* `0`): Z coordinate in meters 33 * `max_forward_speed` (*type:* `float`, *default:* `0`): Reference maximum forward speed in m/s 34 * `heading_offset` (*type:* `float`, *default:* `0`): Heading offset to be added to the computed heading reference in radians 35 * `use_fixed_heading` (*type:* `float`, *default:* `False`): Use the heading offset as a fixed heading reference in radians 36 * `inertial_frame_id` (*type:* `str`, *default:* `'world'`): Name of the inertial reference frame, options are `world` or `world_ned` 37 * `radius_acceptance` (*type:* `float`, *default:* `0`): Radius around the waypoint where the vehicle can be considered to have reached the waypoint 40 FINAL_WAYPOINT_COLOR = [1.0, 131.0 / 255, 0.0]
41 OK_WAYPOINT = [31. / 255, 106. / 255, 226. / 255]
42 FAILED_WAYPOINT = [1.0, 0.0, 0.0]
44 def __init__(self, x=0, y=0, z=0, max_forward_speed=0, heading_offset=0,
45 use_fixed_heading=
False, inertial_frame_id=
'world', radius_acceptance=0.0):
46 assert inertial_frame_id
in [
'world',
'world_ned'], \
47 'Invalid inertial reference frame, options' \
48 ' are world or world_ned, provided={}'.format(inertial_frame_id)
60 return self.
_x == other.x
and self.
_y == other.y
and self.
_z == other.z
63 return self.
_x != other.x
or self.
_y != other.y
or self.
_z != other.z
66 msg =
'(x, y, z)= (%.2f, %.2f, %.2f) m\n' % (self.
_x, self.
_y, self.
_z)
69 msg +=
'Heading offset = %.2f degrees\n' % (self.
_heading_offset * 180 / np.pi)
74 """`str`: Name of the inertial reference frame""" 77 @inertial_frame_id.setter
79 assert frame_id
in [
'world',
'world_ned']
84 """`float`: X coordinate of the waypoint in meters""" 89 """`float`: Y coordinate of the waypoint in meters""" 94 """`float`: Z coordinate of the waypoint in meters""" 99 """`numpy.ndarray`: Position 3D vector""" 100 return np.array([self.
_x, self.
_y, self.
_z])
104 if isinstance(new_pos, list):
105 assert len(new_pos) == 3,
'New position must have three elements' 106 elif isinstance(new_pos, np.ndarray):
107 assert new_pos.shape == (3,),
'New position must have three elements' 109 raise Exception(
'Invalid position vector size')
116 """`bool`: Flag on constraint violation for this waypoint""" 119 @violates_constraint.setter
125 """`float`: Maximum reference forward speed""" 128 @max_forward_speed.setter
134 """`float`: Heading offset in radians""" 139 """`float`: Heading reference stored for this waypoint in radians""" 148 """`float`: Radius of acceptance in meters""" 151 @radius_of_acceptance.setter
153 assert radius >= 0,
'Radius must be greater or equal to zero' 158 """`float`: Flag to use the heading offset""" 162 """Return the waypoint marker's color 166 RGB color as a `list` 171 """Return the RGB color for the final waypoint 175 RGB color as a `list` 180 """Set waypoint parameters from `uuv_control_msgs/Waypoint` 185 * `msg` (*type:* `uuv_control_msgs/Waypoint`): Waypoint message 190 self.
_x = msg.point.x
191 self.
_y = msg.point.y
192 self.
_z = msg.point.z
199 """Convert waypoint to `uuv_control_msgs/Waypoint` message 203 `uuv_control_msgs/Waypoint` message 205 wp = WaypointMessage()
217 """Compute distance of waypoint to a point 221 * `pos` (*type:* list of `float`): 3D position vector 225 Distance to point in meters 227 return np.sqrt((self.
_x - pos[0])**2 +
228 (self.
_y - pos[1])**2 +
229 (self.
_z - pos[2])**2)
232 """Compute heading to target waypoint 236 * `target` (*type:* `uuv_waypoints/Waypoint`): Target waypoint 240 Heading angle in radians 242 dy = target.y - self.
y 243 dx = target.x - self.
x 244 return np.arctan2(dy, dx)
def get_final_color(self)
def from_message(self, msg)
def calculate_heading(self, target)
def violates_constraint(self)
def inertial_frame_id(self)
def max_forward_speed(self)
def __init__(self, x=0, y=0, z=0, max_forward_speed=0, heading_offset=0, use_fixed_heading=False, inertial_frame_id='world', radius_acceptance=0.0)
def radius_of_acceptance(self)
def using_heading_offset(self)
list FINAL_WAYPOINT_COLOR