Welcome to genpy’s documentation!

Python ROS message and service generators.

Indices and tables

class genpy.Time(secs=0, nsecs=0)[source]

Time contains the ROS-wide ‘time’ primitive representation.

It consists of two integers: seconds since epoch and nanoseconds since seconds. Time instances are mutable.

nsecs
secs
to_time()[source]

Get Time in time.time() format. alias of L{to_sec()}.

Returns:time in floating point secs (time.time() format), float
class genpy.Duration(secs=0, nsecs=0)[source]

Duration represents the ROS ‘duration’ primitive.

It consists of two integers: seconds and nanoseconds. The Duration class allows you to add and subtract Duration instances, including adding and subtracting from Time instances.

nsecs
secs
class genpy.TVal(secs=0, nsecs=0)[source]

Base class of Time and Duration representations.

Representation is secs+nanoseconds since epoch.

canon()[source]

Canonicalize the field representation in this instance.

Should only be used when manually setting secs/nsecs slot values, as in deserialization.

classmethod from_sec(float_secs)[source]

Create new TVal instance using time.time() value (float seconds).

Parameters:float_secs – time value in time.time() format, float
Returns:TVal instance for specified time
is_zero()[source]
Returns:True if time is zero (secs and nsecs are zero), bool
nsecs
secs
set(secs, nsecs)[source]

Set time using separate secs and nsecs values.

Parameters:
  • secs – seconds since epoch, int
  • nsecs – nanoseconds since seconds, int
to_nsec()[source]
Returns:time as nanoseconds, long
to_sec()[source]
Returns:time as float seconds (same as time.time() representation), float
class genpy.Message(*args, **kwds)[source]

Base class of Message data classes auto-generated from msg files.

deserialize(str_)[source]

Deserialize data in str into this instance.

Parameters:str – serialized data, str
serialize(buff)[source]

Serialize data into buffer.

Parameters:buff – buffer, StringIO
exception genpy.SerializationError[source]

Message serialization error.

exception genpy.DeserializationError[source]

Message deserialization error.

exception genpy.MessageException[source]

Base exception type for errors in genmsg routines.