Skip to main content

Module message

Module message 

Source
Expand description

The std URN message types (blueprint §9.2, §24.3).

AstrsMessage itself lives in astrs-data — it has to, since astrs-idl‘s ROS 2 codegen and astrs-operator-macros’ derive both implement it and neither may depend upward on the node API (§4.1). This module is where the hand-written implementations live: one Rust type per entry of the §24.3 registry, each producing exactly the normative columnar layout that entry declares.

  scalar     bool · i8..i64 · u8..u64 · f32/f64 · String · Bytes · Empty · Timestamp
  geometry   Vector3 · Quaternion · Pose · Transform · Twist · Accel
  sensor     LaserScan · Imu · NavSatFix · Range · PointCloud
  vision     Detections · Keypoints · Mask
  nav        Odometry · Path · OccupancyGrid
  media      Image · AudioFrame · CompressedImage

§Two traits, on purpose

TraitDirectionWhy separate
FromPayloadpayload → valueSome types can only be read — astrs_data::tensor::ImageView is a checked view over somebody else’s columns, with no way to construct one from scratch
AstrsMessagebothEverything a node can also send

There is deliberately no blanket impl<T: AstrsMessage> FromPayload for T: the pair is written together for each type, which keeps a read-only implementation such as ImageView’s legal instead of overlapping with a blanket one. crate::Payload::view is generic over FromPayload, so the blueprint’s let img: ImageView = data.view()?; resolves.

§The layouts are normative, not incidental

Every implementation here is checked against astrs_data::TypeRegistry::std() by assert_registry_layout in its own test. Round-tripping an encoder against its own decoder proves nothing about §24.3 conformance; comparing the produced DataType against the registry’s does.

§Parameterised types

Image[pixel=…], AudioFrame[sample=…] and PointCloud[fields=…] have a layout that depends on a URN parameter, which a const URN: &'static str cannot express. Those three carry the parameter as a Rust value instead (PixelFormat, SampleFormat, PointCloud::field_names) and expose to_record_batch/from_record_batch as inherent methods with the same shape as the trait’s, plus a urn() that renders the parameterised URN a port should declare. CompressedImage’s layout does not vary with its format, so it implements the trait proper.

§Examples

use astrs_node_api::message::{AstrsMessage, Pose, Vector3};

let batch = Vector3::new(1.0, 2.0, 3.0).to_record_batch()?;
assert_eq!(batch.num_rows(), 1);
assert_eq!(Vector3::from_record_batch(&batch)?.y, 2.0);
assert_eq!(Pose::URN, "std/geometry/v1/Pose");

Re-exports§

pub use geometry::Accel;
pub use geometry::Pose;
pub use geometry::Quaternion;
pub use geometry::Transform;
pub use geometry::Twist;
pub use geometry::Vector3;
pub use media::AudioFrame;
pub use media::CompressedImage;
pub use media::Image;
pub use media::ImageSamples;
pub use media::PixelFormat;
pub use media::SampleFormat;
pub use nav::OccupancyGrid;
pub use nav::Odometry;
pub use nav::Path;
pub use nav::StampedPose;
pub use scalar::Bytes;
pub use scalar::BytesRun;
pub use scalar::Duration;
pub use scalar::Empty;
pub use scalar::Flag;
pub use scalar::FlagRun;
pub use scalar::Scalar;
pub use scalar::ScalarRun;
pub use scalar::ScalarType;
pub use scalar::Text;
pub use scalar::TextRun;
pub use scalar::Timestamp;
pub use scalar::TimestampRun;
pub use sensor::Imu;
pub use sensor::LaserScan;
pub use sensor::NavSatFix;
pub use sensor::PointCloud;
pub use sensor::Range;
pub use vision::BoundingBox;
pub use vision::Detections;
pub use vision::Keypoint;
pub use vision::Keypoints;
pub use vision::Mask;

Modules§

build
Column constructors shared by every AstrsMessage implementation.
geometry
std/geometry/v1 — rigid-body quantities (§24.3).
media
std/media/v1 — images and audio (§24.3).
nav
std/nav/v1 — navigation products built on std/geometry/v1 (§24.3).
read
Column accessors shared by every AstrsMessage implementation.
scalar
std/core/v1 and std/time/v1 — the scalar channels (§24.3).
sensor
std/sensor/v1 — raw sensor frames (§24.3).
vision
std/vision/v1 — perception outputs (§24.3).

Traits§

AstrsMessage
A Rust type that maps onto a single-column AstRS payload (blueprint §6.1, §9.2).
FromPayload
Reading a typed value out of a decoded payload.

Functions§

assert_layout_matches
Compares a layout against the registry’s entry for urn.
assert_registry_layout
Checks a type’s layout against the std registry (§24.3).
assert_registry_layout_for
assert_registry_layout for a type whose registry entry requires a parameter the const URN cannot carry.
payload_column
The single top-level payload column of batch (§6.1).
single_row_column
The single payload column of a batch that must hold exactly one row.