python/cyber_py3/cyber.py

Defined in python/cyber_py3/cyber.py

cyber_py3.cyber.init(module_name='cyber_py')

init cyber environment.

参数

module_name – Used as the log file name.

返回

Success is True, otherwise False.

init cyber environment.

cyber_py3.cyber.ok()

is cyber envi ok.

cyber_py3.cyber.shutdown()

shutdown cyber envi.

cyber_py3.cyber.is_shutdown()

is cyber shutdown.

cyber_py3.cyber.waitforshutdown()

wait until the cyber is shutdown.

cyber_py3.cyber.Node : public object

Class for cyber Node wrapper.

Public Functions

register_message(self, file_desc)

register proto message by proto descriptor file.

参数

file_desc – object about datatype.DESCRIPTOR.file .

register proto message desc file.

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

create a channel writer for send message to another channel.

参数
  • 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.

返回

return the writer object.

create a channel writer for send message to another channel.

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

create a channel reader for receive message from another channel.

参数
  • 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

返回

return the writer object.

create a channel reader for receive message from another channel.

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

Create RawData reader:listener RawMessage

create_client(self, name, request_data_type, response_data_type)

create client for the c/s.

参数
  • name – the service name.

  • request_data_type – the request message type.

  • response_data_type – the response message type.

返回

the client object.

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

create client for the c/s.

参数
  • 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.

返回

return the service object.

spin(self)

spin for every 0.002s.

cyber_py3.cyber.Writer : public object

Class for cyber writer wrapper.

Public Functions

write(self, data)

write message.

参数

data – is a message type.

返回

Success is 0, otherwise False.

writer message string

cyber_py3.cyber.Reader : public object

Class for cyber reader wrapper.

cyber_py3.cyber.Client : public object

Class for cyber service client wrapper.

Public Functions

send_request(self, data)

send request message to service.

参数

data – is a message type.

返回

None or response from service.

send request to service

cyber_py3.cyber.ChannelUtils : public object

Public Static Functions

get_debugstring_rawmsgdata(msg_type, rawmsgdata)

Parse rawmsg from rawmsg data by message type.

参数
  • msg_type – message type.

  • rawmsgdata – rawmsg data.

返回

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

get_msgtype(channel_name, sleep_s=2)

Parse rawmsg from channel name.

参数
  • channel_name – channel name.

  • sleep_s – wait time for topo discovery.

返回

return the messsage type of this channel.

get_channels(sleep_s=2)

Get all active channel names.

参数

sleep_s – wait time for topo discovery.

返回

all active channel names.

get_channels_info(sleep_s=2)

Get the active channel info.

参数

sleep_s – wait time for topo discovery.

返回

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

cyber_py3.cyber.NodeUtils : public object

Public Static Functions

get_nodes(sleep_s=2)

Get all active node names.

参数

sleep_s – wait time for topo discovery.

返回

all active node names.

get_node_attr(node_name, sleep_s=2)

Get node attribute by the node name.

参数
  • node_name – node name.

  • sleep_s – wait time for topo discovery.

返回

the node’s attribute.

get_readersofnode(node_name, sleep_s=2)

Get node’s reader channel names.

参数
  • node_name – the node name.

  • sleep_s – wait time for topo discovery.

返回

node’s reader channel names.

get_writersofnode(node_name, sleep_s=2)

Get node’s writer channel names.

参数
  • node_name – the node name.

  • sleep_s – wait time for topo discovery.

返回

node’s writer channel names.

python/cyber_py3/record.py

Defined in python/cyber_py3/record.py

cyber_py3.record.RecordReader : public object

Class for cyber RecordReader wrapper.

Public Functions

__init__(self, file_name)

the constructor function.

参数

file_name – the record file name.

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

Read message from bag file.

参数
  • start_time – the start time to read.

  • end_time – the end time to read.

返回

return (channnel, data, data_type, timestamp)

get_messagenumber(self, channel_name)

Return message count of the channel in current record file.

参数

channel_name – the channel name.

返回

return the message count.

get_messagetype(self, channel_name)

Get the corresponding message type of channel.

