python/cyber_py/cyber.py

Defined in python/cyber_py/cyber.py

cyber_py.cyber.init(module_name module_name = "cyber_py")

init cyber environment.

Return

Success is True, otherwise False.

init cyber environment.

Parameters
  • module_name: Used as the log file name.

cyber_py.cyber.ok()

is cyber envi ok.

cyber_py.cyber.shutdown()

shutdown cyber envi.

cyber_py.cyber.is_shutdown()

is cyber shutdown.

cyber_py.cyber.waitforshutdown()

wait until the cyber is shutdown.

class Node

Class for cyber Node wrapper.

Public Functions

register_message(self self, file_desc file_desc)

register proto message by proto descriptor file.

Parameters
  • file_desc: object about datatype.DESCRIPTOR.file .

    register proto message desc file.
    

create_writer(self self, name name, data_type data_type, qos_depth qos_depth = 1)

create a channel writer for send message to another channel.

Return

return the writer object.

create a channel writer for send message to another channel.

Parameters
  • name: is the channel name.

  • data_type: is message class for serialization

  • qos_depth: is a queue size, which defines the size of the cache.

create_reader(self self, name name, data_type data_type, callback callback, args args = None)

create a channel reader for receive message from another channel.

Return

return the writer object.

create a channel reader for receive message from another channel.

Parameters
  • name: the channel name to read.

  • data_type: message class for serialization

  • callback: function to call (fn(data)) when data is received. If args is set, the function must accept the args as a second argument, i.e. fn(data, args)

  • args: additional arguments to pass to the callback

create_rawdata_reader(self self, name name, callback callback, args args = None)

Create RawData reader:listener RawMessage

create_client(self self, name name, request_data_type request_data_type, response_data_type response_data_type)

create client for the c/s.

Return

the client object.

Parameters
  • name: the service name.

  • request_data_type: the request message type.

  • response_data_type: the response message type.

create_service(self self, name name, req_data_type req_data_type, res_data_type res_data_type, callback callback, args args = None)

create client for the c/s.

Return

return the service object.

Parameters
  • name: the service name.

  • req_data_type: the request message type.

  • res_data_type: the response message type.

  • callback: function to call (fn(data)) when data is received. If args is set, the function must accept the args as a second argument, i.e. fn(data, args)

  • args: additional arguments to pass to the callback.

spin(self self)

spin for every 0.002s.

class Writer

Class for cyber writer wrapper.

Public Functions

write(self self, data data)

write message.

Return

Success is 0, otherwise False.

writer message string

Parameters
  • data: is a message type.

class Reader

Class for cyber reader wrapper.

class Client

Class for cyber service client wrapper.

Public Functions

send_request(self self, data data)

send request message to service.

Return

None or response from service.

send request to service

Parameters
  • data: is a message type.

class ChannelUtils

Public Static Functions

get_debugstring_rawmsgdata(msg_type msg_type, rawmsgdata rawmsgdata)

Parse rawmsg from rawmsg data by message type.

Return

a human readable form of this message. For debugging and other purposes.

Parameters
  • msg_type: message type.

  • rawmsgdata: rawmsg data.

get_msgtype(channel_name channel_name, sleep_s sleep_s = 2)

Parse rawmsg from channel name.

Return

return the messsage type of this channel.

Parameters
  • channel_name: channel name.

  • sleep_s: wait time for topo discovery.

get_channels(sleep_s sleep_s = 2)

Get all active channel names.

Return

all active channel names.

Parameters
  • sleep_s: wait time for topo discovery.

get_channels_info(sleep_s sleep_s = 2)

Get the active channel info.

Return

all active channels info. {‘channel1’:[], ‘channel2’:[]} .

Parameters
  • sleep_s: wait time for topo discovery.

class NodeUtils

Public Static Functions

get_nodes(sleep_s sleep_s = 2)

Get all active node names.

Return

all active node names.

Parameters
  • sleep_s: wait time for topo discovery.

get_node_attr(node_name node_name, sleep_s sleep_s = 2)

Get node attribute by the node name.

Return

the node’s attribute.

Parameters
  • node_name: node name.

  • sleep_s: wait time for topo discovery.

get_readersofnode(node_name node_name, sleep_s sleep_s = 2)

Get node’s reader channel names.

Return

node’s reader channel names.

Parameters
  • node_name: the node name.

  • sleep_s: wait time for topo discovery.

get_writersofnode(node_name node_name, sleep_s sleep_s = 2)

Get node’s writer channel names.

Return

node’s writer channel names.

Parameters
  • node_name: the node name.

  • sleep_s: wait time for topo discovery.

python/cyber_py/record.py

Defined in python/cyber_py/record.py

class RecordReader

Class for cyber RecordReader wrapper.

Public Functions

__init__(self self, file_name file_name)

the constructor function.

Parameters
  • file_name: the record file name.

read_messages(self self, start_time start_time = 0, end_time end_time = 18446744073709551615)

Read message from bag file.

Return

return (channnel, data, data_type, timestamp)

Parameters
  • start_time: the start time to read.

  • end_time: the end time to read.

get_messagenumber(self self, channel_name channel_name)

Return message count of the channel in current record file.

Return

return the message count.

Parameters
  • channel_name: the channel name.

get_messagetype(self self, channel_name channel_name)

Get the corresponding message type of channel.

