Class Ros2
The ROS 2 naming and encoding rules, none of which need a ROS installation.
public static class Ros2
- Inheritance
-
Ros2
- Inherited Members
Remarks
A gateway written in C# can validate a name, derive the DDS topic and the
Zenoh key an rmw_zenoh peer subscribes on, and encode a
geometry_msgs/msg/Twist with no ROS distribution anywhere near it.
Driving a live graph does need one, so that stays in the Rust crate.
Methods
DdsTopic(string, EntityKind)
Returns the DDS topic a fully qualified name maps onto.
public static string? DdsTopic(string fqn, EntityKind kind)
Parameters
fqnstringThe fully qualified name.
kindEntityKindWhich subsystem the name belongs to.
Returns
- string
The DDS topic, or
nullif the name is not fully qualified.
Exceptions
- ArgumentOutOfRangeException
kindis not one of the EntityKind values.
DdsTypeName(string)
Returns the DDS type name an interface type maps onto.
public static string? DdsTypeName(string rosType)
Parameters
rosTypestringThe interface type as
package/namespace/Type.
Returns
- string
The DDS type name, or
nullif the type is not valid.
EntityKey(uint, string, string, string)
Builds the Zenoh key an rmw_zenoh peer publishes an entity on.
public static string? EntityKey(uint domainId, string fqn, string rosType, string typeHash)
Parameters
domainIduintThe ROS 2 domain.
fqnstringThe fully qualified entity name.
rosTypestringThe interface type as
package/namespace/Type.typeHashstringThe message type hash as its
RIHS01_string.
Returns
- string
The key, or
nullif the name, type, or hash is not usable.
IsFullyQualified(string)
Reports whether a name resolves with no namespace applied.
public static bool IsFullyQualified(string name)
Parameters
namestringThe candidate name.
Returns
- bool
truewhen the name is fully qualified.
IsValidName(string)
Reports whether a string is a valid ROS 2 topic or service name.
public static bool IsValidName(string name)
Parameters
namestringThe candidate name.
Returns
- bool
truewhen the name obeys the ROS 2 rules.
PercentMangle(string)
Percent-mangles a name as rmw_zenoh writes it in a liveliness token, each / as %.
public static string PercentMangle(string name)
Parameters
namestringThe name to mangle.
Returns
- string
The mangled name.
PrefixFor(EntityKind)
Returns the DDS topic prefix a subsystem uses.
public static string PrefixFor(EntityKind kind)
Parameters
kindEntityKindThe subsystem.
Returns
- string
rt,rq, orrr.
Exceptions
- ArgumentOutOfRangeException
kindis not one of the EntityKind values.
SuffixFor(EntityKind)
Returns what the middleware appends to a name for a subsystem.
public static string SuffixFor(EntityKind kind)
Parameters
kindEntityKindThe subsystem.
Returns
- string
Nothing for a topic,
Requestfor a service request, orReplyfor a service response.
Exceptions
- ArgumentOutOfRangeException
kindis not one of the EntityKind values.
TwistFromCdr(ReadOnlySpan<byte>)
Decodes a twist from its CDR representation.
public static Ros2Twist? TwistFromCdr(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>The encoded bytes.
Returns
- Ros2Twist?
The command, or
nullif the bytes are not a well-formed twist.
TwistToCdr(Ros2Twist)
Encodes a twist into its CDR representation.
public static byte[] TwistToCdr(Ros2Twist twist)
Parameters
twistRos2TwistThe command to encode.
Returns
- byte[]
The encoded bytes.
TypeHashDigest(string)
Returns the 32-byte digest a RIHS01 hash string carries.
public static byte[]? TypeHashDigest(string text)
Parameters
textstringThe hash as its
RIHS01_string.
Returns
- byte[]
The digest, or
nullif the string is malformed.