参数

channel_name – channel name.

返回

return the name of ther string type.

get_protodesc(self, channel_name)

Return message protodesc.

get_headerstring(self)

Return message header string.

reset(self)

Return reset.

get_channellist(self)

Return current channel names list.

cyber_py3.record.RecordWriter : public object

Class for cyber RecordWriter wrapper.

Public Functions

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

the constructor function.

参数
  • 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, path)

Open record file for write.

参数

path – the file path.

返回

Success is True, other False.

close(self)

Close record file.

Close record file.

write_channel(self, channel_name, type_name, proto_desc)

Writer channel by channelname, typename, protodesc.

参数
  • channel_name – the channel name to write

  • type_name – a string of message type name.

  • proto_desc – the message descriptor.

返回

Success is True, other False.

Writer channel by channelname,typename,protodesc

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

Writer msg: channelname, data, writer time.

参数
  • 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.

返回

Success is True, other False.

Writer msg:channelname,rawmsg,writer time

set_size_fileseg(self, size_kilobytes)

Return filesegment size.

set_intervaltime_fileseg(self, time_sec)

Return file interval time.

get_messagenumber(self, channel_name)

Return message count.

get_messagetype(self, channel_name)

Return message type.

get_protodesc(self, channel_name)

Return message protodesc.

python/cyber_py3/cyber_time.py

Defined in python/cyber_py3/cyber_time.py

cyber_py3.cyber_time.Duration : public object

Class for cyber Duration wrapper.

Public Functions

sleep(self)

sleep for the amount of time specified by the duration.

to_sec(self)

convert to second.

to_nsec(self)

convert to nanosecond.

cyber_py3.cyber_time.Time : public object

Class for cyber time wrapper.

Public Functions

__init__(self, other)

Constructor, creates a Time.

参数

other – float means seconds unit. int means nanoseconds.

to_sec(self)

convert to second.

to_nsec(self)

convert to nanosecond.

sleep_until(self, cyber_time)

sleep until time.

Public Static Functions

now()

return current time.

cyber_py3.cyber_time.Rate : public object

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

Public Functions

__init__(self, other)

Constructor, creates a Rate.

参数

other – float means frequency the desired rate to run at in Hz. int means the expected_cycle_time.

sleep(self)

Sleeps for any leftover time in a cycle.

reset(self)

Sets the start time for the rate to now.

get_cycle_time(self)

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

get_expected_cycle_time(self)

Get the expected cycle time.

python/cyber_py3/cyber_timer.py

Defined in python/cyber_py3/cyber_timer.py

cyber_py3.cyber_timer.Timer : public object

Class for cyber timer wrapper.

Public Functions

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

Used to perform oneshot or periodic timing tasks.

参数
  • 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, period, callback, oneshot=0)

set the option of timer.

参数
  • 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)

start the timer

stop(self)

stop the timer

python/cyber_py3/parameter.py

Defined in python/cyber_py3/parameter.py

cyber_py3.parameter.Parameter : public object

Class for Parameter wrapper.

Public Functions

type_name(self)

return Parameter typename

descriptor(self)

return Parameter descriptor

name(self)

return Parameter name

debug_string(self)

return Parameter debug string

as_string(self)

return native value

as_double(self)

return native value

as_int64(self)

return native value

cyber_py3.parameter.ParameterServer : public object

Class for ParameterServer wrapper.

Public Functions

__init__(self, node)

constructor the ParameterServer by the node object.

参数

node – the node to support the parameter server.

set_parameter(self, param)

set parameter, param is Parameter.

get_parameter(self, param_name)

get Parameter by param name param_name.

get_paramslist(self)

get all params of this parameterserver.

cyber_py3.parameter.ParameterClient : public object

Class for ParameterClient wrapper.

Public Functions

__init__(self, node, server_node_name)

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

参数
  • node – a node to create client.

  • server_node_name – the parameter server’s node name.

set_parameter(self, param)

set parameter, param is Parameter.

get_parameter(self, param_name)

get Parameter by param name param_name.

get_paramslist(self)

get all params of the server_node_name parameterserver.