Class: Time

Time(secondsopt, nanosecondsopt, clockTypeopt)

- Class representing a Time in ROS

Constructor

new Time(secondsopt, nanosecondsopt, clockTypeopt)

Create a Time.
Parameters:
Name Type Attributes Default Description
seconds number | string <optional>
0 The second part of the time.
nanoseconds number | string <optional>
0 The nanosecond part of the time.
clockType ClockType <optional>
Clock.ClockType.SYSTEM_TIME The clock type.
Source:

Methods

add(other) → {Time}

Add a duration to this time object.
Parameters:
Name Type Description
other Duration The Duration object to be added.
Source:
Returns:
Return the result of a new Time object.
Type
Time

eq(other) → {boolean}

Determine whether two Time objects are equal.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if they are equal.
Type
boolean

get:clockType() → {ClockType}

Get the the clock type of the Time object.
Source:
Returns:
- The clock type.
Type
ClockType

get:nanoseconds() → {number|string}

Get the nanosecond part of the time.
Source:
Returns:
- value in nanosecond, if the value is greater than Number.MAX_SAFE_INTEGER (2^53-1), will be presented in string of decimal format.
Type
number | string

get:secondsAndNanoseconds() → {object}

Get the time as separate seconds and nanoseconds component.
Source:
Returns:
- object with properties seconds and nanoseconds.
Type
object

gt(other) → {boolean}

Determine whether the time is greater than another one.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if it's greater than other.
Type
boolean

gte(other) → {boolean}

Determine whether the time is greater than or equal with another one.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if it's greater than or equal with other.
Type
boolean

lt(other) → {boolean}

Determine whether the time is less than another one.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if it's less than other.
Type
boolean

lte(other) → {boolean}

Determine whether the time is less than or equal with another one.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if it's less than or equal with other.
Type
boolean

ne(other) → {boolean}

Determine whether two Time objects are not equal.
Parameters:
Name Type Description
other Time The time object to be compared.
Source:
Returns:
Return true if they are not equal.
Type
boolean

sub(other) → {Duration|Time}

Subtract a duration/time to this time object.
Parameters:
Name Type Description
other Duration | Time The time to be subtracted.
Source:
Returns:
Return the result.
Type
Duration | Time

toMsg() → {builtin_interfaces.msg.Time}

Create a builtin_interfaces.msg.Time message
Source:
Returns:
- The new Time message.
Type
builtin_interfaces.msg.Time

(static) fromMsg(msg, clockTypeopt) → {Time}

Create a Time object from a message of builtin_interfaces/msg/Time
Parameters:
Name Type Attributes Default Description
msg object The builtin_interfaces.msg.Time message to be created from.
clockType ClockType <optional>
Clock.ClockType.ROS_TIME The type of the time object.
Source:
Returns:
Return the created Time object.
Type
Time