ark::time

Enums

  • PtpMessageType (uint8_t)
    Enumerates PTP message types that we support.

  • PtpControlType (uint8_t)
    Represents control types.

  • DayOfWeek (int32_t)
    A helpful enumeration of days of the week.

Variables

Defined in “ark/time/hwclock.hh”:

  • constexpr const auto *const FAKE_HWCLOCK_DEFAULT_PATH= “/etc/fake-hwclock.data”
    Default path that the deb fake-hwclock package expects the file to be written to.

Defined in “ark/time/ntp_packet.hh”:

  • constexpr uint8_t NTP_VERSION= 3
    Version of the protocol we support.

  • constexpr uint8_t NTP_CLIENT_MODE= 3
    Defines the NTP client mode.

  • constexpr uint32_t NTP_POSIX_TIME_DELTA= 2208988800UL
    Defines the delta between NTP time and POSIX time.

  • constexpr double NTP_FRACTIONAL_MULTIPLIER= 4294967295.0
    Translation from NTP fractional to our fractional.

Defined in “ark/time/ptp_packet.hh”:

Classes

  • ark::time::GlobalTimeSubscriber
    Subscribes to global time, and then provides helper functions to handle translation of pipeline time to global time.

    Intended as a set of convenience routines to make it easier for a stage to access global time.

  • ark::time::LocalTimeClientStage
    This stage is responsible for reading the local time back from the system clock and producing a time model that can transform from pipeline time to said local time.

  • ark::time::LocalTimeZoneStage
    This stage will read the local timezone and publish it out on the robot timezone channel periodically.

  • ark::time::NtpClient
    This represents a client that can synchronize to a remote NTP source. You initialize it against the server that you wish to communicate through, and then run poll() periodically to handle results.

    The client will periodically emit time pairs, which you can then use in whatever time synchronization algorithm you like.

  • ark::time::NtpClientStage
    This stage is used to transmit current time acquired from a predefined NTP server.

  • ark::time::RolloverAwareClock
    This is a clock that consumes timestamps in a 32-bit format, processes them, and produces timestamps in a 64-bit format. Each time the 32-bit clock rolls over, the ‘high’ bits of the 64-bit clock will advance by one.

  • ark::time::TimeEstimator
    Takes in pairs of timestamps (the local time the measurement ended, the remote time measurement, and the latency between the two), and produces a time model that can be used to transform times between the two.

  • ark::time::TimeModel
    Represents a class that allows you to convert a timestamp in one frame to a timestamp in another frame.

    Normally produced from a time estimator.

  • ark::time::TimePlugin
    A simple plugin that can display time.

  • ark::time::CalendarTime
    A structure wrapping the ‘struct tm’ that is used as a calendar time.

  • ark::time::NtpTimePair
    Represents an NTP time pair (the original request time, and the receive time on the server side).

  • ark::time::NtpWirePacket
    Represents an NTP packet as we’d see it on the wire.

  • ark::time::NtpWireTimestamp
    Represents an NTP timestamp as we’d see it on the wire.

  • ark::time::PtpAnnounceBody
    Represents the body of a PTP packet for Announce messages.

  • ark::time::PtpDelayResponseBody
    Represents the body of a PTP packet for DelayResponse messages.

  • ark::time::PtpPacket
    Represents a PTP packet as it comes over the wire the PTP system uses a few non-standard-sized fields, so we don’t try to use a packed structure. This is a relatively ‘pure’ representation, however.

  • ark::time::RobotClock
    A clock (and associated durations/time_points) for the “robot synchronized” time. This is the clock that sensors and computers are synchronized too onboard, and may differ from the time on the wall or the steady clock.

  • ark::time::TimeEstimatorConfiguration
    Configuration related to the time estimator. This allows you to tune the filter a bit to your needs.

  • ark::time::TimeOfDay
    A structure containing a human-readable ‘point in time’, typically used for scheduling or alarms.

Functions

Declared in “ark/time/convert.hh”:

  • std::chrono::steady_clock::time_point system_to_steady_time(const std::chrono::system_clock::time_point & time)
    Translates a system time to a steady time, assuming that there is a linear transform between the two. This makes a best effort to ensure that there is as little error as possible, but there could be some.

    By default, this will try to minimize error in the translation to no more then 10us.

  • std::chrono::system_clock::time_point steady_to_system_time(const std::chrono::steady_clock::time_point & time)
    Translates a steady time to a system time, assuming that there is a linear transform between the two. This makes a best effort to ensure that there is as little error as possible, but there could be some.

    By default, this will try to minimize error in the translation to no more then 10us.

Declared in “ark/time/hwclock.hh”:

  • void sync_hardware_clock()
    Invoke to copy the current time from the system clock to the RTC clock. Note that the kernel automatically does this (usually every 11 minutes and on a clean shutdown). It’s generally better to allow the kernel to do this, but if you are losing power after a sync but before the 11 minutes is up, this can help ensure a sync.

  • void sync_fake_hardware_clock(const std::filesystem::path & output_path)
    Invoked to output the system time to the fake hardware clock file. This is the file used by the fake-hwclock package, and is often used on embedded devices when there is no RTC available.

    Typically, this file is written out every hour or so, but this can be useful if you are losing power before the occurs. The default output path is set to where the deb fake-hwclock package will typically read the file from.

