Message Handlers¶
- mil_tools.pose_to_numpy(pose: Pose) Tuple[float, float] [source]¶
Turns a
Pose
message into a tuple of position and orientation.Warning
This method relies on a method (
mil_ros_tools.rosmsg_to_numpy()
) which will be deprecated in the future. This method will need to be updated.
- mil_tools.twist_to_numpy(twist: Twist)[source]¶
Turns a
Twist
message into a tuple of linear and angular speeds.Warning
This method relies on a method (
mil_ros_tools.rosmsg_to_numpy()
) which will be deprecated in the future. This method will need to be updated.
- mil_tools.posetwist_to_numpy(posetwist: PoseTwist)[source]¶
Turns a
PoseTwist
message into pose position, pose orientation, twist linear, and twist angular.Warning
This method relies on a method (
mil_ros_tools.rosmsg_to_numpy()
) which will be deprecated in the future. This method will need to be updated.- Parameters
twist (PoseTwist) – The pose + twist message.
- Returns
The tuple of linear and angular speeds.
- Return type
Tuple[Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray]]
- mil_tools.odometry_to_numpy(odom: Odometry)[source]¶
Turns a
Odometry
message into its pose, twist, pose covariance, and twist covariance.Warning
This method relies on a method (
mil_ros_tools.rosmsg_to_numpy()
) which will be deprecated in the future. This method will need to be updated.- Parameters
odom (Odometry) – The odometry message.
- Returns
- Tuple[Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray],
np.ndarray, np.ndarray]: The tuple of pose, twist, pose covariance, and twist covariance.
- mil_tools.wrench_to_numpy(wrench: Wrench)[source]¶
Turns a
Wrench
message into its force and torque, represented as numpy arrays.Warning
This method relies on a method (
mil_ros_tools.rosmsg_to_numpy()
) which will be deprecated in the future. This method will need to be updated.- Parameters
wrench (Wrench) – The wrench message.
- Returns
The tuple of force and torque.
- Return type
Tuple[np.ndarray, np.ndarray]
- mil_tools.numpy_to_point(vector: ndarray) Point [source]¶
Turns a List[
float
] into aPoint
message.- Parameters
vector (np.ndarray) – The vector to convert
- Returns
The constructed message.
- Return type
geometry_msgs.Point
- mil_tools.numpy_to_point2d(vector: ndarray) Point2D [source]¶
Turns a
np.ndarray
into aPoint2D
message.- Parameters
vector (np.ndarray) – The vector to convert. Should have two values, the first of which represents x and the other y.
- Returns
The constructed message.
- Return type
- mil_tools.numpy_to_quaternion(np_quaternion: ndarray) Quaternion [source]¶
Turns a List[
float
] into aQuaternion
message.- Parameters
np_quaternion (np.ndarray) – The vector to convert. Should have four values, representing
x
,y
,z
, andw
.- Returns
The constructed message.
- Return type
- mil_tools.numpy_to_twist(linear_vel: ndarray, angular_vel: ndarray) Twist [source]¶
Turns two
np.ndarray`s into a :class:`Twist
message.- Parameters
linear_vel (np.ndarray) – The vector to convert. Values should represent the individual components of
x
,y
, andz
.angular_vel (np.ndarray) – The vector to convert. Values should represent the individual components of
x
,y
, andz
.
- Returns
The constructed message.
- Return type
- mil_tools.numpy_to_wrench(forcetorque: ndarray)[source]¶
Turns a np.ndarray into a
Wrench
message.- Parameters
forcetorque (np.ndarray) – The vector to convert. Values should represent the individual components of
force.x
,force.y
,force.z
,torque.x
,torque.y
, andtorque.z
.- Returns
The constructed message.
- Return type
- mil_tools.numpy_matrix_to_quaternion(np_matrix: ndarray)[source]¶
Given a 3x3 rotation matrix, convert to a quaternion, and return the quaternion as a ROS message.
- Parameters
np_matrix (np.ndarray) – The 3x3 rotation matrix.
- Returns
The constructed message.
- Return type
- mil_tools.numpy_pair_to_pose(np_translation: ndarray, np_rotation_matrix: ndarray) Pose [source]¶
Convert a rotation matrix and point pair to a Pose message.
- Parameters
np_translation (np.ndarray) – An array of 2 or 3 points representing the object’s position.
np_rotation_matrix (np.ndarray) – A 3x3 rotation matrix.
- Returns
The Pose message with the position and orientation.
- Return type
geometry_msgs.Pose
- mil_tools.numpy_quat_pair_to_pose(np_translation: ndarray, np_quaternion: ndarray) Pose [source]¶
Convert a quaternion array and point array pair to a Pose message.
- Parameters
np_translation (np.ndarray) – An array of 2 or 3 points representing the object’s position.
np_quaternion (np.ndarray) – An array with 4 points, representing
x
,y
,z
, andw
of a quaternion describing the object.
- Returns
The Pose message with the position and orientation.
- Return type
geometry_msgs.Pose
- mil_tools.numpy_to_points(points: List[ndarray]) List[Point] [source]¶
Convert a list of
np.ndarray`s into :class:`Point
messages.- Parameters
points (List[np.ndarray]) – The points that will be converted to messages.
- Returns
The resulting point messages.
- Return type
List[Point]
- mil_tools.numpy_to_polygon(polygon: List[ndarray]) Polygon [source]¶
Convert a list of
np.ndarray`s (representing :class:`Point`s) into a :class:`Polygon
message.- Parameters
points (List[np.ndarray]) – The points that will be added to the polygon.
- Returns
The resulting message.
- Return type
- mil_tools.numpy_to_vector3(vec: ndarray) Vector3 [source]¶
Convert a
np.ndarray
offloat`s with length 3 into a :class:`Vector3
message.- Parameters
vec (np.ndarray) – A numpy array with
x
,y
, andz
.- Returns
The Vector3 message.
- Return type
- mil_tools.numpy_to_pose2D(pose: ndarray) Pose2D [source]¶
Convert a
np.ndarray
offloat`s with length 3 into a :class:`Pose2D
message.- Parameters
pose (np.ndarray) – A numpy array with
x
,y
, andtheta
.- Returns
The Pose2D message.
- Return type
- mil_tools.numpy_to_colorRGBA(color: ndarray) ColorRGBA [source]¶
Convert a
np.ndarray
offloat`s with length 4 into a :class:`ColorRGBA
message.- Parameters
color (np.ndarray) – A numpy array with
r
,g
,b
, anda
.- Returns
The ColorRGBA message.
- Return type
- mil_tools.numpy_to_pointcloud2(points: ndarray, stamp: Optional[Time] = None, frame_id: Optional[str] = None) PointCloud2 [source]¶
Create a sensor_msgs.PointCloud2 from an array of points.
- Parameters
points (np.ndarray) – The array of points.
stamp (Optional[genpy.rostime.Time]) – An optional timestamp for the message header.
frame_id (Optional[str]) – An optional string describing the frame associated with the point cloud.
- Returns
A PointCloud2 message with the provided information.
- Return type
- mil_tools.make_wrench_stamped(force: List[float], torque: List[float], frame: str = '/body')[source]¶
Makes a WrenchStamped message.
- Parameters
force (List[float]) – An array representing the force components. The list should contain
force.x
,force.y
,force.z
.torque (List[float]) – An array representing the torque components. The list should contain
torque.x
,torque.y
, andtorque.z
.frame (str) – The frame to attach to the header. Defaults to
/body
.
- Returns
The constructed message.
- Return type
- mil_tools.make_pose_stamped(position: List[float], orientation: List[float], frame: str = '/body') WrenchStamped [source]¶
Makes a PoseStamped message.
- Parameters
position (List[float]) – An array representing the force components. The list should contain
position.x
,position.y
,position.z
.orientation (List[float]) – An array representing the torque components. The list should contain
orientation.x
,orientation.y
,orientation.z
, andorientation.w
.frame (str) – The frame to attach to the header. Defaults to
/body
.
- Returns
The constructed message.
- Return type