Return

return the name of ther string type.

Parameters
  • channel_name: channel name.

get_protodesc(self self, channel_name channel_name)

Return message protodesc.

get_headerstring(self self)

Return message header string.

reset(self self)

Return reset.

get_channellist(self self)

Return current channel names list.

class RecordWriter

Class for cyber RecordWriter wrapper.

Public Functions

__init__(self self, file_segmentation_size_kb file_segmentation_size_kb = 0, file_segmentation_interval_sec file_segmentation_interval_sec = 0)

the constructor function.

Parameters
  • file_segmentation_size_kb: size to segment the file, 0 is no segmentation.

  • file_segmentation_interval_sec: size to segment the file, 0 is no segmentation.

open(self self, path path)

Open record file for write.

Return

Success is Ture, other False.

Parameters
  • path: the file path.

close(self self)

Close record file.

Close record file.

write_channel(self self, channel_name channel_name, type_name type_name, proto_desc proto_desc)

Writer channel by channelname, typename, protodesc.

Return

Success is Ture, other False.

Writer channel by channelname,typename,protodesc

Parameters
  • channel_name: the channel name to write

  • type_name: a string of message type name.

  • proto_desc: the message descriptor.

write_message(self self, channel_name channel_name, data data, time time, raw raw = True)

Writer msg: channelname, data, writer time.

Return

Success is Ture, other False.

Writer msg:channelname,rawmsg,writer time

Parameters
  • channel_name: channel name to write.

  • data: when raw is True, data processed as a rawdata, other it needs to SerializeToString

  • time: message time.

  • raw: the flag implies data whether or not a rawdata.

set_size_fileseg(self self, size_kilobytes size_kilobytes)

Return filesegment size.

set_intervaltime_fileseg(self self, time_sec time_sec)

Return file interval time.

get_messagenumber(self self, channel_name channel_name)

Return message count.

get_messagetype(self self, channel_name channel_name)

Return message type.

get_protodesc(self self, channel_name channel_name)

Return message protodesc.

python/cyber_py/cyber_time.py

Defined in python/cyber_py/cyber_time.py

class Duration

Class for cyber Duration wrapper.

Public Functions

sleep(self self)

sleep for the amount of time specified by the duration.

to_sec(self self)

convert to second.

to_nsec(self self)

convert to nanosecond.

class Time

Class for cyber time wrapper.

Public Functions

__init__(self self, other other)

Constructor, creates a Time.

Parameters
  • other: float means seconds unit. int or long means nanoseconds.

to_sec(self self)

convert to second.

to_nsec(self self)

convert to nanosecond.

sleep_until(self self, time time)

sleep until time.

Public Static Functions

now()

return current time.

class Rate

Class for cyber Rate wrapper. Help run loops at a desired frequency.

Public Functions

__init__(self self, other other)

Constructor, creates a Rate.

Parameters
  • other: float means frequency the desired rate to run at in Hz. int or long means the expected_cycle_time.

sleep(self self)

Sleeps for any leftover time in a cycle.

reset(self self)

Sets the start time for the rate to now.

get_cycle_time(self self)

Get the actual run time of a cycle from start to sleep.

get_expected_cycle_time(self self)

Get the expected cycle time.

python/cyber_py/cyber_timer.py

Defined in python/cyber_py/cyber_timer.py

class Timer

Class for cyber timer wrapper.

Public Functions

__init__(self self, period period = None, callback callback = None, oneshot oneshot = None)

Used to perform oneshot or periodic timing tasks.

Parameters
  • period: The period of the timer, unit is ms.

  • callback: The tasks that the timer needs to perform.

  • oneshot: 1:perform the callback only after the first timing cycle 0:perform the callback every timed period

set_option(self self, period period, callback callback, oneshot oneshot = 0)

set the option of timer.

Parameters
  • period: The period of the timer, unit is ms.

  • callback: The tasks that the timer needs to perform.

  • oneshot: 1:perform the callback only after the first timing cycle 0:perform the callback every timed period

start(self self)

start the timer

stop(self self)

stop the timer

python/cyber_py/parameter.py

Defined in python/cyber_py/parameter.py

class Parameter

Class for Parameter wrapper.

Public Functions

type_name(self self)

return Parameter typename

descriptor(self self)

return Parameter descriptor

name(self self)

return Parameter name

debug_string(self self)

return Parameter debug string

as_string(self self)

return native value

as_double(self self)

return native value

as_int64(self self)

return native value

class ParameterServer

Class for ParameterServer wrapper.

Public Functions

__init__(self self, node node)

constructor the ParameterServer by the node object.

Parameters
  • node: the node to support the parameter server.

set_parameter(self self, param param)

set parameter, param is Parameter.

get_parameter(self self, param_name param_name)

get Parameter by param name param_name.

get_paramslist(self self)

get all params of this parameterserver.

class ParameterClient

Class for ParameterClient wrapper.

Public Functions

__init__(self self, node node, server_node_name server_node_name)

constructor the ParameterClient by a node and the parameter server node name.

Parameters
  • node: a node to create client.

  • server_node_name: the parameter server’s node name.

set_parameter(self self, param param)

set parameter, param is Parameter.

get_parameter(self self, param_name param_name)

get Parameter by param name param_name.

get_paramslist(self self)

get all params of the server_node_name parameterserver.