Declared in “ark/time/ntp_client.hh”:

  • std::chrono::system_clock::time_point remote_ntp_server_time(const core::Url & ntp_server_url)
    Returns the current time of a remote NTP server. Does not run any algorithm on the returned results.

Declared in “ark/time/ntp_packet.hh”:

  • NtpWireTimestamp make_chrono_ntp_time(const std::chrono::steady_clock::time_point & input)
    Converts a chrono time point into a timestamp suitable for sending over the wire to the remote NTP server.

  • std::chrono::steady_clock::time_point make_ntp_chrono_time(const NtpWireTimestamp & incoming)
    Converts a NTP timepoint back into a chrono timepoint, suitable for being sent over the wire to the remote server.

  • NtpWirePacket construct_ntp_client_request(const std::chrono::steady_clock::time_point & originate_time)
    Constructs a client request, based on the specified originate time. Returns a wire packet suitable for sending to a remote host.

  • NtpTimePair parse_ntp_response(const NtpWirePacket & packet, const std::chrono::steady_clock::time_point & receive_time)
    Parses the given NTP wire packet into a NTP time pair. Copies the receive time into the resultant packet.

  • struct ark::time::NtpWireTimestamp __attribute__()
    The header of a Swift message.

    A system-heartbeat message, sent to indicate the overall health of the system. The offset to translate from local time to GPS time for messages tagged as such. The baseline between 2 Swift devices. This contains the relative vector distance from the base station to the rover receiver with the NED coordinate system definde by the local WGS84 tangent plane centerd at the base station. Absolute geodetic coordinates and status (best available) with covariances See fix mode for the values. The orientation of the device, in vehicle body frame. The rotations should be applied intrinsically in the order yaw, pitch, and roll in order to rotate the from a frame aligned with the local-level NED frame to the vehicle body frame. The velocity in vehicle body frame. The x-axis points at the nose of the vehicle, y-axis points to the right-hand side, and z-axis points downward. The velocity in local NED (north/east/down) coordinate. This frame is defined as the local WGS84 tangent plane, centered on the current location. The velocity in ECEF coordinate frame. A log message (ASCII text) coming from the device. Absolute geodetic coordinates and status (best available). See fix mode for the values. This structure contains configuration information about the IMU. It is necessary to fully decode SwiftMsgImuRaw packets. Raw data from the IMU, containing accelerometer and gyroscope readings. The sense of measurements are aligned with the indications on the device itself. Reports UTC time. The flags indicate the source of the offset value and fix. A decoded GPS time message, from the Swift. Represents the time since the GPS epoch began; the week begins at the Saturday/Sunday transition. Measurement units come from the MSG_IMU_AUX.

Declared in “ark/time/ptp_packet.hh”:

  • PtpPacket decode_ptp_packet(const std::string_view & data)
    Decodes the given data string, returning a PTP packet.

Declared in “ark/time/robot_clock.hh”:

  • std::ostream & operator«(std::ostream & output, const RobotClock::time_point & value)
    Stream formatting operator for time points.

  • std::ostream & operator«(std::ostream & output, const RobotClock::duration & value)
    Stream formatting operator for durations.

Declared in “ark/time/strftime.hh”:

  • CalendarTime gmtime(const std::chrono::system_clock::time_point & time)
    Takes the given system clock time point and converts it to UTC time, as if you had called gmtime_r on it (post-conversion). Throws if there is an error during conversion.

  • CalendarTime localtime(const std::chrono::system_clock::time_point & time)
    Takes the given system clock time point and converts it to local time (the default assigned time zone), as if you had called localtime_r on it (post-conversion). Throws if there is an error during conversion.

  • std::string strftime(const CalendarTime & time, std::string_view format_string)
    Converts the given calendar time (from using gmtime or localtime) into a human readable string, based on the format string given. This essentially calls strftime under the hood, so the format string is identical. Throws if there is an error.

  • std::string format_duration(const std::chrono::nanoseconds & duration)
    Formats the given duration as days/hours/minutes/seconds.

  • std::string format_duration(const Duration & duration)
    Formats the given duration as days/hours/minutes/seconds.

Declared in “ark/time/time_model.hh”:

  • TimeModel< LocalClock, RemoteClock > create_model_from_message(const TimeModelMessage & message)
    Helper to create a Time Model from a message.

Declared in “ark/time/time_of_day.hh”:

  • TimeOfDay time_of_day_from_string(const std::string_view & input)
    Converts the given input time (in the form of HH:MM or HH::MM:SS) into a structure that contains the hours/minutes/seconds in integer form. Useful for taking human-readable timestamps and making them machine-readable.

Declared in “ark/time/timezone.hh”:

  • std::string strftime_tz(const std::chrono::system_clock::time_point & time, const std::string & timezone, const std::string & format_string)
    Prints the given system time point as a string, using the given format string and timezone. You can use strftime() instead if you just want to print in UTC or local time.

  • std::chrono::system_clock::time_point apply_time_of_day(const std::chrono::system_clock::time_point & base_time, const std::string & timezone, const TimeOfDay & time_of_day)
    Takes the given input time and timezone, and applies the hours/minutes/seconds (time of day) to that timestamp, and returns the final result as a UTC timestamp.

  • DayOfWeek to_day_of_week(const std::chrono::system_clock::time_point & time, const std::string & timezone)
    Returns the day-of-week as an enumerated value, based on the given system time and in the specified timezone.

  • const char * to_string(DayOfWeek day)
    Converts the given day of the week into a string.