├── .gitignore
├── cyber
├── conf
│ ├── compute_sched.conf
│ ├── control_sched.conf
│ ├── dreamview_sched.conf
│ ├── control_sched_choreography.conf
│ ├── control_sched_classic.conf
│ ├── cyber.pb.conf
│ ├── example_sched_choreography.conf
│ └── example_sched_classic.conf
├── doxy-docs
│ ├── source
│ │ ├── images
│ │ │ ├── cyber_monitor.png
│ │ │ ├── cyber_visualizer1.png
│ │ │ ├── cyber_visualizer2.png
│ │ │ ├── cyber_visualizer3.png
│ │ │ └── cyber_visualizer4.png
│ │ ├── api
│ │ │ ├── pythonapi_index.rst
│ │ │ └── cppapi_index.rst
│ │ └── conf.py
│ ├── environment.yml
│ ├── build_doxy_sphinx.sh
│ ├── Doxyfile
│ └── make.bat
├── class_loader
│ ├── ClassLoaderConfig.cmake.in
│ ├── test
│ │ ├── BUILD
│ │ ├── base.h
│ │ ├── plugin2.cc
│ │ └── plugin1.cc
│ └── BUILD
├── proto
│ ├── proto_desc.proto
│ ├── run_mode_conf.proto
│ ├── perception.proto
│ ├── perf_conf.proto
│ ├── cyber_conf.proto
│ ├── unit_test.proto
│ ├── dag_conf.proto
│ ├── classic_conf.proto
│ ├── scheduler_conf.proto
│ ├── topology_change.proto
│ ├── choreography_conf.proto
│ ├── parameter.proto
│ ├── component_conf.proto
│ ├── qos_profile.proto
│ ├── role_attributes.proto
│ └── transport_conf.proto
├── examples
│ ├── timer_component_example
│ │ ├── timer.launch
│ │ ├── timer.dag
│ │ ├── BUILD
│ │ ├── CMakeLists.txt
│ │ ├── timer_component_example.cc
│ │ └── timer_component_example.h
│ ├── common_component_example
│ │ ├── common.launch
│ │ ├── CMakeLists.txt
│ │ ├── common.dag
│ │ ├── BUILD
│ │ ├── common_component_example.cc
│ │ └── common_component_example.h
│ ├── proto
│ │ ├── BUILD
│ │ └── examples.proto
│ ├── BUILD
│ ├── listener.cc
│ ├── talker.cc
│ └── paramserver.cc
├── tools
│ ├── cyber_channel
│ │ └── CMakeLists.txt
│ ├── cyber_monitor
│ │ ├── CMakeLists.txt
│ │ ├── renderable_message.cc
│ │ └── BUILD
│ └── cyber_recorder
│ │ ├── CMakeLists.txt
│ │ ├── info.h
│ │ └── player
│ │ ├── play_param.h
│ │ └── play_task_buffer.h
├── sysmo
│ ├── CMakeLists.txt
│ ├── BUILD
│ ├── sysmo_test.cc
│ ├── sysmo.h
│ └── sysmo.cc
├── event
│ ├── CMakeLists.txt
│ └── BUILD
├── task
│ ├── CMakeLists.txt
│ └── BUILD
├── service
│ ├── CMakeLists.txt
│ ├── BUILD
│ └── service_base.h
├── blocker
│ ├── CMakeLists.txt
│ ├── BUILD
│ └── blocker_manager.cc
├── io
│ ├── CMakeLists.txt
│ ├── poll_data.h
│ └── poll_handler.h
├── time
│ ├── CMakeLists.txt
│ ├── BUILD
│ └── rate.h
├── timer
│ ├── CMakeLists.txt
│ ├── BUILD
│ ├── timer_task.h
│ └── timer_bucket.h
├── node
│ ├── CMakeLists.txt
│ └── node.cc
├── croutine
│ ├── CMakeLists.txt
│ └── detail
│ │ ├── swap_aarch64.S
│ │ └── swap_x86_64.S
├── common
│ ├── CMakeLists.txt
│ ├── log_test.cc
│ ├── util.h
│ ├── types.h
│ ├── environment.h
│ └── environment_test.cc
├── message
│ ├── CMakeLists.txt
│ ├── raw_message_traits.h
│ └── py_message_traits.h
├── parameter
│ ├── CMakeLists.txt
│ ├── parameter_service_names.h
│ └── BUILD
├── component
│ ├── CMakeLists.txt
│ └── BUILD
├── python
│ ├── cyber_py
│ │ ├── examples
│ │ │ ├── BUILD
│ │ │ ├── py_listener.cc
│ │ │ ├── timer.py
│ │ │ ├── service.py
│ │ │ ├── listener.py
│ │ │ ├── client.py
│ │ │ └── talker.py
│ │ ├── __init__.py
│ │ └── test
│ │ │ └── test_init.py
│ ├── cyber_py3
│ │ ├── __init__.py
│ │ ├── test
│ │ │ └── test_init.py
│ │ └── examples
│ │ │ ├── timer.py
│ │ │ ├── service.py
│ │ │ ├── listener.py
│ │ │ ├── client.py
│ │ │ └── talker.py
│ └── README.md
├── mainboard
│ ├── CMakeLists.txt
│ └── mainboard.cc
├── logger
│ ├── CMakeLists.txt
│ ├── logger.h
│ ├── logger_util.cc
│ ├── log_file_object_test.cc
│ └── BUILD
├── setup.bash
├── CMakeLists.txt
├── scheduler
│ ├── processor_context.cc
│ ├── common
│ │ ├── mutex_wrapper.h
│ │ ├── cv_wrapper.h
│ │ └── pin_thread.h
│ ├── scheduler_factory.h
│ └── processor_context.h
├── init.h
├── transport
│ ├── shm
│ │ ├── state.cc
│ │ ├── segment_factory.h
│ │ ├── notifier_factory.h
│ │ ├── notifier_base.h
│ │ ├── xsi_segment.h
│ │ ├── posix_segment.h
│ │ └── multicast_notifier.h
│ ├── dispatcher
│ │ ├── intra_dispatcher.cc
│ │ └── dispatcher.cc
│ ├── common
│ │ ├── endpoint.cc
│ │ ├── endpoint.h
│ │ └── endpoint_test.cc
│ └── message
│ │ └── history_attributes.h
├── state.cc
├── record
│ ├── file
│ │ ├── section.h
│ │ ├── record_file_base.cc
│ │ └── record_file_base.h
│ └── CMakeLists.txt
├── binary.h
├── base
│ ├── for_each_test.cc
│ ├── CMakeLists.txt
│ └── for_each.h
├── cyber.h
├── cyber.cc
├── service_discovery
│ └── communication
│ │ └── participant_listener.cc
├── data
│ └── data_visitor_base.h
└── state.h
├── VERSION
├── CyberConfig.cmake.in
├── cmake
├── FindGlog.cmake
├── FindGflags.cmake
├── FindFastRTPS.cmake
├── FindProtobuf.cmake
└── external
│ ├── glog-0.3.5.cmake
│ └── gflags-2.2.0.cmake
├── README.md
└── scripts
└── genprotosrc.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.swp
3 | build/
4 | tmp/
5 |
--------------------------------------------------------------------------------
/cyber/conf/compute_sched.conf:
--------------------------------------------------------------------------------
1 | compute_sched_classic.conf
--------------------------------------------------------------------------------
/cyber/conf/control_sched.conf:
--------------------------------------------------------------------------------
1 | control_sched_classic.conf
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | cyber is imported from c5996ef638f21aced4f9b5e100cd2df3738b843c
2 | @https://github.com/ApolloAuto/apollo.git
3 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/images/cyber_monitor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhxt/cyber-rt/HEAD/cyber/doxy-docs/source/images/cyber_monitor.png
--------------------------------------------------------------------------------
/cyber/doxy-docs/environment.yml:
--------------------------------------------------------------------------------
1 | name: CyberRT
2 |
3 | channels:
4 | - conda-forge
5 |
6 | dependencies:
7 | - breathe
8 | - recommonmark
9 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/images/cyber_visualizer1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhxt/cyber-rt/HEAD/cyber/doxy-docs/source/images/cyber_visualizer1.png
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/images/cyber_visualizer2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhxt/cyber-rt/HEAD/cyber/doxy-docs/source/images/cyber_visualizer2.png
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/images/cyber_visualizer3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhxt/cyber-rt/HEAD/cyber/doxy-docs/source/images/cyber_visualizer3.png
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/images/cyber_visualizer4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhxt/cyber-rt/HEAD/cyber/doxy-docs/source/images/cyber_visualizer4.png
--------------------------------------------------------------------------------
/cyber/doxy-docs/build_doxy_sphinx.sh:
--------------------------------------------------------------------------------
1 | rm -rf xml/*
2 | doxygen Doxyfile
3 | rm -rf build/*
4 | sphinx-build -b html -d build/doctrees source build/html
5 |
--------------------------------------------------------------------------------
/cyber/class_loader/ClassLoaderConfig.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
4 |
5 | check_required_components(@PROJECT_NAME@)
6 |
--------------------------------------------------------------------------------
/cyber/proto/proto_desc.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | message ProtoDesc {
6 | optional bytes desc = 1;
7 | repeated ProtoDesc dependencies = 2;
8 | }
9 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/api/pythonapi_index.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | Python API
4 | ====================
5 |
6 | Cyber RT provides the python interfaces for developers.
7 |
8 | .. toctree::
9 |
10 | pythonapi
11 |
12 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/api/cppapi_index.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | C++ API
4 | ====================
5 |
6 | Topological communication APIs is actually implemented in ``node`` and ``reader/writer`` and ``client/service``.
7 |
8 | .. toctree::
9 |
10 | cppapi
11 |
12 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/timer.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 | timer
4 | /apollo/cyber/examples/timer_component_example/timer.dag
5 | timer
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_channel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberChannel)
3 |
4 | install(FILES cyber_channel
5 | DESTINATION ${CYBER_INSTALL_DIR}/bin
6 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
7 | )
8 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/common.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 | common
4 | /apollo/cyber/examples/common_component_example/common.dag
5 | common
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cyber/proto/run_mode_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | enum RunMode {
6 | MODE_REALITY = 0;
7 | MODE_SIMULATION = 1;
8 | }
9 |
10 | message RunModeConf {
11 | optional RunMode run_mode = 1 [default = MODE_REALITY];
12 | }
13 |
--------------------------------------------------------------------------------
/cyber/conf/dreamview_sched.conf:
--------------------------------------------------------------------------------
1 |
2 | scheduler_conf {
3 | policy: "classic"
4 | classic_conf {
5 | groups: [
6 | {
7 | name: "dv"
8 | processor_num: 4
9 | affinity: "range"
10 | cpuset: "28-31"
11 | }
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/cyber/proto/perception.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | message Perception {
6 | message Header {
7 | optional uint64 timestamp = 1;
8 | }
9 | optional Header header = 1;
10 | optional uint64 msg_id = 2;
11 | optional double result = 3;
12 | };
13 |
--------------------------------------------------------------------------------
/cyber/examples/proto/BUILD:
--------------------------------------------------------------------------------
1 | package(default_visibility = ["//visibility:public"])
2 |
3 | cc_proto_library(
4 | name = "examples_cc_proto",
5 | deps = [
6 | ":examples_proto",
7 | ],
8 | )
9 |
10 | proto_library(
11 | name = "examples_proto",
12 | srcs = ["examples.proto"],
13 | )
14 |
--------------------------------------------------------------------------------
/cyber/proto/perf_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | enum PerfType {
6 | SCHED = 1;
7 | TRANSPORT = 2;
8 | DATA_CACHE = 3;
9 | ALL = 4;
10 | }
11 |
12 | message PerfConf {
13 | optional bool enable = 1 [default = false];
14 | optional PerfType type = 2 [default = ALL];
15 | }
16 |
--------------------------------------------------------------------------------
/CyberConfig.cmake.in:
--------------------------------------------------------------------------------
1 | # prevent multiple inclusion
2 | if(_@PROJECT_NAME@_CONFIG_INCLUDED)
3 | return()
4 | endif()
5 | set(_@PROJECT_NAME@_CONFIG_INCLUDED TRUE)
6 |
7 | # output package information
8 | if(NOT @PROJECT_NAME@_FIND_QUIETLY)
9 | message(STATUS "Found @PROJECT_NAME@: @PACKAGE_VERSION@ (${@PROJECT_NAME@_DIR})")
10 | endif()
11 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/timer.dag:
--------------------------------------------------------------------------------
1 | module_config {
2 | module_library : "/apollo/bazel-bin/cyber/examples/timer_component_example/libtimer_component_example.so"
3 | timer_components {
4 | class_name : "TimerComponentSample"
5 | config {
6 | name : "timer"
7 | interval : 10
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/cyber/sysmo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberSysmo)
3 |
4 | add_library(cyber_sysmo sysmo.cc)
5 |
6 | add_library(Cyber::sysmo ALIAS cyber_sysmo)
7 |
8 | file(GLOB HEADERS *.h)
9 |
10 | install(FILES ${HEADERS}
11 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/sysmo/
12 | )
13 |
14 | install(TARGETS cyber_sysmo
15 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
16 | )
17 |
--------------------------------------------------------------------------------
/cyber/event/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberEvent)
4 |
5 | add_library(cyber_event perf_event_cache.cc)
6 |
7 | add_library(Cyber::event ALIAS cyber_event)
8 |
9 | file(GLOB HEADERS *.h)
10 |
11 | install(FILES ${HEADERS}
12 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/event/
13 | )
14 |
15 | install(TARGETS cyber_event
16 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
17 | )
18 |
--------------------------------------------------------------------------------
/cyber/proto/cyber_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/scheduler_conf.proto";
6 | import "cyber/proto/transport_conf.proto";
7 | import "cyber/proto/run_mode_conf.proto";
8 | import "cyber/proto/perf_conf.proto";
9 |
10 | message CyberConfig {
11 | optional SchedulerConf scheduler_conf = 1;
12 | optional TransportConf transport_conf = 2;
13 | optional RunModeConf run_mode_conf = 3;
14 | optional PerfConf perf_conf = 4;
15 | }
16 |
--------------------------------------------------------------------------------
/cyber/conf/control_sched_choreography.conf:
--------------------------------------------------------------------------------
1 | scheduler_conf {
2 | policy: "choreography"
3 |
4 | choreography_conf {
5 | processor_num: 2
6 |
7 | pool_processor_num: 2
8 | pool_affinity: "range"
9 | pool_cpuset: "12-15"
10 |
11 | tasks: [
12 | {
13 | name: "control_/apollo/planning"
14 | processor: 0
15 | },
16 | {
17 | name: "canbus_/apollo/control"
18 | processor: 0
19 | prio: 2
20 | }
21 | ]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(common_component_example VERSION 1.0.0)
4 |
5 | set(proto_src ../proto/examples.pb.cc)
6 | add_library(common_component_example SHARED common_component_example.cc
7 | ${proto_src})
8 |
9 | target_link_libraries(common_component_example
10 | Cyber::init
11 | Cyber::transmitter
12 | )
13 | install(TARGETS
14 | common_component_example
15 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
16 | )
17 |
--------------------------------------------------------------------------------
/cyber/proto/unit_test.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | message UnitTest {
6 | optional string class_name = 1;
7 | optional string case_name = 2;
8 | };
9 |
10 | message Chatter {
11 | optional uint64 timestamp = 1;
12 | optional uint64 lidar_timestamp = 2;
13 | optional uint64 seq = 3;
14 | optional bytes content = 4;
15 | };
16 |
17 | message ChatterBenchmark {
18 | optional uint64 stamp = 1;
19 | optional uint64 seq = 2;
20 | optional string content = 3;
21 | }
22 |
--------------------------------------------------------------------------------
/cyber/examples/proto/examples.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.examples.proto;
4 |
5 | message SamplesTest1 {
6 | optional string class_name = 1;
7 | optional string case_name = 2;
8 | };
9 |
10 | message Chatter {
11 | optional uint64 timestamp = 1;
12 | optional uint64 lidar_timestamp = 2;
13 | optional uint64 seq = 3;
14 | optional bytes content = 4;
15 | };
16 |
17 | message Driver {
18 | optional string content = 1;
19 | optional uint64 msg_id = 2;
20 | optional uint64 timestamp = 3;
21 | };
22 |
--------------------------------------------------------------------------------
/cyber/task/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberTask)
4 |
5 | add_library(cyber_task_manager task_manager.cc)
6 | target_link_libraries(cyber_task_manager
7 | Cyber::croutine
8 | Cyber::scheduler)
9 |
10 | add_library(Cyber::task_manager ALIAS cyber_task_manager)
11 |
12 | file(GLOB HEADERS *.h)
13 |
14 | install(FILES ${HEADERS}
15 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/task
16 | )
17 |
18 | install(TARGETS cyber_task_manager
19 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
20 | )
21 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/common.dag:
--------------------------------------------------------------------------------
1 | # Define all coms in DAG streaming.
2 | module_config {
3 | module_library : "/apollo/bazel-bin/cyber/examples/common_component_example/libcommon_component_example.so"
4 | components {
5 | class_name : "CommonComponentSample"
6 | config {
7 | name : "common"
8 | readers {
9 | channel: "/apollo/prediction"
10 | }
11 | readers {
12 | channel: "/apollo/test"
13 | }
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/cyber/sysmo/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_test(
6 | name = "sysmo_test",
7 | size = "small",
8 | srcs = ["sysmo_test.cc"],
9 | deps = [
10 | "//cyber:cyber_core",
11 | "//cyber/scheduler:scheduler_factory",
12 | "@gtest//:main",
13 | ],
14 | )
15 |
16 | cc_library(
17 | name = "sysmo",
18 | srcs = ["sysmo.cc"],
19 | hdrs = ["sysmo.h"],
20 | deps = [
21 | "//cyber/scheduler:scheduler_factory",
22 | ],
23 | )
24 |
25 | cpplint()
26 |
--------------------------------------------------------------------------------
/cyber/conf/control_sched_classic.conf:
--------------------------------------------------------------------------------
1 | scheduler_conf {
2 | policy: "classic"
3 | classic_conf {
4 | groups: [
5 | {
6 | name: "control"
7 | processor_num: 8
8 | affinity: "range"
9 | cpuset: "8-15"
10 | processor_policy: "SCHED_OTHER"
11 | processor_prio: 0
12 | tasks: [
13 | {
14 | name: "control_/apollo/planning"
15 | prio: 10
16 | },
17 | {
18 | name: "canbus_/apollo/control"
19 | prio: 11
20 | }
21 | ]
22 | }
23 | ]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/cyber/service/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberService)
3 |
4 | add_library(cyber_client INTERFACE)
5 | target_sources(cyber_client INTERFACE
6 | client_base.h
7 | client.h
8 | )
9 | add_library(cyber_server INTERFACE)
10 | target_sources(cyber_server INTERFACE
11 | service_base.h
12 | service.h
13 | )
14 |
15 | add_library(Cyber::client ALIAS cyber_client)
16 | add_library(Cyber::server ALIAS cyber_server)
17 |
18 | file(GLOB HEADERS *.h)
19 |
20 | install(FILES ${HEADERS}
21 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/service/
22 | )
23 |
--------------------------------------------------------------------------------
/cyber/blocker/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberBlocker)
4 |
5 | add_library(cyber_blocker_manager blocker_manager.cc)
6 | add_library(cyber_intra_reader INTERFACE)
7 | add_library(cyber_intra_writer INTERFACE)
8 | add_library(cyber_intra_blocker INTERFACE)
9 |
10 | add_library(Cyber::blocker_manager ALIAS cyber_blocker_manager)
11 |
12 | file(GLOB HEADERS *.h)
13 |
14 | install(FILES ${HEADERS}
15 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/blocker/
16 | )
17 |
18 | install(TARGETS cyber_blocker_manager
19 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
20 | )
21 |
--------------------------------------------------------------------------------
/cyber/class_loader/test/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "base",
7 | hdrs = ["base.h"],
8 | )
9 |
10 | cc_library(
11 | name = "plugin1",
12 | srcs = ["plugin1.cc"],
13 | deps = [
14 | ":base",
15 | "//cyber/class_loader:class_loader_manager",
16 | ],
17 | )
18 |
19 | cc_library(
20 | name = "plugin2",
21 | srcs = ["plugin2.cc"],
22 | deps = [
23 | ":base",
24 | "//cyber/class_loader:class_loader_manager",
25 | ],
26 | )
27 |
28 | cpplint()
29 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_binary(
6 | name = "libtimer_component_example.so",
7 | linkopts = ["-shared"],
8 | linkstatic = False,
9 | deps = [":timer_component_example_lib"],
10 | )
11 |
12 | cc_library(
13 | name = "timer_component_example_lib",
14 | srcs = ["timer_component_example.cc"],
15 | hdrs = ["timer_component_example.h"],
16 | deps = [
17 | "//cyber",
18 | "//cyber/examples/proto:examples_cc_proto",
19 | ],
20 | )
21 |
22 | cpplint()
23 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_binary(
6 | name = "libcommon_component_example.so",
7 | linkopts = ["-shared"],
8 | linkstatic = False,
9 | deps = [":common_component_example_lib"],
10 | )
11 |
12 | cc_library(
13 | name = "common_component_example_lib",
14 | srcs = ["common_component_example.cc"],
15 | hdrs = ["common_component_example.h"],
16 | deps = [
17 | "//cyber",
18 | "//cyber/examples/proto:examples_cc_proto",
19 | ],
20 | )
21 |
22 | cpplint()
23 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/Doxyfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = "Cyber RT Documents"
2 | XML_OUTPUT = xml
3 | INPUT = ../cyber.h ../init.h ../node ../record ../time ../timer ../component ../logger ../parameter ../service ../service_discovery ../python
4 | FILE_PATTERNS = *.h *.py
5 | RECURSIVE = YES
6 | GENERATE_LATEX = NO
7 | GENERATE_MAN = NO
8 | GENERATE_RTF = NO
9 | CASE_SENSE_NAMES = NO
10 | GENERATE_HTML = NO
11 | GENERATE_XML = YES
12 | RECURSIVE = YES
13 | QUIET = YES
14 | JAVADOC_AUTOBRIEF = YES
15 | WARN_IF_UNDOCUMENTED = NO
16 | MACRO_EXPANSION = YES
17 | PREDEFINED = IN_DOXYGEN
18 |
--------------------------------------------------------------------------------
/cyber/service/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "client",
7 | hdrs = ["client.h"],
8 | deps = [
9 | ":client_base",
10 | ],
11 | )
12 |
13 | cc_library(
14 | name = "client_base",
15 | hdrs = ["client_base.h"],
16 | )
17 |
18 | cc_library(
19 | name = "service",
20 | hdrs = ["service.h"],
21 | deps = [
22 | ":service_base",
23 | "//cyber/scheduler",
24 | ],
25 | )
26 |
27 | cc_library(
28 | name = "service_base",
29 | hdrs = ["service_base.h"],
30 | )
31 |
32 | cpplint()
33 |
--------------------------------------------------------------------------------
/cyber/io/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberIo)
3 |
4 | add_library(cyber_poller poller.cc)
5 | add_library(cyber_poll_handler poll_handler.cc)
6 | add_library(cyber_session session.cc)
7 |
8 | add_library(Cyber::poller ALIAS cyber_poller)
9 | add_library(Cyber::poll_handler ALIAS cyber_poll_handler)
10 | add_library(Cyber::session ALIAS cyber_session)
11 |
12 | file(GLOB HEADERS *.h)
13 |
14 | install(FILES ${HEADERS}
15 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/io/
16 | )
17 |
18 | install(TARGETS cyber_poller cyber_poll_handler cyber_session
19 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
20 | )
21 |
--------------------------------------------------------------------------------
/cyber/proto/dag_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/component_conf.proto";
6 |
7 | message ComponentInfo {
8 | optional string class_name = 1;
9 | optional ComponentConfig config = 2;
10 | }
11 |
12 | message TimerComponentInfo {
13 | optional string class_name = 1;
14 | optional TimerComponentConfig config = 2;
15 | }
16 |
17 | message ModuleConfig {
18 | optional string module_library = 1;
19 | repeated ComponentInfo components = 2;
20 | repeated TimerComponentInfo timer_components = 3;
21 | }
22 |
23 | message DagConfig {
24 | repeated ModuleConfig module_config = 1;
25 | }
26 |
--------------------------------------------------------------------------------
/cyber/proto/classic_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | message ClassicTask {
6 | optional string name = 1;
7 | optional uint32 prio = 2 [default = 1];
8 | optional string group_name = 3;
9 | }
10 |
11 | message SchedGroup {
12 | required string name = 1 [default = "default_grp"];
13 | optional uint32 processor_num = 2;
14 | optional string affinity = 3;
15 | optional string cpuset = 4;
16 | optional string processor_policy = 5;
17 | optional int32 processor_prio = 6 [default = 0];
18 | repeated ClassicTask tasks = 7;
19 | }
20 |
21 | message ClassicConf {
22 | repeated SchedGroup groups = 1;
23 | }
24 |
--------------------------------------------------------------------------------
/cyber/time/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberTime)
4 |
5 | add_library(cyber_duration duration.cc)
6 | add_library(cyber_rate rate.cc)
7 |
8 | add_library(cyber_time time.cc)
9 | target_link_libraries(cyber_time cyber_duration)
10 |
11 | add_library(Cyber::duration ALIAS cyber_duration)
12 | add_library(Cyber::rate ALIAS cyber_rate)
13 | add_library(Cyber::time ALIAS cyber_time)
14 |
15 | file(GLOB HEADERS *.h)
16 |
17 | install(FILES ${HEADERS}
18 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/time/
19 | )
20 |
21 | install(TARGETS cyber_duration cyber_rate cyber_time
22 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
23 | )
24 |
--------------------------------------------------------------------------------
/cyber/task/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "task",
7 | hdrs = ["task.h"],
8 | deps = [
9 | ":task_manager",
10 | ],
11 | )
12 |
13 | cc_test(
14 | name = "task_test",
15 | size = "small",
16 | srcs = ["task_test.cc"],
17 | deps = [
18 | "//cyber:cyber_core",
19 | "@gtest//:main",
20 | ],
21 | )
22 |
23 | cc_library(
24 | name = "task_manager",
25 | srcs = ["task_manager.cc"],
26 | hdrs = ["task_manager.h"],
27 | deps = [
28 | "//cyber/scheduler:scheduler_factory",
29 | ],
30 | )
31 |
32 | cpplint()
33 |
--------------------------------------------------------------------------------
/cyber/event/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "perf_event_cache",
7 | srcs = ["perf_event_cache.cc"],
8 | hdrs = ["perf_event_cache.h"],
9 | deps = [
10 | ":perf_event",
11 | "//cyber:state",
12 | "//cyber/base:bounded_queue",
13 | "//cyber/common:global_data",
14 | "//cyber/common:log",
15 | "//cyber/common:macros",
16 | "//cyber/time",
17 | ],
18 | )
19 |
20 | cc_library(
21 | name = "perf_event",
22 | hdrs = ["perf_event.h"],
23 | deps = [
24 | "//cyber/common:global_data",
25 | ],
26 | )
27 |
28 | cpplint()
29 |
--------------------------------------------------------------------------------
/cyber/proto/scheduler_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/classic_conf.proto";
6 | import "cyber/proto/choreography_conf.proto";
7 |
8 | message InnerThread {
9 | optional string name = 1;
10 | optional string cpuset = 2;
11 | optional string policy = 3;
12 | optional uint32 prio = 4 [default = 1];
13 | }
14 |
15 | message SchedulerConf {
16 | optional string policy = 1;
17 | optional uint32 routine_num = 2;
18 | optional uint32 default_proc_num = 3;
19 | optional string process_level_cpuset = 4;
20 | repeated InnerThread threads = 5;
21 | optional ClassicConf classic_conf = 6;
22 | optional ChoreographyConf choreography_conf = 7;
23 | }
24 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(timer_component_example VERSION 1.0.0)
4 |
5 | set(proto_src ../proto/examples.pb.cc)
6 | add_library(timer_component_example SHARED timer_component_example.cc
7 | ${proto_src})
8 |
9 | target_link_libraries(timer_component_example
10 | ${Glog_LIBRARY}
11 | gflags
12 | Cyber::init
13 | Cyber::rate
14 | Cyber::time
15 | FastRTPS::fastrtps
16 | Protobuf::libprotobuf
17 | Cyber::component_base
18 | Cyber::transmitter
19 | Cyber::blocker_manager
20 | Cyber::core)
21 | install(TARGETS
22 | timer_component_example
23 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
24 | )
25 |
--------------------------------------------------------------------------------
/cyber/timer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberTimer)
3 |
4 | add_library(cyber_timer timer.cc)
5 | target_link_libraries(cyber_timer Cyber::rate)
6 |
7 | add_library(cyber_timer_task INTERFACE)
8 | add_library(cyber_timer_bucket INTERFACE)
9 |
10 | add_library(cyber_timing_wheel timing_wheel.cc)
11 | target_link_libraries(cyber_timing_wheel Cyber::timer)
12 |
13 | add_library(Cyber::timing_wheel ALIAS cyber_timing_wheel)
14 | add_library(Cyber::timer ALIAS cyber_timer)
15 |
16 | file(GLOB HEADERS *.h)
17 |
18 | install(FILES ${HEADERS}
19 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/timer/
20 | )
21 |
22 | install(TARGETS
23 | cyber_timing_wheel
24 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
25 | )
26 |
--------------------------------------------------------------------------------
/cyber/node/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberNode)
4 |
5 | add_library(cyber_node node.cc)
6 | target_link_libraries(cyber_node Cyber::role_attributes)
7 |
8 | add_library(cyber_reader INTERFACE)
9 | add_library(cyber_writer INTERFACE)
10 | add_library(cyber_node_channel INTERFACE)
11 | add_library(cyber_node_service INTERFACE)
12 |
13 | add_library(Cyber::node ALIAS cyber_node)
14 |
15 | file(GLOB HEADERS *.h)
16 |
17 | install(FILES ${HEADERS}
18 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/node/
19 | )
20 |
21 | install(TARGETS
22 | cyber_node
23 | cyber_reader
24 | cyber_writer
25 | cyber_node_channel
26 | cyber_node_service
27 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
28 | )
29 |
--------------------------------------------------------------------------------
/cyber/croutine/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberCroutine)
4 |
5 | add_compile_options(-mcx16)
6 | add_library(cyber_routine_context detail/routine_context.cc detail/swap_x86_64.S)
7 |
8 | add_library(cyber_croutine croutine.cc)
9 | target_link_libraries(cyber_croutine
10 | Cyber::event
11 | Cyber::routine_context)
12 |
13 | add_library(Cyber::croutine ALIAS cyber_croutine)
14 | add_library(Cyber::routine_context ALIAS cyber_routine_context)
15 |
16 | file(GLOB HEADERS *.h)
17 |
18 | install(FILES ${HEADERS}
19 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/croutine/
20 | )
21 |
22 | install(TARGETS
23 | cyber_croutine
24 | cyber_routine_context
25 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
26 | )
27 |
--------------------------------------------------------------------------------
/cyber/common/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberCommon)
4 |
5 | add_library(cyber_file file.cc)
6 | target_include_directories(cyber_file PUBLIC ${Protobuf_INCLUDE_DIR})
7 | target_link_libraries(cyber_file Protobuf::libprotobuf)
8 |
9 | add_library(cyber_global_data SHARED global_data.cc)
10 | target_link_libraries(cyber_global_data
11 | Cyber::file
12 | Cyber::cyber_conf)
13 |
14 | add_library(Cyber::file ALIAS cyber_file)
15 | add_library(Cyber::global_data ALIAS cyber_global_data)
16 |
17 | file(GLOB HEADERS *.h)
18 |
19 | install(FILES ${HEADERS}
20 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/common
21 | )
22 |
23 | install(TARGETS cyber_file cyber_global_data
24 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
25 | )
26 |
--------------------------------------------------------------------------------
/cyber/proto/topology_change.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/role_attributes.proto";
6 |
7 | enum ChangeType {
8 | CHANGE_NODE = 1;
9 | CHANGE_CHANNEL = 2;
10 | CHANGE_SERVICE = 3;
11 | CHANGE_PARTICIPANT = 4;
12 | };
13 |
14 | enum OperateType {
15 | OPT_JOIN = 1;
16 | OPT_LEAVE = 2;
17 | };
18 |
19 | enum RoleType {
20 | ROLE_NODE = 1;
21 | ROLE_WRITER = 2;
22 | ROLE_READER = 3;
23 | ROLE_SERVER = 4;
24 | ROLE_CLIENT = 5;
25 | ROLE_PARTICIPANT = 6;
26 | };
27 |
28 | message ChangeMsg {
29 | optional uint64 timestamp = 1;
30 | optional ChangeType change_type = 2;
31 | optional OperateType operate_type = 3;
32 | optional RoleType role_type = 4;
33 | optional RoleAttributes role_attr = 5;
34 | };
35 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_monitor/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberMonitor)
3 |
4 | add_executable(cyber_monitor
5 | cyber_topology_message.cc
6 | general_channel_message.cc
7 | general_message_base.cc
8 | general_message.cc
9 | main.cc
10 | renderable_message.cc
11 | screen.cc
12 | )
13 |
14 | target_link_libraries(cyber_monitor
15 | pthread
16 | ncurses
17 | gflags
18 | Cyber::init
19 | Cyber::component_base
20 | Cyber::core
21 | Cyber::blocker_manager
22 | Cyber::endpoint
23 | )
24 |
25 | file(GLOB HEADERS *.h)
26 |
27 | install(FILES ${HEADERS}
28 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/monitor
29 | )
30 |
31 | install(TARGETS cyber_monitor
32 | DESTINATION ${CYBER_INSTALL_DIR}/bin
33 | )
34 |
--------------------------------------------------------------------------------
/cyber/proto/choreography_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | message ChoreographyTask {
6 | optional string name = 1;
7 | optional int32 processor = 2;
8 | optional uint32 prio = 3 [default = 1];
9 | }
10 |
11 | message ChoreographyConf {
12 | optional uint32 choreography_processor_num = 1;
13 | optional string choreography_affinity = 2;
14 | optional string choreography_processor_policy = 3;
15 | optional int32 choreography_processor_prio = 4;
16 | optional string choreography_cpuset = 5;
17 | optional uint32 pool_processor_num = 6;
18 | optional string pool_affinity = 7;
19 | optional string pool_processor_policy = 8;
20 | optional int32 pool_processor_prio = 9;
21 | optional string pool_cpuset = 10;
22 | repeated ChoreographyTask tasks = 11;
23 | }
24 |
--------------------------------------------------------------------------------
/cyber/proto/parameter.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | enum ParamType {
6 | NOT_SET = 0;
7 | BOOL = 1;
8 | INT = 2;
9 | DOUBLE = 3;
10 | STRING = 4;
11 | PROTOBUF = 5;
12 | }
13 |
14 | message Param {
15 | optional string name = 1;
16 | optional ParamType type = 2;
17 | optional string type_name = 3;
18 | oneof oneof_value {
19 | bool bool_value = 4;
20 | int64 int_value = 5;
21 | double double_value = 6;
22 | string string_value = 7;
23 | }
24 | optional bytes proto_desc = 8;
25 | }
26 |
27 | message NodeName {
28 | optional string value = 1;
29 | }
30 |
31 | message ParamName {
32 | optional string value = 1;
33 | }
34 |
35 | message BoolResult {
36 | optional bool value = 1;
37 | }
38 |
39 | message Params {
40 | repeated Param param = 1;
41 | }
42 |
--------------------------------------------------------------------------------
/cyber/message/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberMessage)
4 |
5 | add_library(cyber_protobuf_factory protobuf_factory.cc)
6 | target_link_libraries(cyber_protobuf_factory cyber_proto_desc)
7 |
8 | add_library(message_traits INTERFACE)
9 | add_library(protobuf_traits INTERFACE)
10 | add_library(py_message_traits INTERFACE)
11 | add_library(raw_message_traits INTERFACE)
12 |
13 | add_library(Cyber::protobuf_factory ALIAS cyber_protobuf_factory)
14 |
15 | file(GLOB HEADERS *.h)
16 |
17 | install(FILES ${HEADERS}
18 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/message/
19 | )
20 |
21 | install(TARGETS
22 | cyber_protobuf_factory
23 | message_traits
24 | protobuf_traits
25 | py_message_traits
26 | raw_message_traits
27 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
28 | )
29 |
--------------------------------------------------------------------------------
/cyber/parameter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberParameter)
4 |
5 | add_library(cyber_parameter parameter.cc)
6 | add_library(cyber_parameter_client parameter_client.cc)
7 | add_library(cyber_parameter_server parameter_server.cc)
8 | target_link_libraries(cyber_parameter_server
9 | Cyber::endpoint
10 | )
11 |
12 | add_library(Cyber::parameter ALIAS cyber_parameter)
13 | add_library(Cyber::parameter_client ALIAS cyber_parameter_client)
14 | add_library(Cyber::parameter_server ALIAS cyber_parameter_server)
15 |
16 | file(GLOB HEADERS *.h)
17 |
18 | install(FILES ${HEADERS}
19 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/parameter/
20 | )
21 |
22 | install(TARGETS cyber_parameter cyber_parameter_client cyber_parameter_server
23 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
24 | )
25 |
--------------------------------------------------------------------------------
/cmake/FindGlog.cmake:
--------------------------------------------------------------------------------
1 | find_library(Glog_LIBRARY NAMES "glog"
2 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/lib"
3 | NO_DEFAULT_PATH
4 | )
5 | find_path(Glog_INCLUDE_DIR NAMES "glog/config.h"
6 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/include"
7 | DOC "The Glog Include path")
8 | message(STATUS "Glog inc: ${Glog_INCLUDE_DIR} lib: ${Glog_LIBRARY}")
9 |
10 | include(FindPackageHandleStandardArgs)
11 | find_package_handle_standard_args(Glog DEFAULT_MSG Glog_INCLUDE_DIR Glog_LIBRARY)
12 |
13 | mark_as_advanced(Glog_INCLUDE_DIR Glog_LIBRARY)
14 |
15 | if(Glog_FOUND)
16 | if (NOT TARGET Glog::glog)
17 | add_library(Glog::glog INTERFACE IMPORTED)
18 | target_link_libraries(Glog::glog INTERFACE ${Glog_LIBRARY})
19 | target_include_directories(Glog::glog INTERFACE ${Glog_INCLUDE_DIR})
20 | endif()
21 | endif()
22 |
--------------------------------------------------------------------------------
/cyber/component/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberComponent)
4 |
5 | add_library(cyber_timer_component timer_component.cc)
6 |
7 | add_library(cyber_component_base INTERFACE)
8 | target_include_directories(cyber_component_base INTERFACE
9 | $
10 | $
11 | )
12 | target_link_libraries(cyber_component_base INTERFACE
13 | Cyber::node
14 | )
15 |
16 | add_library(Cyber::component ALIAS cyber_timer_component)
17 | add_library(Cyber::component_base ALIAS cyber_component_base)
18 |
19 | file(GLOB HEADERS *.h)
20 |
21 | install(FILES ${HEADERS}
22 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/component/
23 | )
24 |
25 | install(TARGETS cyber_timer_component
26 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
27 | )
28 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_binary(
6 | name = "py_talker",
7 | srcs = ["py_talker.cc"],
8 | deps = [
9 | "//cyber",
10 | "//cyber/proto:unit_test_cc_proto",
11 | "//cyber/py_wrapper:py_cyber",
12 | ],
13 | )
14 |
15 | cc_binary(
16 | name = "py_listener",
17 | srcs = ["py_listener.cc"],
18 | deps = [
19 | "//cyber",
20 | "//cyber/proto:unit_test_cc_proto",
21 | "//cyber/py_wrapper:py_cyber",
22 | ],
23 | )
24 |
25 | cc_binary(
26 | name = "py_service",
27 | srcs = ["py_service.cc"],
28 | deps = [
29 | "//cyber",
30 | "//cyber/proto:unit_test_cc_proto",
31 | "//cyber/py_wrapper:py_cyber",
32 | ],
33 | )
34 |
35 | cpplint()
36 |
--------------------------------------------------------------------------------
/cyber/proto/component_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/qos_profile.proto";
6 |
7 | message ReaderOption {
8 | optional string channel = 1;
9 | optional QosProfile qos_profile =
10 | 2; // depth: used to define capacity of processed messages
11 | optional uint32 pending_queue_size = 3
12 | [default = 1]; // used to define capacity of unprocessed messages
13 | }
14 |
15 | message ComponentConfig {
16 | optional string name = 1;
17 | optional string config_file_path = 2;
18 | optional string flag_file_path = 3;
19 | repeated ReaderOption readers = 4;
20 | }
21 |
22 | message TimerComponentConfig {
23 | optional string name = 1;
24 | optional string config_file_path = 2;
25 | optional string flag_file_path = 3;
26 | optional uint32 interval = 4; // In milliseconds.
27 | }
28 |
--------------------------------------------------------------------------------
/cyber/conf/cyber.pb.conf:
--------------------------------------------------------------------------------
1 | # transport_conf {
2 | # shm_conf {
3 | # # "multicast" "condition"
4 | # notifier_type: "condition"
5 | # # "posix" "xsi"
6 | # shm_type: "xsi"
7 | # shm_locator {
8 | # ip: "239.255.0.100"
9 | # port: 8888
10 | # }
11 | # }
12 | # participant_attr {
13 | # lease_duration: 12
14 | # announcement_period: 3
15 | # domain_id_gain: 200
16 | # port_base: 10000
17 | # }
18 | # communication_mode {
19 | # same_proc: INTRA
20 | # diff_proc: SHM
21 | # diff_host: RTPS
22 | # }
23 | # resource_limit {
24 | # max_history_depth: 1000
25 | # }
26 | # }
27 |
28 | run_mode_conf {
29 | run_mode: MODE_REALITY
30 | }
31 |
32 | scheduler_conf {
33 | routine_num: 100
34 | default_proc_num: 16
35 | }
36 |
--------------------------------------------------------------------------------
/cyber/mainboard/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberMainboad)
4 |
5 | add_executable(cyber_mainboard
6 | mainboard.cc
7 | module_argument.cc
8 | module_controller.cc
9 | )
10 |
11 | target_link_libraries(cyber_mainboard
12 | PUBLIC
13 | cyber_class_loader
14 | cyber_class_loader_utility
15 | cyber_class_factory
16 | cyber_class_loader_manager
17 | cyber_scheduler
18 | cyber_state
19 | cyber_file
20 | cyber_init
21 | cyber_node
22 | cyber_global_data
23 | ${Glog_LIBRARY}
24 | gflags
25 | Cyber::dag_conf
26 | Cyber::perf_conf
27 | )
28 |
29 | file(GLOB HEADERS *.h)
30 |
31 | install(FILES ${HEADERS}
32 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/mainboard/
33 | )
34 |
35 | install(TARGETS cyber_mainboard
36 | DESTINATION ${CYBER_INSTALL_DIR}/bin
37 | )
38 |
--------------------------------------------------------------------------------
/cmake/FindGflags.cmake:
--------------------------------------------------------------------------------
1 | find_library(Gflags_LIBRARY NAMES "gflags"
2 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/lib"
3 | NO_DEFAULT_PATH
4 | )
5 | find_path(Gflags_INCLUDE_DIR NAMES "gflags/gflags.h"
6 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/include"
7 | NO_DEFAULT_PATH
8 | DOC "The Gflags Include path")
9 | message(STATUS "Gflags inc: ${Gflags_INCLUDE_DIR} lib: ${Gflags_LIBRARY}")
10 |
11 | include(FindPackageHandleStandardArgs)
12 | find_package_handle_standard_args(Gflags DEFAULT_MSG Gflags_INCLUDE_DIR Gflags_LIBRARY)
13 |
14 | mark_as_advanced(Gflags_INCLUDE_DIR Gflags_LIBRARY)
15 |
16 | if(Gflags_FOUND)
17 | if(NOT TARGET Gflags::gflags)
18 | add_library(Gflags::gflags INTERFACE IMPORTED)
19 | target_link_libraries(Gflags::gflags INTERFACE ${Gflags_LIBRARY})
20 | target_include_directories(Gflags::gflags INTERFACE ${Gflags_INCLUDE_DIR})
21 | endif()
22 | endif()
23 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/cyber/proto/qos_profile.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | enum QosHistoryPolicy {
6 | HISTORY_SYSTEM_DEFAULT = 0;
7 | HISTORY_KEEP_LAST = 1;
8 | HISTORY_KEEP_ALL = 2;
9 | };
10 |
11 | enum QosReliabilityPolicy {
12 | RELIABILITY_SYSTEM_DEFAULT = 0;
13 | RELIABILITY_RELIABLE = 1;
14 | RELIABILITY_BEST_EFFORT = 2;
15 | };
16 |
17 | enum QosDurabilityPolicy {
18 | DURABILITY_SYSTEM_DEFAULT = 0;
19 | DURABILITY_TRANSIENT_LOCAL = 1;
20 | DURABILITY_VOLATILE = 2;
21 | };
22 |
23 | message QosProfile {
24 | optional QosHistoryPolicy history = 1 [default = HISTORY_KEEP_LAST];
25 | optional uint32 depth = 2 [default = 1]; // capacity of history
26 | optional uint32 mps = 3 [default = 0]; // messages per second
27 | optional QosReliabilityPolicy reliability = 4
28 | [default = RELIABILITY_RELIABLE];
29 | optional QosDurabilityPolicy durability = 5 [default = DURABILITY_VOLATILE];
30 | };
--------------------------------------------------------------------------------
/cmake/FindFastRTPS.cmake:
--------------------------------------------------------------------------------
1 | find_library(FastRTPS_LIBRARY NAMES "fastrtps"
2 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/lib"
3 | NO_DEFAULT_PATH
4 | )
5 | find_path(FastRTPS_INCLUDE_DIR NAMES "fastrtps/Domain.h"
6 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/include"
7 | NO_DEFAULT_PATH
8 | DOC "The FastRTPS Include path")
9 | message(STATUS "FastRTPS inc: ${FastRTPS_INCLUDE_DIR} lib: ${FastRTPS_LIBRARY} ")
10 |
11 | include(FindPackageHandleStandardArgs)
12 | find_package_handle_standard_args(FastRTPS DEFAULT_MSG FastRTPS_INCLUDE_DIR FastRTPS_LIBRARY)
13 |
14 | mark_as_advanced(FastRTPS_INCLUDE_DIR FastRTPS_LIBRARY)
15 |
16 | if(FastRTPS_FOUND)
17 | if(NOT TARGET FastRTPS::fastrtps)
18 | add_library(FastRTPS::fastrtps INTERFACE IMPORTED)
19 | target_link_libraries(FastRTPS::fastrtps INTERFACE ${FastRTPS_LIBRARY})
20 | target_include_directories(FastRTPS::fastrtps INTERFACE ${FastRTPS_INCLUDE_DIR})
21 | endif()
22 | endif()
23 |
--------------------------------------------------------------------------------
/cyber/class_loader/test/base.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 201 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #pragma once
18 |
19 | class Base {
20 | public:
21 | virtual void DoSomething() = 0;
22 | virtual ~Base() {}
23 | };
24 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_recorder/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberRecorder)
3 |
4 | add_executable(cyber_recorder
5 | player/player.cc
6 | player/play_task.cc
7 | player/play_task_buffer.cc
8 | player/play_task_consumer.cc
9 | player/play_task_producer.cc
10 | info.cc
11 | main.cc
12 | recorder.cc
13 | recoverer.cc
14 | spliter.cc
15 | )
16 |
17 | target_link_libraries(cyber_recorder
18 | pthread
19 | gflags
20 | Cyber::pb_record
21 | Cyber::record_reader
22 | Cyber::record_viewer
23 | Cyber::record_writer
24 | Cyber::init
25 | Cyber::component_base
26 | Cyber::core
27 | Cyber::blocker_manager
28 | Cyber::endpoint
29 | )
30 |
31 | file(GLOB HEADERS *.h)
32 |
33 | install(FILES ${HEADERS}
34 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/monitor
35 | )
36 |
37 | install(TARGETS cyber_recorder
38 | DESTINATION ${CYBER_INSTALL_DIR}/bin
39 | )
40 |
41 |
--------------------------------------------------------------------------------
/cmake/FindProtobuf.cmake:
--------------------------------------------------------------------------------
1 | find_library(Protobuf_LIBRARY NAMES "protobuf"
2 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/lib"
3 | NO_DEFAULT_PATH
4 | )
5 | find_path(Protobuf_INCLUDE_DIR NAMES "google/protobuf/stubs/common.h"
6 | PATHS "${LOCAL_DEPENDS_INSTALL_DIR}/include"
7 | NO_DEFAULT_PATH
8 | DOC "The Protobuf Include path")
9 |
10 | message(STATUS "Protobuf inc: ${Protobuf_INCLUDE_DIR} lib : ${Protobuf_LIBRARY}")
11 |
12 | include(FindPackageHandleStandardArgs)
13 | find_package_handle_standard_args(Protobuf DEFAULT_MSG Protobuf_INCLUDE_DIR Protobuf_LIBRARY)
14 |
15 | mark_as_advanced(Protobuf_INCLUDE_DIR Protobuf_LIBRARY)
16 |
17 | if(Protobuf_FOUND)
18 | if (NOT TARGET Protobuf::libprotobuf)
19 | add_library(Protobuf::libprotobuf INTERFACE IMPORTED)
20 | target_link_libraries(Protobuf::libprotobuf INTERFACE ${Protobuf_LIBRARY})
21 | target_include_directories(Protobuf::libprotobuf INTERFACE ${Protobuf_INCLUDE_DIR})
22 | endif()
23 | endif()
24 |
--------------------------------------------------------------------------------
/cyber/croutine/detail/swap_aarch64.S:
--------------------------------------------------------------------------------
1 | .text
2 | .align 4
3 | .globl ctx_swap
4 |
5 | ctx_swap:
6 | stp x0, x30, [sp,#-16]!
7 | stp d8, d9, [sp,#-16]!
8 | stp d10, d11, [sp,#-16]!
9 | stp d12, d13, [sp,#-16]!
10 | stp d14, d15, [sp,#-16]!
11 | stp x1, x19, [sp,#-16]!
12 | stp x20, x21, [sp,#-16]!
13 | stp x22, x23, [sp,#-16]!
14 | stp x24, x25, [sp,#-16]!
15 | stp x26, x27, [sp,#-16]!
16 | stp x28, x29, [sp,#-16]!
17 |
18 | mov x3, sp
19 | str x3, [x0]
20 |
21 | ldr x3, [x1]
22 | mov sp, x3
23 |
24 | ldp x28, x29, [sp]
25 | ldp x26, x27, [sp,#16]!
26 | ldp x24, x25, [sp,#16]!
27 | ldp x22, x23, [sp,#16]!
28 | ldp x20, x21, [sp,#16]!
29 | ldp x1, x19, [sp,#16]!
30 | ldp d14, d15, [sp,#16]!
31 | ldp d12, d13, [sp,#16]!
32 | ldp d10, d11, [sp,#16]!
33 | ldp d8, d9, [sp,#16]!
34 | ldp x0, x30, [sp,#16]!
35 |
36 | add sp, sp, #16
37 |
38 | ret
39 |
--------------------------------------------------------------------------------
/cyber/logger/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberLogger)
4 |
5 | add_library(cyber_async_logger async_logger.cc)
6 | target_link_libraries(cyber_async_logger Cyber::logg_file_object)
7 |
8 | add_library(cyber_logger logger.cc)
9 |
10 | add_library(cyber_log_file_object log_file_object.cc)
11 | target_link_libraries(cyber_log_file_object Cyber::logger_util)
12 |
13 | add_library(cyber_logger_util logger_util.cc)
14 |
15 | add_library(Cyber::async_logger ALIAS cyber_async_logger)
16 | add_library(Cyber::logger ALIAS cyber_logger)
17 | add_library(Cyber::logg_file_object ALIAS cyber_log_file_object)
18 | add_library(Cyber::logger_util ALIAS cyber_logger_util)
19 |
20 | file(GLOB HEADERS *.h)
21 |
22 | install(FILES ${HEADERS}
23 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/logger/
24 | )
25 |
26 | install(TARGETS
27 | cyber_async_logger
28 | cyber_logger
29 | cyber_log_file_object
30 | cyber_logger_util
31 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
32 | )
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### CyberRT Lite
2 |
3 | Build [Apollo CyberRT](https://github.com/ApolloAuto/apollo.git ) with CMake
4 |
5 | How to build
6 |
7 | 1. prepare dependencies
8 |
9 | ```
10 | cd cyber-rt
11 | wget http://apolloauto.club/mirror/cyberdeps.tgz
12 | tar zxvf cyberdeps.tgz
13 |
14 | ls tmp/
15 | FastRTPS_1.5.0.patch Fast-RTPS-1.5.0.tar.gz gflags-2.2.0.tar.gz glog-0.3.5.tar.gz protobuf-3.3.0.tar.gz
16 | ```
17 |
18 | 2. build dependencies
19 |
20 | ```
21 | mkdir build
22 | cd build
23 | cmake ..
24 | make
25 | ```
26 |
27 | 3. build cyber-rt lite
28 |
29 | ```
30 | cmake ..
31 | scripts/genprotosrc.sh
32 | make
33 |
34 | ```
35 |
36 | 4. run examples
37 |
38 | ```
39 | cyber-rt/build$ cyber/examples/cyber_example_talker
40 | cyber-rt/build$ cyber/examples/cyber_example_listener
41 | ```
42 |
43 | Note:
44 |
45 | This is a Pre-Alpha version , not fully tested, functions may not work well, All contributes are welcome!
46 |
47 |
48 | TODO:
49 |
50 | 1. make a cmake Macro or Funtion to generate proto source
51 |
52 |
--------------------------------------------------------------------------------
/cyber/proto/role_attributes.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | import "cyber/proto/qos_profile.proto";
6 |
7 | message SocketAddr {
8 | optional string ip = 1; // dotted decimal
9 | optional uint32 port = 2;
10 | };
11 |
12 | message RoleAttributes {
13 | optional string host_name = 1;
14 | optional string host_ip = 2;
15 | optional int32 process_id = 3;
16 | optional string node_name = 4;
17 | optional uint64 node_id = 5; // hash value of node_name
18 | // especially for WRITER and READER
19 | optional string channel_name = 6;
20 | optional uint64 channel_id = 7; // hash value of channel_name
21 | optional string message_type = 8;
22 | optional bytes proto_desc = 9;
23 | optional uint64 id = 10;
24 | optional QosProfile qos_profile = 11;
25 | optional SocketAddr socket_addr = 12; // reserved for socket communication
26 | // especially for SERVER and CLIENT
27 | optional string service_name = 13;
28 | optional uint64 service_id = 14; // hash value of service_name
29 | };
30 |
--------------------------------------------------------------------------------
/cyber/setup.bash:
--------------------------------------------------------------------------------
1 | export CYBER_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2 | binary_path="$CYBER_PATH/bin"
3 | lib_path="$CYBER_PATH/lib"
4 | proto_path="$CYBER_PATH/../../lib"
5 |
6 | PYTHON_LD_PATH="/apollo/bazel-bin/cyber/py_wrapper"
7 |
8 | qt_path=/usr/local/Qt5.5.1/5.5/gcc_64
9 | export LD_LIBRARY_PATH=${proto_path}:${lib_path}:$LD_LIBRARY_PATH
10 | export QT_QPA_PLATFORM_PLUGIN_PATH=${qt_path}/plugins
11 | export PATH=${binary_path}:${recorder_path}:${monitor_path}:${launch_path}:${channel_path}:${node_path}:${service_path}:${qt_path}/bin:${visualizer_path}:${rosbag_to_record_path}:$PATH
12 | export PYTHONPATH=${PYTHON_LD_PATH}:${CYBER_PATH}/python:$PYTHONPATH
13 |
14 | export CYBER_DOMAIN_ID=80
15 | export CYBER_IP=127.0.0.1
16 |
17 | export GLOG_log_dir=$CYBER_PATH/log
18 | export GLOG_alsologtostderr=0
19 | export GLOG_colorlogtostderr=1
20 | export GLOG_minloglevel=0
21 |
22 | export sysmo_start=0
23 |
24 | # for DEBUG log
25 | #export GLOG_minloglevel=-1
26 | #export GLOG_v=4
27 |
28 | #source ${CYBER_PATH}/tools/cyber_tools_auto_complete.bash
29 |
--------------------------------------------------------------------------------
/cyber/examples/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_binary(
6 | name = "talker",
7 | srcs = ["talker.cc"],
8 | deps = [
9 | "//cyber",
10 | "//cyber/examples/proto:examples_cc_proto",
11 | ],
12 | )
13 |
14 | cc_binary(
15 | name = "listener",
16 | srcs = ["listener.cc"],
17 | deps = [
18 | "//cyber",
19 | "//cyber/examples/proto:examples_cc_proto",
20 | ],
21 | )
22 |
23 | cc_binary(
24 | name = "paramserver",
25 | srcs = ["paramserver.cc"],
26 | deps = [
27 | "//cyber",
28 | "//cyber/parameter",
29 | ],
30 | )
31 |
32 | cc_binary(
33 | name = "service",
34 | srcs = ["service.cc"],
35 | deps = [
36 | "//cyber",
37 | "//cyber/examples/proto:examples_cc_proto",
38 | ],
39 | )
40 |
41 | cc_binary(
42 | name = "record",
43 | srcs = ["record.cc"],
44 | deps = [
45 | "//cyber",
46 | "//cyber/proto:record_cc_proto",
47 | ],
48 | )
49 |
50 | cpplint()
51 |
--------------------------------------------------------------------------------
/cyber/doxy-docs/source/conf.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import os
5 | import subprocess
6 |
7 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
8 |
9 | if on_rtd:
10 | subprocess.call('cd ..; doxygen', shell=True)
11 |
12 | import sphinx_rtd_theme
13 |
14 | html_theme = "sphinx_rtd_theme"
15 |
16 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
17 |
18 | def setup(app):
19 | app.add_stylesheet("main_stylesheet.css")
20 |
21 | extensions = ['breathe', 'recommonmark']
22 | breathe_projects = { 'Cyber RT Documents': '../xml' }
23 | templates_path = ['_templates']
24 | html_static_path = ['_static']
25 | source_suffix = {
26 | '.rst': 'restructuredtext',
27 | '.md': 'markdown',
28 | }
29 | master_doc = 'index'
30 | project = 'Cyber RT Documents'
31 | copyright = '2019, Apollo'
32 | author = 'Apollo Baidu'
33 |
34 | #html_logo = 'quantstack-white.svg'
35 |
36 | exclude_patterns = []
37 | highlight_language = 'c++'
38 | pygments_style = 'sphinx'
39 | todo_include_todos = False
40 | htmlhelp_basename = 'CyberRTdoc'
41 |
42 |
--------------------------------------------------------------------------------
/cyber/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(CyberCore)
3 |
4 | add_library(cyber_core cyber.cc)
5 |
6 | add_library(cyber_init init.cc)
7 | target_link_libraries(cyber_init
8 | ${Glog_LIBRARY}
9 | Cyber::service_manager
10 | Cyber::async_logger
11 | Cyber::task_manager
12 | Cyber::timing_wheel
13 | Cyber::state
14 | Cyber::global_data
15 | Cyber::sysmo
16 | Cyber::topology_manager)
17 |
18 | add_library(cyber_state state.cc)
19 | add_library(cyber_binary INTERFACE)
20 |
21 | add_library(Cyber::core ALIAS cyber_core)
22 | add_library(Cyber::init ALIAS cyber_init)
23 | add_library(Cyber::state ALIAS cyber_state)
24 |
25 | file(GLOB HEADERS *.h)
26 |
27 | install(FILES ${HEADERS}
28 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/
29 | )
30 |
31 | install(TARGETS
32 | cyber_core cyber_init cyber_state
33 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
34 | )
35 |
36 | install(DIRECTORY
37 | conf
38 | DESTINATION ${CYBER_INSTALL_DIR}
39 | )
40 |
41 | install(FILES
42 | setup.bash
43 | DESTINATION ${CYBER_INSTALL_DIR}
44 | )
45 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 |
19 | import sys
20 |
21 |
22 | if sys.version_info[0] >= 3:
23 | sys.stderr.write('''
24 | You are running Python3 while importing Python2 Cyber wrapper!
25 | Please change to "import cyber_py3.xyz" accordingly.''')
26 | sys.exit(1)
27 |
--------------------------------------------------------------------------------
/cyber/time/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "time",
7 | srcs = ["time.cc"],
8 | hdrs = ["time.h"],
9 | deps = [
10 | ":duration",
11 | "//cyber/common",
12 | ],
13 | )
14 |
15 | cc_test(
16 | name = "time_test",
17 | size = "small",
18 | srcs = ["time_test.cc"],
19 | deps = [
20 | "//cyber:cyber_core",
21 | "@gtest//:main",
22 | ],
23 | )
24 |
25 | cc_library(
26 | name = "rate",
27 | srcs = ["rate.cc"],
28 | hdrs = ["rate.h"],
29 | deps = [
30 | ":duration",
31 | ":time",
32 | "//cyber/common",
33 | ],
34 | )
35 |
36 | cc_library(
37 | name = "duration",
38 | srcs = ["duration.cc"],
39 | hdrs = ["duration.h"],
40 | deps = [
41 | "//cyber/common",
42 | ],
43 | )
44 |
45 | cc_test(
46 | name = "duration_test",
47 | size = "small",
48 | srcs = ["duration_test.cc"],
49 | deps = [
50 | "//cyber:cyber_core",
51 | "@gtest//:main",
52 | ],
53 | )
54 |
55 | cpplint()
56 |
--------------------------------------------------------------------------------
/cyber/scheduler/processor_context.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/scheduler/processor_context.h"
18 |
19 | namespace apollo {
20 | namespace cyber {
21 | namespace scheduler {
22 |
23 | void ProcessorContext::Shutdown() { stop_.store(true); }
24 |
25 | } // namespace scheduler
26 | } // namespace cyber
27 | } // namespace apollo
28 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | import sys
20 |
21 |
22 | if sys.version_info[0] < 3:
23 | sys.stderr.write('''
24 | You are running Python2 while importing Python3 Cyber wrapper!
25 | Please change to "import cyber_py.xyz" accordingly.''')
26 | sys.exit(1)
27 |
--------------------------------------------------------------------------------
/cyber/common/log_test.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/common/log.h"
18 |
19 | #include "glog/logging.h"
20 | #include "gtest/gtest.h"
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace common {
25 |
26 | TEST(LogTest, TestAll) { AINFO << "11111"; }
27 |
28 | } // namespace common
29 | } // namespace cyber
30 | } // namespace apollo
31 |
--------------------------------------------------------------------------------
/cyber/init.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_INIT_H_
18 | #define CYBER_INIT_H_
19 |
20 | #include "cyber/common/log.h"
21 | #include "cyber/state.h"
22 |
23 | namespace apollo {
24 | namespace cyber {
25 |
26 | bool Init(const char* binary_name);
27 | void Clear();
28 |
29 | } // namespace cyber
30 | } // namespace apollo
31 |
32 | #endif // CYBER_INIT_H_
33 |
--------------------------------------------------------------------------------
/cyber/timer/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "timer",
7 | srcs = ["timer.cc"],
8 | hdrs = ["timer.h"],
9 | deps = [
10 | ":timing_wheel",
11 | "//cyber/common:global_data",
12 | ],
13 | )
14 |
15 | cc_library(
16 | name = "timer_task",
17 | hdrs = ["timer_task.h"],
18 | )
19 |
20 | cc_library(
21 | name = "timer_bucket",
22 | hdrs = ["timer_bucket.h"],
23 | deps = [
24 | ":timer_task",
25 | ],
26 | )
27 |
28 | cc_library(
29 | name = "timing_wheel",
30 | srcs = ["timing_wheel.cc"],
31 | hdrs = ["timing_wheel.h"],
32 | deps = [
33 | ":timer_bucket",
34 | "//cyber/task",
35 | "//cyber/time",
36 | "//cyber/time:duration",
37 | "//cyber/time:rate",
38 | ],
39 | )
40 |
41 | cc_test(
42 | name = "timer_test",
43 | size = "small",
44 | timeout = "moderate",
45 | srcs = ["timer_test.cc"],
46 | deps = [
47 | "//cyber:cyber_core",
48 | "//cyber:init",
49 | "@gtest//:main",
50 | ],
51 | )
52 |
53 | cpplint()
54 |
--------------------------------------------------------------------------------
/cyber/transport/shm/state.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/transport/shm/state.h"
18 |
19 | namespace apollo {
20 | namespace cyber {
21 | namespace transport {
22 |
23 | State::State(const uint64_t& ceiling_msg_size)
24 | : ceiling_msg_size_(ceiling_msg_size) {}
25 |
26 | State::~State() {}
27 |
28 | } // namespace transport
29 | } // namespace cyber
30 | } // namespace apollo
31 |
--------------------------------------------------------------------------------
/cyber/state.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/state.h"
18 |
19 | #include
20 |
21 | namespace apollo {
22 | namespace cyber {
23 |
24 | namespace {
25 | std::atomic g_cyber_state;
26 | }
27 |
28 | State GetState() { return g_cyber_state.load(); }
29 |
30 | void SetState(const State& state) { g_cyber_state.store(state); }
31 |
32 | } // namespace cyber
33 | } // namespace apollo
34 |
--------------------------------------------------------------------------------
/cyber/record/file/section.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_RECORD_FILE_SECTION_H_
18 | #define CYBER_RECORD_FILE_SECTION_H_
19 |
20 | namespace apollo {
21 | namespace cyber {
22 | namespace record {
23 |
24 | struct Section {
25 | proto::SectionType type;
26 | int64_t size;
27 | };
28 |
29 | } // namespace record
30 | } // namespace cyber
31 | } // namespace apollo
32 |
33 | #endif // CYBER_RECORD_FILE_SECTION_H_
34 |
--------------------------------------------------------------------------------
/cyber/transport/dispatcher/intra_dispatcher.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/transport/dispatcher/intra_dispatcher.h"
18 |
19 | namespace apollo {
20 | namespace cyber {
21 | namespace transport {
22 |
23 | IntraDispatcher::IntraDispatcher() { chain_.reset(new ChannelChain()); }
24 |
25 | IntraDispatcher::~IntraDispatcher() {}
26 |
27 | } // namespace transport
28 | } // namespace cyber
29 | } // namespace apollo
30 |
--------------------------------------------------------------------------------
/cyber/blocker/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "blocker_manager",
7 | srcs = ["blocker_manager.cc"],
8 | hdrs = ["blocker_manager.h"],
9 | deps = [
10 | ":blocker",
11 | ],
12 | )
13 |
14 | cc_test(
15 | name = "blocker_manager_test",
16 | size = "small",
17 | srcs = ["blocker_manager_test.cc"],
18 | deps = [
19 | "//cyber",
20 | "//cyber/proto:unit_test_cc_proto",
21 | "@gtest//:main",
22 | ],
23 | )
24 |
25 | cc_library(
26 | name = "blocker",
27 | hdrs = ["blocker.h"],
28 | )
29 |
30 | cc_test(
31 | name = "blocker_test",
32 | size = "small",
33 | srcs = ["blocker_test.cc"],
34 | deps = [
35 | "//cyber",
36 | "//cyber/proto:unit_test_cc_proto",
37 | "@gtest//:main",
38 | ],
39 | )
40 |
41 | cc_library(
42 | name = "intra_reader",
43 | hdrs = ["intra_reader.h"],
44 | deps = [
45 | ":blocker_manager",
46 | ],
47 | )
48 |
49 | cc_library(
50 | name = "intra_writer",
51 | hdrs = ["intra_writer.h"],
52 | deps = [
53 | ":blocker_manager",
54 | ],
55 | )
56 |
57 | cpplint()
58 |
--------------------------------------------------------------------------------
/cyber/common/util.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_COMMON_UTIL_H_
18 | #define CYBER_COMMON_UTIL_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace common {
25 |
26 | inline std::size_t Hash(const std::string& key) {
27 | return std::hash{}(key);
28 | }
29 |
30 | } // namespace common
31 | } // namespace cyber
32 | } // namespace apollo
33 |
34 | #endif // CYBER_COMMON_UTIL_H_
35 |
--------------------------------------------------------------------------------
/cyber/python/README.md:
--------------------------------------------------------------------------------
1 | # Python Wrapper for Cyber RT
2 |
3 | ## Usage
4 |
5 | Make sure you have built Apollo successfully, which should also have added
6 | `/apollo/cyber/python` to the PYTHONPATH for you. Then in Python code:
7 |
8 | ```python
9 | import sys
10 |
11 | from cyber_py3 import cyber
12 |
13 |
14 | cyber.init()
15 |
16 | if not cyber.ok():
17 | print('Well, something is wrong.')
18 | sys.exit(1)
19 |
20 | # Do your job here.
21 | cyber.shutdown()
22 | ```
23 |
24 | Learn more usage from the [examples](cyber_py3/examples/) and
25 | [tests](cyber_py3/test/).
26 |
27 | ## Work with Python2?
28 |
29 | Firstly, it's not recommended, as Python2 is deprecated since
30 | [Jan 1, 2020](https://pythonclock.org). We also deprioritized maintaining the
31 | Python2 Wrapper.
32 |
33 | Similar to the Python 3 wrapper, but just import things from the cyber_py
34 | module. Everything should work the same.
35 |
36 | ```python
37 | import sys
38 |
39 | from cyber_py import cyber
40 |
41 |
42 | cyber.init()
43 |
44 | if not cyber.ok():
45 | print('Well, something is wrong.')
46 | sys.exit(1)
47 |
48 | # Do your job here.
49 | cyber.shutdown()
50 | ```
51 |
52 | Learn more usage from the [examples](cyber_py/examples/) and
53 | [tests](cyber_py/test/).
54 |
--------------------------------------------------------------------------------
/cyber/croutine/detail/swap_x86_64.S:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | .globl ctx_swap
18 | .type ctx_swap, @function
19 | ctx_swap:
20 | pushq %rdi
21 | pushq %r12
22 | pushq %r13
23 | pushq %r14
24 | pushq %r15
25 | pushq %rbx
26 | pushq %rbp
27 | movq %rsp, (%rdi)
28 |
29 | movq (%rsi), %rsp
30 | popq %rbp
31 | popq %rbx
32 | popq %r15
33 | popq %r14
34 | popq %r13
35 | popq %r12
36 | popq %rdi
37 | ret
38 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/common_component_example.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 | #include "cyber/examples/common_component_example/common_component_example.h"
17 | #include
18 | using namespace std;
19 | bool CommonComponentSample::Init() {
20 | AINFO << "Commontest component init";
21 | return true;
22 | }
23 |
24 | bool CommonComponentSample::Proc(const std::shared_ptr& msg0) {
25 | cout << msg0->content() << endl;
26 | AINFO << "Start common component Proc [" "]";
27 | return true;
28 | }
29 |
--------------------------------------------------------------------------------
/cyber/class_loader/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "class_loader",
7 | srcs = [
8 | "class_loader.cc",
9 | "utility/class_factory.cc",
10 | "utility/class_loader_utility.cc",
11 | ],
12 | hdrs = [
13 | "class_loader.h",
14 | "class_loader_register_macro.h",
15 | "utility/class_factory.h",
16 | "utility/class_loader_utility.h",
17 | ],
18 | linkopts = [
19 | "-lPocoFoundation",
20 | ],
21 | deps = [
22 | "//cyber:init",
23 | "//cyber/common:log",
24 | ],
25 | )
26 |
27 | cc_library(
28 | name = "class_loader_manager",
29 | srcs = ["class_loader_manager.cc"],
30 | hdrs = ["class_loader_manager.h"],
31 | deps = [
32 | ":class_loader",
33 | ],
34 | )
35 |
36 | cc_test(
37 | name = "class_loader_test",
38 | size = "small",
39 | srcs = ["class_loader_test.cc"],
40 | data = [
41 | "//cyber/class_loader/test:plugin1",
42 | "//cyber/class_loader/test:plugin2",
43 | ],
44 | deps = [
45 | "//cyber",
46 | "//cyber/class_loader/test:base",
47 | "//cyber/proto:unit_test_cc_proto",
48 | "@gtest",
49 | ],
50 | )
51 |
52 | cpplint()
53 |
--------------------------------------------------------------------------------
/cyber/proto/transport_conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package apollo.cyber.proto;
4 |
5 | enum OptionalMode {
6 | HYBRID = 0;
7 | INTRA = 1;
8 | SHM = 2;
9 | RTPS = 3;
10 | }
11 |
12 | message ShmMulticastLocator {
13 | optional string ip = 1;
14 | optional uint32 port = 2;
15 | };
16 |
17 | message ShmConf {
18 | optional string notifier_type = 1;
19 | optional string shm_type = 2;
20 | optional ShmMulticastLocator shm_locator = 3;
21 | };
22 |
23 | message RtpsParticipantAttr {
24 | optional int32 lease_duration = 1 [default = 12];
25 | optional int32 announcement_period = 2 [default = 3];
26 | optional uint32 domain_id_gain = 3 [default = 200];
27 | optional uint32 port_base = 4 [default = 10000];
28 | };
29 |
30 | message CommunicationMode {
31 | optional OptionalMode same_proc = 1 [default = INTRA]; // INTRA SHM RTPS
32 | optional OptionalMode diff_proc = 2 [default = SHM]; // SHM RTPS
33 | optional OptionalMode diff_host = 3 [default = RTPS]; // RTPS
34 | };
35 |
36 | message ResourceLimit {
37 | optional uint32 max_history_depth = 1 [default = 1000];
38 | };
39 |
40 | message TransportConf {
41 | optional ShmConf shm_conf = 1;
42 | optional RtpsParticipantAttr participant_attr = 2;
43 | optional CommunicationMode communication_mode = 3;
44 | optional ResourceLimit resource_limit = 4;
45 | };
46 |
--------------------------------------------------------------------------------
/cyber/transport/shm/segment_factory.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_SHM_SEGMENT_FACTORY_H_
18 | #define CYBER_TRANSPORT_SHM_SEGMENT_FACTORY_H_
19 |
20 | #include "cyber/transport/shm/segment.h"
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace transport {
25 |
26 | class SegmentFactory {
27 | public:
28 | static SegmentPtr CreateSegment(uint64_t channel_id);
29 | };
30 |
31 | } // namespace transport
32 | } // namespace cyber
33 | } // namespace apollo
34 |
35 | #endif // CYBER_TRANSPORT_SHM_SEGMENT_FACTORY_H_
36 |
--------------------------------------------------------------------------------
/cyber/binary.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_BINARY_H_
18 | #define CYBER_BINARY_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | class Binary {
25 | public:
26 | static std::string GetName() { return GetNameRef(); }
27 | static void SetName(const std::string& name) { GetNameRef() = name; }
28 | static std::string& GetNameRef() {
29 | static std::string binary_name;
30 | return binary_name;
31 | }
32 | };
33 | } // namespace cyber
34 | } // namespace apollo
35 |
36 | #endif // CYBER_BINARY_H_
37 |
--------------------------------------------------------------------------------
/cyber/examples/common_component_example/common_component_example.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 | #include
17 |
18 | #include "cyber/component/component.h"
19 | #include "cyber/examples/proto/examples.pb.h"
20 |
21 | using apollo::cyber::Component;
22 | using apollo::cyber::ComponentBase;
23 | using apollo::cyber::examples::proto::Chatter;
24 |
25 | class CommonComponentSample : public Component {
26 | public:
27 | bool Init() override;
28 | bool Proc(const std::shared_ptr& msg1) override;
29 | };
30 | CYBER_REGISTER_COMPONENT(CommonComponentSample)
31 |
--------------------------------------------------------------------------------
/cyber/transport/dispatcher/dispatcher.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/transport/dispatcher/dispatcher.h"
18 |
19 | namespace apollo {
20 | namespace cyber {
21 | namespace transport {
22 |
23 | Dispatcher::Dispatcher() : is_shutdown_(false) {}
24 |
25 | Dispatcher::~Dispatcher() { Shutdown(); }
26 |
27 | void Dispatcher::Shutdown() {
28 | is_shutdown_.store(true);
29 | ADEBUG << "Shutdown";
30 | }
31 |
32 | bool Dispatcher::HasChannel(uint64_t channel_id) {
33 | return msg_listeners_.Has(channel_id);
34 | }
35 |
36 | } // namespace transport
37 | } // namespace cyber
38 | } // namespace apollo
39 |
--------------------------------------------------------------------------------
/cyber/base/for_each_test.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 | #include "cyber/base/for_each.h"
17 |
18 | #include
19 | #include
20 | #include "gtest/gtest.h"
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace base {
25 |
26 | TEST(ForEachTest, base) {
27 | std::vector vec;
28 | FOR_EACH(i, 0, 100) { vec.push_back(i); }
29 | EXPECT_EQ(100, vec.size());
30 |
31 | int index = 0;
32 | FOR_EACH(it, vec.begin(), vec.end()) { EXPECT_EQ(index++, *it); }
33 |
34 | FOR_EACH(i, 0, 'a') { EXPECT_GT('a', i); }
35 | }
36 |
37 | } // namespace base
38 | } // namespace cyber
39 | } // namespace apollo
40 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/test/test_init.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2018 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for test init."""
20 |
21 | import unittest
22 |
23 | from cyber_py import cyber
24 |
25 |
26 | class TestInit(unittest.TestCase):
27 |
28 | """
29 | Class for init unit test.
30 | """
31 |
32 | def test_init(self):
33 | """
34 | Test cyber.
35 | """
36 | self.assertTrue(cyber.init())
37 | self.assertTrue(cyber.ok())
38 | cyber.shutdown()
39 | self.assertTrue(cyber.is_shutdown())
40 |
41 | if __name__ == '__main__':
42 | unittest.main()
43 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/test/test_init.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for test init."""
20 |
21 | import unittest
22 |
23 | from cyber_py3 import cyber
24 |
25 |
26 | class TestInit(unittest.TestCase):
27 |
28 | """
29 | Class for init unit test.
30 | """
31 |
32 | def test_init(self):
33 | """
34 | Test cyber.
35 | """
36 | self.assertTrue(cyber.init())
37 | self.assertTrue(cyber.ok())
38 | cyber.shutdown()
39 | self.assertTrue(cyber.is_shutdown())
40 |
41 | if __name__ == '__main__':
42 | unittest.main()
43 |
--------------------------------------------------------------------------------
/cyber/scheduler/common/mutex_wrapper.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SCHEDULER_COMMON_MUTEX_WRAPPER_H_
18 | #define CYBER_SCHEDULER_COMMON_MUTEX_WRAPPER_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace scheduler {
25 |
26 | class MutexWrapper {
27 | public:
28 | MutexWrapper& operator=(const MutexWrapper& other) = delete;
29 | std::mutex& Mutex() { return mutex_; }
30 |
31 | private:
32 | mutable std::mutex mutex_;
33 | };
34 |
35 | } // namespace scheduler
36 | } // namespace cyber
37 | } // namespace apollo
38 |
39 | #endif // CYBER_SCHEDULER_COMMON_MUTEX_WRAPPER_H_
40 |
--------------------------------------------------------------------------------
/cyber/scheduler/common/cv_wrapper.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SCHEDULER_COMMON_CV_WRAPPER_H_
18 | #define CYBER_SCHEDULER_COMMON_CV_WRAPPER_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace scheduler {
25 |
26 | class CvWrapper {
27 | public:
28 | CvWrapper& operator=(const CvWrapper& other) = delete;
29 | std::condition_variable& Cv() { return cv_; }
30 |
31 | private:
32 | mutable std::condition_variable cv_;
33 | };
34 |
35 | } // namespace scheduler
36 | } // namespace cyber
37 | } // namespace apollo
38 |
39 | #endif // CYBER_SCHEDULER_COMMON_CV_WRAPPER_H_
40 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_monitor/renderable_message.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/tools/cyber_monitor/renderable_message.h"
18 |
19 | #include
20 |
21 | #include "cyber/tools/cyber_monitor/screen.h"
22 |
23 | void RenderableMessage::SplitPages(int key) {
24 | switch (key) {
25 | case CTRL('d'):
26 | case KEY_NPAGE:
27 | ++page_index_;
28 | if (page_index_ >= pages_) {
29 | page_index_ = pages_ - 1;
30 | }
31 | break;
32 |
33 | case CTRL('u'):
34 | case KEY_PPAGE:
35 | --page_index_;
36 | if (page_index_ < 1) {
37 | page_index_ = 0;
38 | }
39 | break;
40 | default: {}
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/cyber/transport/shm/notifier_factory.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_SHM_NOTIFIER_FACTORY_H_
18 | #define CYBER_TRANSPORT_SHM_NOTIFIER_FACTORY_H_
19 |
20 | #include
21 |
22 | #include "cyber/transport/shm/notifier_base.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace transport {
27 |
28 | class NotifierFactory {
29 | public:
30 | static NotifierPtr CreateNotifier();
31 |
32 | private:
33 | static NotifierPtr CreateConditionNotifier();
34 | static NotifierPtr CreateMulticastNotifier();
35 | };
36 |
37 | } // namespace transport
38 | } // namespace cyber
39 | } // namespace apollo
40 |
41 | #endif // CYBER_TRANSPORT_SHM_NOTIFIER_FACTORY_H_
42 |
--------------------------------------------------------------------------------
/cyber/cyber.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_CYBER_H_
18 | #define CYBER_CYBER_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/common/log.h"
25 | #include "cyber/component/component.h"
26 | #include "cyber/init.h"
27 | #include "cyber/node/node.h"
28 | #include "cyber/task/task.h"
29 | #include "cyber/time/time.h"
30 | #include "cyber/timer/timer.h"
31 |
32 | namespace apollo {
33 | namespace cyber {
34 |
35 | std::unique_ptr CreateNode(const std::string& node_name,
36 | const std::string& name_space = "");
37 |
38 | } // namespace cyber
39 | } // namespace apollo
40 |
41 | #endif // CYBER_CYBER_H_
42 |
--------------------------------------------------------------------------------
/cyber/component/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "component",
7 | hdrs = ["component.h"],
8 | deps = [
9 | ":component_base",
10 | "//cyber/scheduler",
11 | ],
12 | )
13 |
14 | cc_test(
15 | name = "component_test",
16 | size = "small",
17 | srcs = ["component_test.cc"],
18 | deps = [
19 | "//cyber",
20 | "@gtest",
21 | ],
22 | )
23 |
24 | cc_library(
25 | name = "timer_component",
26 | srcs = ["timer_component.cc"],
27 | hdrs = ["timer_component.h"],
28 | deps = [
29 | ":component_base",
30 | "//cyber/blocker:blocker_manager",
31 | "//cyber/timer",
32 | "//cyber/transport:history",
33 | "//cyber/transport:hybrid_transmitter",
34 | "//cyber/transport:intra_transmitter",
35 | "//cyber/transport:rtps_transmitter",
36 | "//cyber/transport:shm_transmitter",
37 | ],
38 | )
39 |
40 | cc_test(
41 | name = "timer_component_test",
42 | size = "small",
43 | srcs = ["timer_component_test.cc"],
44 | deps = [
45 | "//cyber",
46 | "@gtest//:main",
47 | ],
48 | )
49 |
50 | cc_library(
51 | name = "component_base",
52 | hdrs = ["component_base.h"],
53 | deps = [
54 | "//cyber/base:signal",
55 | "//cyber/base:thread_pool",
56 | "//cyber/class_loader",
57 | "//cyber/node",
58 | ],
59 | )
60 |
61 | cpplint()
62 |
--------------------------------------------------------------------------------
/cmake/external/glog-0.3.5.cmake:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(Glog VERSION "0.3.5")
3 |
4 | find_package(Glog QUIET)
5 |
6 | set(GLOG_SRC file:///${CMAKE_SOURCE_DIR}/tmp/glog-0.3.5.tar.gz )
7 |
8 | if(NOT Glog_FOUND)
9 | message(STATUS "Glog not found, going to build it")
10 | option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
11 |
12 | if(BUILD_SHARED_LIBS)
13 | list(APPEND extra_cmake_args -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
14 | endif()
15 |
16 | if(DEFINED CMAKE_BUILD_TYPE)
17 | list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
18 | endif()
19 |
20 | include(ExternalProject)
21 |
22 | externalproject_add(glog
23 | URL ${GLOG_SRC}
24 | #DOWNLOAD_DIR dl
25 | TIMEOUT 600
26 | PREFIX external
27 | UPDATE_COMMAND ""
28 | CMAKE_ARGS
29 | -DBUILD_SHARED_LIBS=ON
30 | -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/local_depends/
31 | ${extra_cmake_args}
32 | -Wno-dev
33 | )
34 |
35 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/local_depends/
36 | DESTINATION ${CMAKE_INSTALL_PREFIX})
37 | else()
38 | message(STATUS "Found Glog ${Glog_VERSION} ${Glog_INCLUDE_DIR}" )
39 | endif()
40 |
41 | include(CMakePackageConfigHelpers)
42 | write_basic_package_version_file(
43 | "${PROJECT_BINARY_DIR}/GlogConfig-version.cmake"
44 | COMPATIBILITY AnyNewerVersion)
45 |
46 | install(FILES
47 | #"${PROJECT_BINARY_DIR}/GlogConfig.cmake"
48 | "${PROJECT_BINARY_DIR}/GlogConfig-version.cmake"
49 | DESTINATION share/${PROJECT_NAME}/cmake)
50 |
--------------------------------------------------------------------------------
/cyber/scheduler/scheduler_factory.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SCHEDULER_SCHEDULER_FACTORY_H_
18 | #define CYBER_SCHEDULER_SCHEDULER_FACTORY_H_
19 |
20 | #include "cyber/common/environment.h"
21 | #include "cyber/common/file.h"
22 | #include "cyber/common/global_data.h"
23 | #include "cyber/common/util.h"
24 | #include "cyber/scheduler/policy/scheduler_choreography.h"
25 | #include "cyber/scheduler/policy/scheduler_classic.h"
26 | #include "cyber/scheduler/scheduler.h"
27 |
28 | namespace apollo {
29 | namespace cyber {
30 | namespace scheduler {
31 |
32 | Scheduler* Instance();
33 | void CleanUp();
34 |
35 | } // namespace scheduler
36 | } // namespace cyber
37 | } // namespace apollo
38 |
39 | #endif // CYBER_SCHEDULER_SCHEDULER_FACTORY_H_
40 |
--------------------------------------------------------------------------------
/cyber/time/rate.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TIME_RATE_H_
18 | #define CYBER_TIME_RATE_H_
19 |
20 | #include "cyber/time/duration.h"
21 | #include "cyber/time/time.h"
22 |
23 | namespace apollo {
24 | namespace cyber {
25 |
26 | class Rate {
27 | public:
28 | explicit Rate(double frequency);
29 | explicit Rate(uint64_t nanoseconds);
30 | explicit Rate(const Duration&);
31 | void Sleep();
32 | void Reset();
33 | Duration CycleTime() const;
34 | Duration ExpectedCycleTime() const { return expected_cycle_time_; }
35 |
36 | private:
37 | Time start_;
38 | Duration expected_cycle_time_;
39 | Duration actual_cycle_time_;
40 | };
41 |
42 | } // namespace cyber
43 | } // namespace apollo
44 |
45 | #endif // CYBER_TIME_RATE_H_
46 |
--------------------------------------------------------------------------------
/cyber/timer/timer_task.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TIMER_TIMER_TASK_H_
18 | #define CYBER_TIMER_TIMER_TASK_H_
19 |
20 | #include
21 | #include
22 |
23 | namespace apollo {
24 | namespace cyber {
25 |
26 | class TimerBucket;
27 |
28 | struct TimerTask {
29 | explicit TimerTask(uint64_t timer_id) : timer_id_(timer_id) {}
30 | uint64_t timer_id_ = 0;
31 | std::function callback;
32 | uint64_t interval_ms = 0;
33 | uint64_t remainder_interval_ms = 0;
34 | uint64_t next_fire_duration_ms = 0;
35 | int64_t accumulated_error_ns = 0;
36 | uint64_t last_execute_time_ns = 0;
37 | std::mutex mutex;
38 | };
39 |
40 | } // namespace cyber
41 | } // namespace apollo
42 |
43 | #endif // CYBER_TIMER_TIMER_TASK_H_
44 |
--------------------------------------------------------------------------------
/cyber/blocker/blocker_manager.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/blocker/blocker_manager.h"
18 |
19 | namespace apollo {
20 | namespace cyber {
21 | namespace blocker {
22 |
23 | BlockerManager::BlockerManager() {}
24 |
25 | BlockerManager::~BlockerManager() { blockers_.clear(); }
26 |
27 | void BlockerManager::Observe() {
28 | std::lock_guard lock(blocker_mutex_);
29 | for (auto& item : blockers_) {
30 | item.second->Observe();
31 | }
32 | }
33 |
34 | void BlockerManager::Reset() {
35 | std::lock_guard lock(blocker_mutex_);
36 | for (auto& item : blockers_) {
37 | item.second->Reset();
38 | }
39 | blockers_.clear();
40 | }
41 |
42 | } // namespace blocker
43 | } // namespace cyber
44 | } // namespace apollo
45 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_recorder/info.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TOOLS_CYBER_RECORDER_INFO_H_
18 | #define CYBER_TOOLS_CYBER_RECORDER_INFO_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/common/time_conversion.h"
25 | #include "cyber/proto/record.pb.h"
26 | #include "cyber/record/file/record_file_reader.h"
27 |
28 | using ::apollo::cyber::common::UnixSecondsToString;
29 |
30 | namespace apollo {
31 | namespace cyber {
32 | namespace record {
33 |
34 | class Info {
35 | public:
36 | Info();
37 | ~Info();
38 | bool Display(const std::string& file);
39 | };
40 |
41 | } // namespace record
42 | } // namespace cyber
43 | } // namespace apollo
44 |
45 | #endif // CYBER_TOOLS_CYBER_RECORDER_INFO_H_
46 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/timer_component_example.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/examples/timer_component_example/timer_component_example.h"
18 |
19 | #include "cyber/class_loader/class_loader.h"
20 | #include "cyber/component/component.h"
21 | #include "cyber/examples/proto/examples.pb.h"
22 |
23 | bool TimerComponentSample::Init() {
24 | chatter_writer_ = node_->CreateWriter("channel/chatter");
25 | return true;
26 | }
27 |
28 | bool TimerComponentSample::Proc() {
29 | static int i = 0;
30 | auto out_msg = std::make_shared();
31 | out_msg->set_seq(i++);
32 | chatter_writer_->Write(out_msg);
33 | AINFO << "timer_component_example: Write drivermsg->"
34 | << out_msg->ShortDebugString();
35 | return true;
36 | }
37 |
--------------------------------------------------------------------------------
/cyber/examples/timer_component_example/timer_component_example.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 | #include
17 |
18 | #include "cyber/class_loader/class_loader.h"
19 | #include "cyber/component/component.h"
20 | #include "cyber/component/timer_component.h"
21 | #include "cyber/examples/proto/examples.pb.h"
22 |
23 | using apollo::cyber::Component;
24 | using apollo::cyber::ComponentBase;
25 | using apollo::cyber::TimerComponent;
26 | using apollo::cyber::Writer;
27 | using apollo::cyber::examples::proto::Chatter;
28 |
29 | class TimerComponentSample : public TimerComponent {
30 | public:
31 | bool Init() override;
32 | bool Proc() override;
33 |
34 | private:
35 | std::shared_ptr> chatter_writer_ = nullptr;
36 | };
37 | CYBER_REGISTER_COMPONENT(TimerComponentSample)
38 |
--------------------------------------------------------------------------------
/cyber/sysmo/sysmo_test.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/sysmo/sysmo.h"
18 |
19 | #include
20 | #include
21 | #include "gtest/gtest.h"
22 |
23 | #include "cyber/common/environment.h"
24 | #include "cyber/scheduler/scheduler_factory.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 |
29 | using apollo::cyber::common::GetEnv;
30 |
31 | TEST(SysMoTest, cases) {
32 | auto sched = scheduler::Instance();
33 | setenv("sysmo_start", "1", 1);
34 | auto sysmo_start = GetEnv("sysmo_start");
35 | EXPECT_EQ(sysmo_start, "1");
36 | auto sysmo = SysMo::Instance();
37 | std::this_thread::sleep_for(std::chrono::milliseconds(300));
38 | sysmo->Shutdown();
39 | sched->Shutdown();
40 | }
41 |
42 | } // namespace cyber
43 | } // namespace apollo
44 |
--------------------------------------------------------------------------------
/cyber/transport/common/endpoint.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/transport/common/endpoint.h"
18 | #include "cyber/common/global_data.h"
19 |
20 | namespace apollo {
21 | namespace cyber {
22 | namespace transport {
23 |
24 | Endpoint::Endpoint(const RoleAttributes& attr)
25 | : enabled_(false), id_(), attr_(attr) {
26 | if (!attr_.has_host_name()) {
27 | attr_.set_host_name(common::GlobalData::Instance()->HostName());
28 | }
29 |
30 | if (!attr_.has_process_id()) {
31 | attr_.set_process_id(common::GlobalData::Instance()->ProcessId());
32 | }
33 |
34 | if (!attr_.has_id()) {
35 | attr_.set_id(id_.HashValue());
36 | }
37 | }
38 |
39 | Endpoint::~Endpoint() {}
40 |
41 | } // namespace transport
42 | } // namespace cyber
43 | } // namespace apollo
44 |
--------------------------------------------------------------------------------
/cyber/transport/shm/notifier_base.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_SHM_NOTIFIER_BASE_H_
18 | #define CYBER_TRANSPORT_SHM_NOTIFIER_BASE_H_
19 |
20 | #include
21 |
22 | #include "cyber/transport/shm/readable_info.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace transport {
27 |
28 | class NotifierBase;
29 | using NotifierPtr = NotifierBase*;
30 |
31 | class NotifierBase {
32 | public:
33 | virtual ~NotifierBase() = default;
34 |
35 | virtual void Shutdown() = 0;
36 | virtual bool Notify(const ReadableInfo& info) = 0;
37 | virtual bool Listen(int timeout_ms, ReadableInfo* info) = 0;
38 | };
39 |
40 | } // namespace transport
41 | } // namespace cyber
42 | } // namespace apollo
43 |
44 | #endif // CYBER_TRANSPORT_SHM_NOTIFIER_BASE_H_
45 |
--------------------------------------------------------------------------------
/cyber/examples/listener.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/cyber.h"
18 | #include "cyber/examples/proto/examples.pb.h"
19 |
20 | void MessageCallback(
21 | const std::shared_ptr& msg) {
22 | AINFO << "Received message seq-> " << msg->seq();
23 | AINFO << "msgcontent->" << msg->content();
24 | }
25 |
26 | int main(int argc, char* argv[]) {
27 | // init cyber framework
28 | apollo::cyber::Init(argv[0]);
29 | // create listener node
30 | auto listener_node = apollo::cyber::CreateNode("listener");
31 | // create listener
32 | auto listener =
33 | listener_node->CreateReader(
34 | "channel/chatter", MessageCallback);
35 | apollo::cyber::WaitForShutdown();
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/cyber/transport/shm/xsi_segment.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_SHM_XSI_SEGMENT_H_
18 | #define CYBER_TRANSPORT_SHM_XSI_SEGMENT_H_
19 |
20 | #include "cyber/transport/shm/segment.h"
21 |
22 | namespace apollo {
23 | namespace cyber {
24 | namespace transport {
25 |
26 | class XsiSegment : public Segment {
27 | public:
28 | explicit XsiSegment(uint64_t channel_id);
29 | virtual ~XsiSegment();
30 |
31 | static const char* Type() { return "xsi"; }
32 |
33 | private:
34 | void Reset() override;
35 | bool Remove() override;
36 | bool OpenOnly() override;
37 | bool OpenOrCreate() override;
38 |
39 | key_t key_;
40 | };
41 |
42 | } // namespace transport
43 | } // namespace cyber
44 | } // namespace apollo
45 |
46 | #endif // CYBER_TRANSPORT_SHM_XSI_SEGMENT_H_
47 |
--------------------------------------------------------------------------------
/cyber/io/poll_data.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_IO_POLL_DATA_H_
18 | #define CYBER_IO_POLL_DATA_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace io {
27 |
28 | struct PollResponse {
29 | explicit PollResponse(uint32_t e = 0) : events(e) {}
30 |
31 | uint32_t events;
32 | };
33 |
34 | struct PollRequest {
35 | int fd = -1;
36 | uint32_t events = 0;
37 | int timeout_ms = -1;
38 | std::function callback = nullptr;
39 | };
40 |
41 | struct PollCtrlParam {
42 | int operation;
43 | int fd;
44 | epoll_event event;
45 | };
46 |
47 | } // namespace io
48 | } // namespace cyber
49 | } // namespace apollo
50 |
51 | #endif // CYBER_IO_POLL_DATA_H_
52 |
--------------------------------------------------------------------------------
/cyber/logger/logger.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_LOGGER_LOGGER_H_
18 | #define CYBER_LOGGER_LOGGER_H_
19 |
20 | #include
21 |
22 | #include "glog/logging.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace logger {
27 |
28 | class Logger : public google::base::Logger {
29 | public:
30 | explicit Logger(google::base::Logger* wrapped);
31 | ~Logger();
32 | void Write(bool force_flush, time_t timestamp, const char* message,
33 | int message_len) override;
34 | void Flush() override;
35 | uint32_t LogSize() override;
36 |
37 | private:
38 | google::base::Logger* const wrapped_;
39 | std::mutex mutex_;
40 | };
41 |
42 | } // namespace logger
43 | } // namespace cyber
44 | } // namespace apollo
45 |
46 | #endif // CYBER_LOGGER_LOGGER_H_
47 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/py_listener.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/cyber.h"
18 | #include "cyber/proto/unit_test.pb.h"
19 | #include "cyber/py_wrapper/py_cyber.h"
20 |
21 | apollo::cyber::PyReader *pr = nullptr;
22 |
23 | int cbfun(const char *channel_name) {
24 | AINFO << "recv->[ " << channel_name << " ]";
25 | if (pr) {
26 | AINFO << "read->[ " << pr->read() << " ]";
27 | }
28 | return 1;
29 | }
30 |
31 | int main(int argc, char *argv[]) {
32 | apollo::cyber::Init("cyber_python");
33 | apollo::cyber::proto::Chatter chat;
34 | apollo::cyber::PyNode node("listener");
35 | pr = node.create_reader("channel/chatter", chat.GetTypeName());
36 | pr->register_func(cbfun);
37 |
38 | apollo::cyber::WaitForShutdown();
39 | delete pr;
40 |
41 | return 0;
42 | }
43 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/timer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 |
19 | """Module for example of timer."""
20 |
21 | import time
22 |
23 | from cyber_py import cyber
24 | from cyber_py import cyber_timer
25 |
26 |
27 | count = 0
28 |
29 |
30 | def fun():
31 | global count
32 | print("cb fun is called:", count)
33 | count += 1
34 |
35 |
36 | def test_timer():
37 | cyber.init()
38 | ct = cyber_timer.Timer(10, fun, 0) # 10ms
39 | ct.start()
40 | time.sleep(1) # 1s
41 | ct.stop()
42 |
43 | print("+" * 80, "test set_option")
44 | ct2 = cyber_timer.Timer() # 10ms
45 | ct2.set_option(10, fun, 0)
46 | ct2.start()
47 | time.sleep(1) # 1s
48 | ct2.stop()
49 |
50 | cyber.shutdown()
51 |
52 | if __name__ == '__main__':
53 | test_timer()
54 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/examples/timer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 |
19 | """Module for example of timer."""
20 |
21 | import time
22 |
23 | from cyber_py3 import cyber
24 | from cyber_py3 import cyber_timer
25 |
26 |
27 | count = 0
28 |
29 |
30 | def fun():
31 | global count
32 | print("cb fun is called:", count)
33 | count += 1
34 |
35 |
36 | def test_timer():
37 | cyber.init()
38 | ct = cyber_timer.Timer(10, fun, 0) # 10ms
39 | ct.start()
40 | time.sleep(1) # 1s
41 | ct.stop()
42 |
43 | print("+" * 80, "test set_option")
44 | ct2 = cyber_timer.Timer() # 10ms
45 | ct2.set_option(10, fun, 0)
46 | ct2.start()
47 | time.sleep(1) # 1s
48 | ct2.stop()
49 |
50 | cyber.shutdown()
51 |
52 | if __name__ == '__main__':
53 | test_timer()
54 |
--------------------------------------------------------------------------------
/cyber/logger/logger_util.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/logger/logger_util.h"
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include "glog/logging.h"
30 |
31 | namespace apollo {
32 | namespace cyber {
33 | namespace logger {
34 |
35 | static int32_t g_main_thread_pid = getpid();
36 |
37 | int32_t GetMainThreadPid() { return g_main_thread_pid; }
38 |
39 | bool PidHasChanged() {
40 | int32_t pid = getpid();
41 | if (g_main_thread_pid == pid) {
42 | return false;
43 | }
44 | g_main_thread_pid = pid;
45 | return true;
46 | }
47 |
48 | } // namespace logger
49 | } // namespace cyber
50 | } // namespace apollo
51 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/service.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of listener."""
20 |
21 | from cyber_py import cyber
22 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
23 |
24 |
25 | def callback(data):
26 | print("-" * 80)
27 | print("get Request [ ", data, " ]")
28 | return ChatterBenchmark(content="svr: Hello client!", seq=data.seq + 2)
29 |
30 |
31 | def test_service_class():
32 | """
33 | Reader message.
34 | """
35 | print("=" * 120)
36 | node = cyber.Node("service_node")
37 | r = node.create_service(
38 | "server_01", ChatterBenchmark, ChatterBenchmark, callback)
39 | node.spin()
40 |
41 | if __name__ == '__main__':
42 | cyber.init()
43 | test_service_class()
44 | cyber.shutdown()
45 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/examples/service.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of listener."""
20 |
21 | from cyber_py3 import cyber
22 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
23 |
24 |
25 | def callback(data):
26 | print("-" * 80)
27 | print("get Request [ ", data, " ]")
28 | return ChatterBenchmark(content="svr: Hello client!", seq=data.seq + 2)
29 |
30 |
31 | def test_service_class():
32 | """
33 | Reader message.
34 | """
35 | print("=" * 120)
36 | node = cyber.Node("service_node")
37 | r = node.create_service(
38 | "server_01", ChatterBenchmark, ChatterBenchmark, callback)
39 | node.spin()
40 |
41 | if __name__ == '__main__':
42 | cyber.init()
43 | test_service_class()
44 | cyber.shutdown()
45 |
--------------------------------------------------------------------------------
/cyber/scheduler/processor_context.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SCHEDULER_POLICY_PROCESSOR_CONTEXT_H_
18 | #define CYBER_SCHEDULER_POLICY_PROCESSOR_CONTEXT_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/base/macros.h"
25 | #include "cyber/croutine/croutine.h"
26 |
27 | namespace apollo {
28 | namespace cyber {
29 | namespace scheduler {
30 |
31 | using croutine::CRoutine;
32 |
33 | class ProcessorContext {
34 | public:
35 | virtual void Shutdown();
36 | virtual std::shared_ptr NextRoutine() = 0;
37 | virtual void Wait() = 0;
38 |
39 | protected:
40 | std::atomic stop_{false};
41 | };
42 |
43 | } // namespace scheduler
44 | } // namespace cyber
45 | } // namespace apollo
46 |
47 | #endif // CYBER_SCHEDULER_PROCESSOR_CONTEXT_H_
48 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/listener.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2018 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of listener."""
20 |
21 | from cyber_py import cyber
22 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
23 |
24 |
25 | def callback(data):
26 | """
27 | Reader message callback.
28 | """
29 | print("=" * 80)
30 | print("py:reader callback msg->:")
31 | print(data)
32 | print("=" * 80)
33 |
34 |
35 | def test_listener_class():
36 | """
37 | Reader message.
38 | """
39 | print("=" * 120)
40 | test_node = cyber.Node("listener")
41 | test_node.create_reader("channel/chatter", ChatterBenchmark, callback)
42 | test_node.spin()
43 |
44 | if __name__ == '__main__':
45 | cyber.init()
46 | test_listener_class()
47 | cyber.shutdown()
48 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/examples/listener.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of listener."""
20 |
21 | from cyber_py3 import cyber
22 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
23 |
24 |
25 | def callback(data):
26 | """
27 | Reader message callback.
28 | """
29 | print("=" * 80)
30 | print("py:reader callback msg->:")
31 | print(data)
32 | print("=" * 80)
33 |
34 |
35 | def test_listener_class():
36 | """
37 | Reader message.
38 | """
39 | print("=" * 120)
40 | test_node = cyber.Node("listener")
41 | test_node.create_reader("channel/chatter", ChatterBenchmark, callback)
42 | test_node.spin()
43 |
44 | if __name__ == '__main__':
45 | cyber.init()
46 | test_listener_class()
47 | cyber.shutdown()
48 |
--------------------------------------------------------------------------------
/scripts/genprotosrc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | export LD_LIBRARY_PATH=build/local_depends/lib/
4 |
5 | #c++ protobuf
6 | for i in `ls cyber/proto/*.proto`
7 | do
8 | build/local_depends/bin/protoc -I. -Icyber/proto --cpp_out=. $i
9 | done
10 |
11 | for i in `ls cyber/examples/proto/*.proto`
12 | do
13 | build/local_depends/bin/protoc -I. -Icyber/proto --cpp_out=. $i
14 | done
15 |
16 | #python protobuf
17 | for i in `ls cyber/proto/*.proto`
18 | do
19 | build/local_depends/bin/protoc -I. -Icyber/proto --python_out=. $i
20 | done
21 |
22 | for i in `ls cyber/examples/proto/*.proto`
23 | do
24 | build/local_depends/bin/protoc -I. -Icyber/proto --python_out=. $i
25 | done
26 |
27 | if [ ! -d "./py_proto" ]; then
28 | echo "py_proto directory does not exist, then create it"
29 | mkdir -p py_proto/cyber/proto
30 | mkdir -p py_proto/cyber/example/proto
31 | touch py_proto/cyber/__init__.py
32 | touch py_proto/cyber/proto/__init__.py
33 | touch py_proto/cyber/example/__init__.py
34 | touch py_proto/cyber/example/proto/__init__.py
35 | mkdir log
36 | else
37 | echo "py_proto directory exist, delete and create it"
38 | rm -rf py_proto
39 | mkdir -p py_proto/cyber/proto
40 | mkdir -p py_proto/cyber/example/proto
41 | touch py_proto/cyber/__init__.py
42 | touch py_proto/cyber/proto/__init__.py
43 | touch py_proto/cyber/example/__init__.py
44 | touch py_proto/cyber/example/proto/__init__.py
45 | mkdir log
46 | fi
47 |
48 | #move protobuf file to destination path
49 | mv `find ./cyber/proto -name "*pb2.py"` ./py_proto/cyber/proto
50 | mv `find ./cyber/examples/proto -name "*pb2.py"` ./py_proto/cyber/example/proto
51 |
--------------------------------------------------------------------------------
/cyber/timer/timer_bucket.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TIMER_TIMER_BUCKET_H_
18 | #define CYBER_TIMER_TIMER_BUCKET_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/timer/timer_task.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 |
29 | class TimerBucket {
30 | public:
31 | void AddTask(const std::shared_ptr& task) {
32 | std::lock_guard lock(mutex_);
33 | task_list_.push_back(task);
34 | }
35 |
36 | std::mutex& mutex() { return mutex_; }
37 | std::list>& task_list() { return task_list_; }
38 |
39 | private:
40 | std::mutex mutex_;
41 | std::list> task_list_;
42 | };
43 |
44 | } // namespace cyber
45 | } // namespace apollo
46 |
47 | #endif // CYBER_TIMER_TIMER_BUCKET_H_
48 |
--------------------------------------------------------------------------------
/cyber/base/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberBase)
4 |
5 | add_library(cyber_signal INTERFACE)
6 | #target_sources(cyber_signal INTERFACE signal.h)
7 | target_include_directories(cyber_signal INTERFACE
8 | "${PROJECT_SOURCE_DIR}"
9 | )
10 | add_library(Cyber::signal ALIAS cyber_signal)
11 |
12 | #add_executable(signal_test signal_test.cc)
13 | #target_link_libraries(signal_test Cyber::signal)
14 |
15 | add_library(cyber_atomic_fifo INTERFACE)
16 | #target_sources(cyber_signal INTERFACE signal.h)
17 | target_include_directories(cyber_atomic_fifo INTERFACE
18 | "${PROJECT_SOURCE_DIR}"
19 | )
20 |
21 | add_library(Cyber::atomic_fifo ALIAS cyber_atomic_fifo)
22 |
23 | add_library(cyber_base INTERFACE)
24 | target_include_directories(cyber_base INTERFACE
25 | "${PROJECT_SOURCE_DIR}"
26 | )
27 | add_library(Cyber::base ALIAS cyber_base)
28 |
29 | add_library(cyber_atomic_hash_map INTERFACE)
30 | add_library(cyber_atomic_rw_lock INTERFACE)
31 | add_library(cyber_bounded_queue INTERFACE)
32 | add_library(cyber_concurrent_object_pool INTERFACE)
33 | add_library(cyber_for_each INTERFACE)
34 | add_library(cyber_object_pool INTERFACE)
35 | add_library(cyber_reentrant_rw_lock INTERFACE)
36 | add_library(cyber_rw_lock_guard INTERFACE)
37 | add_library(cyber_unbounded_queue INTERFACE)
38 | add_library(cyber_thread_safe_queue INTERFACE)
39 | add_library(cyber_macros INTERFACE)
40 | add_library(cyber_thread_pool INTERFACE)
41 | add_library(cyber_wait_strategy INTERFACE)
42 |
43 | file(GLOB HEADERS *.h)
44 |
45 | install(FILES ${HEADERS}
46 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/base/
47 | )
48 |
--------------------------------------------------------------------------------
/cyber/transport/shm/posix_segment.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_SHM_POSIX_SEGMENT_H_
18 | #define CYBER_TRANSPORT_SHM_POSIX_SEGMENT_H_
19 |
20 | #include
21 |
22 | #include "cyber/transport/shm/segment.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace transport {
27 |
28 | class PosixSegment : public Segment {
29 | public:
30 | explicit PosixSegment(uint64_t channel_id);
31 | virtual ~PosixSegment();
32 |
33 | static const char* Type() { return "posix"; }
34 |
35 | private:
36 | void Reset() override;
37 | bool Remove() override;
38 | bool OpenOnly() override;
39 | bool OpenOrCreate() override;
40 |
41 | std::string shm_name_;
42 | };
43 |
44 | } // namespace transport
45 | } // namespace cyber
46 | } // namespace apollo
47 |
48 | #endif // CYBER_TRANSPORT_SHM_POSIX_SEGMENT_H_
49 |
--------------------------------------------------------------------------------
/cyber/conf/example_sched_choreography.conf:
--------------------------------------------------------------------------------
1 | scheduler_conf {
2 | policy: "choreography"
3 | process_level_cpuset: "0-7,16-23" # all threads in the process are on the cpuset
4 | threads: [
5 | {
6 | name: "lidar"
7 | cpuset: "1"
8 | policy: "SCHED_RR" # policy: SCHED_OTHER,SCHED_RR,SCHED_FIFO
9 | prio: 10
10 | }, {
11 | name: "shm"
12 | cpuset: "2"
13 | policy: "SCHED_FIFO"
14 | prio: 10
15 | }
16 | ]
17 | choreography_conf {
18 | choreography_processor_num: 8
19 | choreography_affinity: "range"
20 | choreography_cpuset: "0-7"
21 | choreography_processor_policy: "SCHED_FIFO" # policy: SCHED_OTHER,SCHED_RR,SCHED_FIFO
22 | choreography_processor_prio: 10
23 |
24 | pool_processor_num: 8
25 | pool_affinity: "range"
26 | pool_cpuset: "16-23"
27 | pool_processor_policy: "SCHED_OTHER"
28 | pool_processor_prio: 0
29 |
30 | tasks: [
31 | {
32 | name: "A"
33 | processor: 0
34 | prio: 1
35 | },
36 | {
37 | name: "B"
38 | processor: 0
39 | prio: 2
40 | },
41 | {
42 | name: "C"
43 | processor: 1
44 | prio: 1
45 | },
46 | {
47 | name: "D"
48 | processor: 1
49 | prio: 2
50 | },
51 | {
52 | name: "E"
53 | }
54 | ]
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/cyber/logger/log_file_object_test.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/logger/log_file_object.h"
18 |
19 | #include
20 |
21 | #include "glog/logging.h"
22 | #include "gtest/gtest.h"
23 |
24 | #include "cyber/cyber.h"
25 | #include "cyber/time/time.h"
26 |
27 | namespace apollo {
28 | namespace cyber {
29 | namespace logger {
30 |
31 | TEST(LogFileObjectTest, init_and_write) {
32 | std::string basename = "logfile";
33 | LogFileObject logfileobject(google::INFO, basename.c_str());
34 | logfileobject.SetBasename("base");
35 | time_t timep;
36 | time(&timep);
37 | std::string message = "cyber logger test";
38 | logfileobject.Write(false, timep, message.c_str(), 20);
39 | logfileobject.SetExtension("unittest");
40 | logfileobject.Flush();
41 | }
42 |
43 | } // namespace logger
44 | } // namespace cyber
45 | } // namespace apollo
46 |
--------------------------------------------------------------------------------
/cyber/scheduler/common/pin_thread.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SCHEDULER_COMMON_PIN_THREAD_H_
18 | #define CYBER_SCHEDULER_COMMON_PIN_THREAD_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/common/log.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 | namespace scheduler {
29 |
30 | void ParseCpuset(const std::string& str, std::vector* cpuset);
31 |
32 | void SetSchedAffinity(std::thread* thread, const std::vector& cpus,
33 | const std::string& affinity, int cpu_id = -1);
34 |
35 | void SetSchedPolicy(std::thread* thread, std::string spolicy,
36 | int sched_priority, pid_t tid = -1);
37 |
38 | } // namespace scheduler
39 | } // namespace cyber
40 | } // namespace apollo
41 |
42 | #endif // CYBER_SCHEDULER_COMMON_PIN_THREAD_H_
43 |
--------------------------------------------------------------------------------
/cyber/common/types.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_COMMON_TYPES_H_
18 | #define CYBER_COMMON_TYPES_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 |
25 | class NullType {};
26 |
27 | // Return code definition for cyber internal function return.
28 | enum ReturnCode {
29 | SUCC = 0,
30 | FAIL = 1,
31 | };
32 |
33 | /**
34 | * @brief Describe relation between nodes, writers/readers...
35 | */
36 | enum Relation : std::uint8_t {
37 | NO_RELATION = 0,
38 | DIFF_HOST, // different host
39 | DIFF_PROC, // same host, but different process
40 | SAME_PROC, // same process
41 | };
42 |
43 | static const char SRV_CHANNEL_REQ_SUFFIX[] = "__SRV__REQUEST";
44 | static const char SRV_CHANNEL_RES_SUFFIX[] = "__SRV__RESPONSE";
45 |
46 | } // namespace cyber
47 | } // namespace apollo
48 |
49 | #endif // CYBER_COMMON_TYPES_H_
50 |
--------------------------------------------------------------------------------
/cyber/sysmo/sysmo.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SYSMO_SYSMO_H_
18 | #define CYBER_SYSMO_SYSMO_H_
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #include "cyber/scheduler/scheduler_factory.h"
28 |
29 | namespace apollo {
30 | namespace cyber {
31 |
32 | using apollo::cyber::scheduler::Scheduler;
33 |
34 | class SysMo {
35 | public:
36 | void Start();
37 | void Shutdown();
38 |
39 | private:
40 | void Checker();
41 |
42 | std::atomic shut_down_{false};
43 | bool start_ = false;
44 |
45 | int sysmo_interval_ms_ = 100;
46 | std::condition_variable cv_;
47 | std::mutex lk_;
48 | std::thread sysmo_;
49 |
50 | DECLARE_SINGLETON(SysMo);
51 | };
52 |
53 | } // namespace cyber
54 | } // namespace apollo
55 |
56 | #endif // CYBER_SYSMO_SYSMO_H_
57 |
--------------------------------------------------------------------------------
/cyber/record/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(CyberRecord)
4 |
5 | add_library(cyber_record_file_base file/record_file_base.cc)
6 | add_library(cyber_record_file_reader file/record_file_reader.cc)
7 | add_library(cyber_record_file_writer file/record_file_writer.cc)
8 | add_library(cyber_header_builder header_builder.cc)
9 |
10 | add_library(cyber_record_reader record_reader.cc)
11 | target_link_libraries(cyber_record_reader
12 | cyber_record_file_reader
13 | cyber_record_file_base)
14 |
15 | add_library(cyber_record_writer record_writer.cc)
16 | target_link_libraries(cyber_record_writer
17 | cyber_header_builder
18 | cyber_record_file_writer
19 | cyber_record_file_base)
20 |
21 | add_library(cyber_record_viewer record_viewer.cc)
22 |
23 | add_library(Cyber::record_reader ALIAS cyber_record_reader)
24 | add_library(Cyber::record_writer ALIAS cyber_record_writer)
25 | add_library(Cyber::record_viewer ALIAS cyber_record_viewer)
26 |
27 | add_library(Cyber::record_header_builder ALIAS cyber_header_builder)
28 | add_library(Cyber::record_file_base ALIAS cyber_record_file_base)
29 | add_library(Cyber::record_file_reader ALIAS cyber_record_file_reader)
30 | add_library(Cyber::record_file_writer ALIAS cyber_record_file_writer)
31 |
32 | file(GLOB HEADERS *.h)
33 |
34 | install(FILES ${HEADERS}
35 | DESTINATION ${CYBER_INSTALL_INCLUDE_DIR}/cyber/record/
36 | )
37 |
38 | install(TARGETS cyber_record_reader
39 | cyber_record_writer
40 | cyber_record_viewer
41 | cyber_record_file_base
42 | cyber_record_file_reader
43 | cyber_record_file_writer
44 | cyber_header_builder
45 | DESTINATION ${CYBER_INSTALL_LIB_DIR}
46 | )
47 |
--------------------------------------------------------------------------------
/cyber/cyber.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/cyber.h"
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include "cyber/common/global_data.h"
24 | #include "cyber/proto/run_mode_conf.pb.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 |
29 | using apollo::cyber::common::GlobalData;
30 | using apollo::cyber::proto::RunMode;
31 |
32 | std::unique_ptr CreateNode(const std::string& node_name,
33 | const std::string& name_space) {
34 | bool is_reality_mode = GlobalData::Instance()->IsRealityMode();
35 | if (is_reality_mode && !OK()) {
36 | // add some hint log
37 | AERROR << "please initialize cyber firstly.";
38 | return nullptr;
39 | }
40 | std::unique_ptr node(new Node(node_name, name_space));
41 | return std::move(node);
42 | }
43 |
44 | } // namespace cyber
45 | } // namespace apollo
46 |
--------------------------------------------------------------------------------
/cyber/parameter/parameter_service_names.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_PARAMETER_PARAMETER_SERVICE_NAMES_H_
18 | #define CYBER_PARAMETER_PARAMETER_SERVICE_NAMES_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 |
25 | constexpr auto SERVICE_NAME_DELIMITER = "/";
26 | constexpr auto GET_PARAMETER_SERVICE_NAME = "get_parameter";
27 | constexpr auto SET_PARAMETER_SERVICE_NAME = "set_parameter";
28 | constexpr auto LIST_PARAMETERS_SERVICE_NAME = "list_parameters";
29 |
30 | static inline std::string FixParameterServiceName(const std::string& node_name,
31 | const char* service_name) {
32 | return node_name + std::string(SERVICE_NAME_DELIMITER) +
33 | std::string(service_name);
34 | }
35 |
36 | } // namespace cyber
37 | } // namespace apollo
38 |
39 | #endif // CYBER_PARAMETER_PARAMETER_SERVICE_NAMES_H_
40 |
--------------------------------------------------------------------------------
/cyber/class_loader/test/plugin2.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include
18 | #include "cyber/class_loader/class_loader.h"
19 | #include "cyber/class_loader/test/base.h"
20 |
21 | class Apple : public Base {
22 | public:
23 | virtual void DoSomething() { std::cout << "I am Apple" << std::endl; }
24 | };
25 |
26 | class Pear : public Base {
27 | public:
28 | virtual void DoSomething() { std::cout << "I am Pear!!!" << std::endl; }
29 | };
30 |
31 | class Banana : public Base {
32 | public:
33 | virtual void DoSomething() { std::cout << "I am Banana" << std::endl; }
34 | };
35 |
36 | class Peach : public Base {
37 | public:
38 | virtual void DoSomething() { std::cout << "I am Peach!!!" << std::endl; }
39 | };
40 |
41 | CLASS_LOADER_REGISTER_CLASS(Apple, Base);
42 | CLASS_LOADER_REGISTER_CLASS(Pear, Base);
43 | CLASS_LOADER_REGISTER_CLASS(Banana, Base);
44 | CLASS_LOADER_REGISTER_CLASS(Peach, Base);
45 |
--------------------------------------------------------------------------------
/cyber/node/node.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/node/node.h"
18 | #include "cyber/common/global_data.h"
19 | #include "cyber/time/time.h"
20 |
21 | namespace apollo {
22 | namespace cyber {
23 |
24 | using proto::RoleType;
25 |
26 | Node::Node(const std::string& node_name, const std::string& name_space)
27 | : node_name_(node_name), name_space_(name_space) {
28 | node_channel_impl_.reset(new NodeChannelImpl(node_name));
29 | node_service_impl_.reset(new NodeServiceImpl(node_name));
30 | }
31 |
32 | Node::~Node() {}
33 |
34 | const std::string& Node::Name() const { return node_name_; }
35 |
36 | void Node::Observe() {
37 | for (auto& reader : readers_) {
38 | reader.second->Observe();
39 | }
40 | }
41 |
42 | void Node::ClearData() {
43 | for (auto& reader : readers_) {
44 | reader.second->ClearData();
45 | }
46 | }
47 |
48 | } // namespace cyber
49 | } // namespace apollo
50 |
--------------------------------------------------------------------------------
/cyber/message/raw_message_traits.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_MESSAGE_RAW_MESSAGE_TRAITS_H_
18 | #define CYBER_MESSAGE_RAW_MESSAGE_TRAITS_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/message/raw_message.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 | namespace message {
29 |
30 | // Template specialization for RawMessage
31 | inline bool SerializeToArray(const RawMessage& message, void* data, int size) {
32 | return message.SerializeToArray(data, size);
33 | }
34 |
35 | inline bool ParseFromArray(const void* data, int size, RawMessage* message) {
36 | return message->ParseFromArray(data, size);
37 | }
38 |
39 | inline int ByteSize(const RawMessage& message) { return message.ByteSize(); }
40 |
41 | } // namespace message
42 | } // namespace cyber
43 | } // namespace apollo
44 |
45 | #endif // CYBER_MESSAGE_RAW_MESSAGE_TRAITS_H_
46 |
--------------------------------------------------------------------------------
/cyber/service_discovery/communication/participant_listener.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/service_discovery/communication/participant_listener.h"
18 |
19 | #include "cyber/common/log.h"
20 |
21 | namespace apollo {
22 | namespace cyber {
23 | namespace service_discovery {
24 |
25 | ParticipantListener::ParticipantListener(const ChangeFunc& callback)
26 | : callback_(callback) {}
27 |
28 | ParticipantListener::~ParticipantListener() {
29 | std::lock_guard lck(mutex_);
30 | callback_ = nullptr;
31 | }
32 |
33 | void ParticipantListener::onParticipantDiscovery(
34 | eprosima::fastrtps::Participant* p,
35 | eprosima::fastrtps::ParticipantDiscoveryInfo info) {
36 | RETURN_IF_NULL(callback_);
37 | (void)p;
38 | std::lock_guard lock(mutex_);
39 | callback_(info);
40 | }
41 |
42 | } // namespace service_discovery
43 | } // namespace cyber
44 | } // namespace apollo
45 |
--------------------------------------------------------------------------------
/cyber/class_loader/test/plugin1.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include
18 | #include "cyber/class_loader/class_loader.h"
19 | #include "cyber/class_loader/test/base.h"
20 |
21 | class Circle : public Base {
22 | public:
23 | virtual void DoSomething() { std::cout << "I am Circle" << std::endl; }
24 | };
25 |
26 | class Rect : public Base {
27 | public:
28 | virtual void DoSomething() { std::cout << "I am Rect" << std::endl; }
29 | ~Rect() {}
30 | };
31 |
32 | class Triangle : public Base {
33 | public:
34 | virtual void DoSomething() { std::cout << "I am Triangle" << std::endl; }
35 | };
36 |
37 | class Star : public Base {
38 | public:
39 | virtual void DoSomething() { std::cout << "I am Star" << std::endl; }
40 | };
41 |
42 | CLASS_LOADER_REGISTER_CLASS(Circle, Base);
43 | CLASS_LOADER_REGISTER_CLASS(Rect, Base);
44 | CLASS_LOADER_REGISTER_CLASS(Triangle, Base);
45 | CLASS_LOADER_REGISTER_CLASS(Star, Base);
46 |
--------------------------------------------------------------------------------
/cyber/transport/message/history_attributes.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_MESSAGE_HISTORY_ATTRIBUTES_H_
18 | #define CYBER_TRANSPORT_MESSAGE_HISTORY_ATTRIBUTES_H_
19 |
20 | #include
21 |
22 | #include "cyber/proto/qos_profile.pb.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace transport {
27 |
28 | struct HistoryAttributes {
29 | HistoryAttributes()
30 | : history_policy(proto::QosHistoryPolicy::HISTORY_KEEP_LAST),
31 | depth(1000) {}
32 | HistoryAttributes(const proto::QosHistoryPolicy& qos_history_policy,
33 | uint32_t history_depth)
34 | : history_policy(qos_history_policy), depth(history_depth) {}
35 |
36 | proto::QosHistoryPolicy history_policy;
37 | uint32_t depth;
38 | };
39 |
40 | } // namespace transport
41 | } // namespace cyber
42 | } // namespace apollo
43 |
44 | #endif // CYBER_TRANSPORT_MESSAGE_HISTORY_ATTRIBUTES_H_
45 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_recorder/player/play_param.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAY_PARAM_H_
18 | #define CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAY_PARAM_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace record {
27 |
28 | struct PlayParam {
29 | bool is_play_all_channels = false;
30 | bool is_loop_playback = false;
31 | double play_rate = 1.0;
32 | uint64_t begin_time_ns = 0;
33 | uint64_t end_time_ns = UINT64_MAX;
34 | uint64_t start_time_s = 0;
35 | uint64_t delay_time_s = 0;
36 | uint32_t preload_time_s = 3;
37 | std::set files_to_play;
38 | std::set channels_to_play;
39 | std::set black_channels;
40 | };
41 |
42 | } // namespace record
43 | } // namespace cyber
44 | } // namespace apollo
45 |
46 | #endif // CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAY_PARAM_H_
47 |
--------------------------------------------------------------------------------
/cyber/message/py_message_traits.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_MESSAGE_PY_MESSAGE_TRAITS_H_
18 | #define CYBER_MESSAGE_PY_MESSAGE_TRAITS_H_
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "cyber/message/py_message.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 | namespace message {
29 |
30 | // Template specialization for RawMessage
31 | inline bool SerializeToArray(const PyMessageWrap& message, void* data,
32 | int size) {
33 | return message.SerializeToArray(data, size);
34 | }
35 |
36 | inline bool ParseFromArray(const void* data, int size, PyMessageWrap* message) {
37 | return message->ParseFromArray(data, size);
38 | }
39 |
40 | inline int ByteSize(const PyMessageWrap& message) { return message.ByteSize(); }
41 |
42 | } // namespace message
43 | } // namespace cyber
44 | } // namespace apollo
45 |
46 | #endif // CYBER_MESSAGE_PY_MESSAGE_TRAITS_H_
47 |
--------------------------------------------------------------------------------
/cyber/parameter/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools:cpplint.bzl", "cpplint")
2 |
3 | package(default_visibility = ["//visibility:public"])
4 |
5 | cc_library(
6 | name = "parameter",
7 | srcs = ["parameter.cc"],
8 | hdrs = ["parameter.h"],
9 | deps = [
10 | "//cyber/message:protobuf_factory",
11 | "//cyber/proto:parameter_cc_proto",
12 | ],
13 | )
14 |
15 | cc_test(
16 | name = "parameter_test",
17 | size = "small",
18 | srcs = ["parameter_test.cc"],
19 | deps = [
20 | "//cyber",
21 | "@gtest//:main",
22 | ],
23 | )
24 |
25 | cc_library(
26 | name = "parameter_client",
27 | srcs = ["parameter_client.cc"],
28 | hdrs = ["parameter_client.h"],
29 | deps = [
30 | ":parameter",
31 | ":parameter_service_names",
32 | "//cyber/node",
33 | "//cyber/service:client",
34 | "@fastrtps",
35 | ],
36 | )
37 |
38 | cc_test(
39 | name = "parameter_client_test",
40 | srcs = ["parameter_client_test.cc"],
41 | deps = [
42 | "//cyber",
43 | "@gtest//:main",
44 | ],
45 | )
46 |
47 | cc_library(
48 | name = "parameter_server",
49 | srcs = ["parameter_server.cc"],
50 | hdrs = ["parameter_server.h"],
51 | deps = [
52 | ":parameter",
53 | ":parameter_service_names",
54 | "//cyber/node",
55 | "//cyber/service",
56 | "@fastrtps",
57 | ],
58 | )
59 |
60 | cc_test(
61 | name = "parameter_server_test",
62 | size = "small",
63 | srcs = ["parameter_server_test.cc"],
64 | deps = [
65 | "//cyber",
66 | "@gtest//:main",
67 | ],
68 | )
69 |
70 | cc_library(
71 | name = "parameter_service_names",
72 | hdrs = ["parameter_service_names.h"],
73 | )
74 |
75 | cpplint()
76 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/client.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env python2
3 |
4 | # ****************************************************************************
5 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | # ****************************************************************************
19 | # -*- coding: utf-8 -*-
20 | """Module for example of listener."""
21 |
22 | import time
23 |
24 | from cyber_py import cyber
25 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
26 |
27 |
28 | def test_client_class():
29 | """
30 | Client send request
31 | """
32 | node = cyber.Node("client_node")
33 | client = node.create_client("server_01", ChatterBenchmark, ChatterBenchmark)
34 | req = ChatterBenchmark()
35 | req.content = "clt:Hello service!"
36 | req.seq = 0
37 | count = 0
38 | while not cyber.is_shutdown():
39 | time.sleep(1)
40 | count += 1
41 | req.seq = count
42 | print("-" * 80)
43 | response = client.send_request(req)
44 | print("get Response [ ", response, " ]")
45 |
46 |
47 | if __name__ == '__main__':
48 | cyber.init()
49 | test_client_class()
50 | cyber.shutdown()
51 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/examples/client.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env python3
3 |
4 | # ****************************************************************************
5 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | # ****************************************************************************
19 | # -*- coding: utf-8 -*-
20 | """Module for example of listener."""
21 |
22 | import time
23 |
24 | from cyber_py3 import cyber
25 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
26 |
27 |
28 | def test_client_class():
29 | """
30 | Client send request
31 | """
32 | node = cyber.Node("client_node")
33 | client = node.create_client("server_01", ChatterBenchmark, ChatterBenchmark)
34 | req = ChatterBenchmark()
35 | req.content = "clt:Hello service!"
36 | req.seq = 0
37 | count = 0
38 | while not cyber.is_shutdown():
39 | time.sleep(1)
40 | count += 1
41 | req.seq = count
42 | print("-" * 80)
43 | response = client.send_request(req)
44 | print("get Response [ ", response, " ]")
45 |
46 |
47 | if __name__ == '__main__':
48 | cyber.init()
49 | test_client_class()
50 | cyber.shutdown()
51 |
--------------------------------------------------------------------------------
/cyber/service/service_base.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_SERVICE_SERVICE_BASE_H_
18 | #define CYBER_SERVICE_SERVICE_BASE_H_
19 |
20 | #include
21 |
22 | namespace apollo {
23 | namespace cyber {
24 |
25 | /**
26 | * @class ServiceBase
27 | * @brief Base class for Service
28 | *
29 | */
30 | class ServiceBase {
31 | public:
32 | /**
33 | * @brief Construct a new Service Base object
34 | *
35 | * @param service_name name of this Service
36 | */
37 | explicit ServiceBase(const std::string& service_name)
38 | : service_name_(service_name) {}
39 |
40 | virtual ~ServiceBase() {}
41 |
42 | virtual void destroy() = 0;
43 |
44 | /**
45 | * @brief Get the service name
46 | */
47 | const std::string& service_name() const { return service_name_; }
48 |
49 | protected:
50 | std::string service_name_;
51 | };
52 |
53 | } // namespace cyber
54 | } // namespace apollo
55 |
56 | #endif // CYBER_SERVICE_SERVICE_BASE_H_
57 |
--------------------------------------------------------------------------------
/cmake/external/gflags-2.2.0.cmake:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(Gflags VERSION "2.2.0")
3 |
4 | set(LOCAL_DEPENDS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/local_depends/ )
5 | set(CYBER_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/opt/CyberRT/ )
6 | set(THIRDPARTY_LIBS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/opt/thirdparty/")
7 |
8 | set(GFLAGS_SRC file://${CMAKE_SOURCE_DIR}/tmp/gflags-2.2.0.tar.gz )
9 |
10 | find_package(Gflags QUIET)
11 |
12 | if(NOT Gflags_FOUND)
13 | message(STATUS "Gflags not found, going to build it")
14 | option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
15 |
16 | if(BUILD_SHARED_LIBS)
17 | list(APPEND extra_cmake_args -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
18 | endif()
19 |
20 | if(DEFINED CMAKE_BUILD_TYPE)
21 | list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
22 | endif()
23 |
24 | include(ExternalProject)
25 |
26 | externalproject_add(gflags
27 | URL ${GFLAGS_SRC}
28 | #DOWNLOAD_DIR dl
29 | TIMEOUT 600
30 | PREFIX external
31 | UPDATE_COMMAND ""
32 | CMAKE_ARGS
33 | -DBUILD_SHARED_LIBS=ON
34 | -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/local_depends/
35 | ${extra_cmake_args}
36 | -Wno-dev
37 | )
38 |
39 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/local_depends/
40 | DESTINATION ${CMAKE_INSTALL_PREFIX})
41 | else()
42 | message(STATUS "Found Gflags ver: ${Gflags_VERSION}")
43 | endif()
44 |
45 | include(CMakePackageConfigHelpers)
46 | write_basic_package_version_file(
47 | "${PROJECT_BINARY_DIR}/GflagsConfig-version.cmake"
48 | COMPATIBILITY AnyNewerVersion)
49 |
50 | install(FILES
51 | #"${PROJECT_BINARY_DIR}/GflagsConfig.cmake"
52 | "${PROJECT_BINARY_DIR}/GflagsConfig-version.cmake"
53 | DESTINATION share/${PROJECT_NAME}/cmake)
54 |
--------------------------------------------------------------------------------
/cyber/transport/common/endpoint.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TRANSPORT_COMMON_ENDPOINT_H_
18 | #define CYBER_TRANSPORT_COMMON_ENDPOINT_H_
19 |
20 | #include
21 | #include
22 |
23 | #include "cyber/proto/role_attributes.pb.h"
24 | #include "cyber/transport/common/identity.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 | namespace transport {
29 |
30 | class Endpoint;
31 | using EndpointPtr = std::shared_ptr;
32 |
33 | using proto::RoleAttributes;
34 |
35 | class Endpoint {
36 | public:
37 | explicit Endpoint(const RoleAttributes& attr);
38 | virtual ~Endpoint();
39 |
40 | const Identity& id() const { return id_; }
41 | const RoleAttributes& attributes() const { return attr_; }
42 |
43 | protected:
44 | bool enabled_;
45 | Identity id_;
46 | RoleAttributes attr_;
47 | };
48 |
49 | } // namespace transport
50 | } // namespace cyber
51 | } // namespace apollo
52 |
53 | #endif // CYBER_TRANSPORT_COMMON_ENDPOINT_H_
54 |
--------------------------------------------------------------------------------
/cyber/sysmo/sysmo.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2019 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/sysmo/sysmo.h"
18 |
19 | #include "cyber/common/environment.h"
20 |
21 | namespace apollo {
22 | namespace cyber {
23 |
24 | using apollo::cyber::common::GetEnv;
25 |
26 | SysMo::SysMo() { Start(); }
27 |
28 | void SysMo::Start() {
29 | auto sysmo_start = GetEnv("sysmo_start");
30 | if (sysmo_start != "" && std::stoi(sysmo_start)) {
31 | start_ = true;
32 | sysmo_ = std::thread(&SysMo::Checker, this);
33 | }
34 | }
35 |
36 | void SysMo::Shutdown() {
37 | if (!start_ || shut_down_.exchange(true)) {
38 | return;
39 | }
40 |
41 | cv_.notify_all();
42 | if (sysmo_.joinable()) {
43 | sysmo_.join();
44 | }
45 | }
46 |
47 | void SysMo::Checker() {
48 | while (cyber_unlikely(!shut_down_.load())) {
49 | scheduler::Instance()->CheckSchedStatus();
50 | std::unique_lock lk(lk_);
51 | cv_.wait_for(lk, std::chrono::milliseconds(sysmo_interval_ms_));
52 | }
53 | }
54 |
55 | } // namespace cyber
56 | } // namespace apollo
57 |
--------------------------------------------------------------------------------
/cyber/common/environment.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_COMMON_ENVIRONMENT_H_
18 | #define CYBER_COMMON_ENVIRONMENT_H_
19 |
20 | #include
21 | #include
22 |
23 | #include "cyber/common/log.h"
24 |
25 | namespace apollo {
26 | namespace cyber {
27 | namespace common {
28 |
29 | inline std::string GetEnv(const std::string& var_name,
30 | const std::string& default_value = "") {
31 | const char* var = std::getenv(var_name.c_str());
32 | if (var == nullptr) {
33 | AWARN << "Environment variable [" << var_name << "] not set, fallback to "
34 | << default_value;
35 | return default_value;
36 | }
37 | return std::string(var);
38 | }
39 |
40 | inline const std::string WorkRoot() {
41 | std::string work_root = GetEnv("CYBER_PATH");
42 | if (work_root.empty()) {
43 | work_root = "/apollo/cyber";
44 | }
45 | return work_root;
46 | }
47 |
48 | } // namespace common
49 | } // namespace cyber
50 | } // namespace apollo
51 |
52 | #endif // CYBER_COMMON_ENVIRONMENT_H_
53 |
--------------------------------------------------------------------------------
/cyber/conf/example_sched_classic.conf:
--------------------------------------------------------------------------------
1 | scheduler_conf {
2 | policy: "classic"
3 | process_level_cpuset: "0-7,16-23" # all threads in the process are on the cpuset
4 | threads: [
5 | {
6 | name: "async_log"
7 | cpuset: "1"
8 | policy: "SCHED_OTHER" # policy: SCHED_OTHER,SCHED_RR,SCHED_FIFO
9 | prio: 0
10 | }, {
11 | name: "shm"
12 | cpuset: "2"
13 | policy: "SCHED_FIFO"
14 | prio: 10
15 | }
16 | ]
17 | classic_conf {
18 | groups: [
19 | {
20 | name: "group1"
21 | processor_num: 16
22 | affinity: "range"
23 | cpuset: "0-7,16-23"
24 | processor_policy: "SCHED_OTHER" # policy: SCHED_OTHER,SCHED_RR,SCHED_FIFO
25 | processor_prio: 0
26 | tasks: [
27 | {
28 | name: "E"
29 | prio: 0
30 | }
31 | ]
32 | },{
33 | name: "group2"
34 | processor_num: 16
35 | affinity: "1to1"
36 | cpuset: "8-15,24-31"
37 | processor_policy: "SCHED_OTHER"
38 | processor_prio: 0
39 | tasks: [
40 | {
41 | name: "A"
42 | prio: 0
43 | },{
44 | name: "B"
45 | prio: 1
46 | },{
47 | name: "C"
48 | prio: 2
49 | },{
50 | name: "D"
51 | prio: 3
52 | }
53 | ]
54 | }
55 | ]
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py/examples/talker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | # ****************************************************************************
4 | # Copyright 2018 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of talker."""
20 |
21 | import time
22 |
23 | from cyber_py import cyber
24 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
25 |
26 |
27 | def test_talker_class():
28 | """
29 | Test talker.
30 | """
31 | msg = ChatterBenchmark()
32 | msg.content = "py:talker:send Alex!"
33 | msg.stamp = 9999
34 | msg.seq = 0
35 | print(msg)
36 | test_node = cyber.Node("node_name1")
37 | g_count = 1
38 |
39 | writer = test_node.create_writer("channel/chatter", ChatterBenchmark, 6)
40 | while not cyber.is_shutdown():
41 | time.sleep(1)
42 | g_count = g_count + 1
43 | msg.seq = g_count
44 | msg.content = "I am python talker."
45 | print("=" * 80)
46 | print("write msg -> %s" % msg)
47 | writer.write(msg)
48 |
49 |
50 | if __name__ == '__main__':
51 | cyber.init("talker_sample")
52 | test_talker_class()
53 | cyber.shutdown()
54 |
--------------------------------------------------------------------------------
/cyber/python/cyber_py3/examples/talker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # ****************************************************************************
4 | # Copyright 2019 The Apollo Authors. All Rights Reserved.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | # ****************************************************************************
18 | # -*- coding: utf-8 -*-
19 | """Module for example of talker."""
20 |
21 | import time
22 |
23 | from cyber_py3 import cyber
24 | from cyber.proto.unit_test_pb2 import ChatterBenchmark
25 |
26 |
27 | def test_talker_class():
28 | """
29 | Test talker.
30 | """
31 | msg = ChatterBenchmark()
32 | msg.content = "py:talker:send Alex!"
33 | msg.stamp = 9999
34 | msg.seq = 0
35 | print(msg)
36 | test_node = cyber.Node("node_name1")
37 | g_count = 1
38 |
39 | writer = test_node.create_writer("channel/chatter", ChatterBenchmark, 6)
40 | while not cyber.is_shutdown():
41 | time.sleep(1)
42 | g_count = g_count + 1
43 | msg.seq = g_count
44 | msg.content = "I am python talker."
45 | print("=" * 80)
46 | print("write msg -> %s" % msg)
47 | writer.write(msg)
48 |
49 |
50 | if __name__ == '__main__':
51 | cyber.init("talker_sample")
52 | test_talker_class()
53 | cyber.shutdown()
54 |
--------------------------------------------------------------------------------
/cyber/examples/talker.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/cyber.h"
18 | #include "cyber/examples/proto/examples.pb.h"
19 | #include "cyber/time/rate.h"
20 | #include "cyber/time/time.h"
21 |
22 | using apollo::cyber::Rate;
23 | using apollo::cyber::Time;
24 | using apollo::cyber::examples::proto::Chatter;
25 |
26 | int main(int argc, char *argv[]) {
27 | // init cyber framework
28 | apollo::cyber::Init(argv[0]);
29 | // create talker node
30 | auto talker_node = apollo::cyber::CreateNode("talker");
31 | // create talker
32 | auto talker = talker_node->CreateWriter("channel/chatter");
33 | Rate rate(1.0);
34 | while (apollo::cyber::OK()) {
35 | static uint64_t seq = 0;
36 | auto msg = std::make_shared();
37 | msg->set_timestamp(Time::Now().ToNanosecond());
38 | msg->set_lidar_timestamp(Time::Now().ToNanosecond());
39 | msg->set_seq(seq++);
40 | msg->set_content("Hello, apollo!");
41 | talker->Write(msg);
42 | AINFO << "talker sent a message!";
43 | rate.Sleep();
44 | }
45 | return 0;
46 | }
47 |
--------------------------------------------------------------------------------
/cyber/record/file/record_file_base.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/record/file/record_file_base.h"
18 |
19 | #include
20 | #include
21 |
22 | #include "cyber/common/log.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace record {
27 |
28 | int64_t RecordFileBase::CurrentPosition() {
29 | off_t pos = lseek(fd_, 0, SEEK_CUR);
30 | if (pos < 0) {
31 | AERROR << "lseek failed, file: " << path_ << ", fd: " << fd_
32 | << ", offset: 0, whence: SEEK_CUR"
33 | << ", position: " << pos << ", errno: " << errno;
34 | }
35 | return pos;
36 | }
37 |
38 | bool RecordFileBase::SetPosition(int64_t position) {
39 | off_t pos = lseek(fd_, position, SEEK_SET);
40 | if (pos < 0) {
41 | AERROR << "lseek failed, file: " << path_ << ", fd: " << fd_
42 | << ", offset: 0, whence: SEEK_SET"
43 | << ", position: " << pos << ", errno: " << errno;
44 | return false;
45 | }
46 | return true;
47 | }
48 |
49 | } // namespace record
50 | } // namespace cyber
51 | } // namespace apollo
52 |
--------------------------------------------------------------------------------
/cyber/base/for_each.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_BASE_FOR_EACH_H_
18 | #define CYBER_BASE_FOR_EACH_H_
19 |
20 | #include
21 |
22 | #include "cyber/base/macros.h"
23 |
24 | namespace apollo {
25 | namespace cyber {
26 | namespace base {
27 |
28 | DEFINE_TYPE_TRAIT(HasLess, operator<) // NOLINT
29 |
30 | template
31 | typename std::enable_if::value && HasLess::value,
32 | bool>::type
33 | LessThan(const Value& val, const End& end) {
34 | return val < end;
35 | }
36 |
37 | template
38 | typename std::enable_if::value || !HasLess::value,
39 | bool>::type
40 | LessThan(const Value& val, const End& end) {
41 | return val != end;
42 | }
43 |
44 | #define FOR_EACH(i, begin, end) \
45 | for (auto i = (true ? (begin) : (end)); \
46 | apollo::cyber::base::LessThan(i, (end)); ++i)
47 |
48 | } // namespace base
49 | } // namespace cyber
50 | } // namespace apollo
51 |
52 | #endif // CYBER_BASE_FOR_EACH_H_
53 |
--------------------------------------------------------------------------------
/cyber/io/poll_handler.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_IO_POLL_HANDLER_H_
18 | #define CYBER_IO_POLL_HANDLER_H_
19 |
20 | #include
21 | #include
22 |
23 | #include "cyber/croutine/croutine.h"
24 | #include "cyber/io/poll_data.h"
25 |
26 | namespace apollo {
27 | namespace cyber {
28 | namespace io {
29 |
30 | class PollHandler {
31 | public:
32 | explicit PollHandler(int fd);
33 | virtual ~PollHandler() = default;
34 |
35 | bool Block(int timeout_ms, bool is_read);
36 | bool Unblock();
37 |
38 | int fd() const { return fd_; }
39 | void set_fd(int fd) { fd_ = fd; }
40 |
41 | private:
42 | bool Check(int timeout_ms);
43 | void Fill(int timeout_ms, bool is_read);
44 | void ResponseCallback(const PollResponse& rsp);
45 |
46 | int fd_;
47 | PollRequest request_;
48 | PollResponse response_;
49 | std::atomic is_read_;
50 | std::atomic is_blocking_;
51 | croutine::CRoutine* routine_;
52 | };
53 |
54 | } // namespace io
55 | } // namespace cyber
56 | } // namespace apollo
57 |
58 | #endif // CYBER_IO_POLL_HANDLER_H_
59 |
--------------------------------------------------------------------------------
/cyber/mainboard/mainboard.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/common/global_data.h"
18 | #include "cyber/common/log.h"
19 | #include "cyber/init.h"
20 | #include "cyber/mainboard/module_argument.h"
21 | #include "cyber/mainboard/module_controller.h"
22 | #include "cyber/state.h"
23 |
24 | #include "gflags/gflags.h"
25 |
26 | using apollo::cyber::mainboard::ModuleArgument;
27 | using apollo::cyber::mainboard::ModuleController;
28 |
29 | int main(int argc, char** argv) {
30 | google::SetUsageMessage("we use this program to load dag and run user apps.");
31 |
32 | // parse the argument
33 | ModuleArgument module_args;
34 | module_args.ParseArgument(argc, argv);
35 |
36 | // initialize cyber
37 | apollo::cyber::Init(argv[0]);
38 |
39 | // start module
40 | ModuleController controller(module_args);
41 | if (!controller.Init()) {
42 | controller.Clear();
43 | AERROR << "module start error.";
44 | return -1;
45 | }
46 |
47 | apollo::cyber::WaitForShutdown();
48 | controller.Clear();
49 | AINFO << "exit mainboard.";
50 |
51 | return 0;
52 | }
53 |
--------------------------------------------------------------------------------
/cyber/data/data_visitor_base.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_DATA_DATA_VISITOR_BASE_H_
18 | #define CYBER_DATA_DATA_VISITOR_BASE_H_
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "cyber/common/global_data.h"
26 | #include "cyber/common/log.h"
27 | #include "cyber/data/data_notifier.h"
28 |
29 | namespace apollo {
30 | namespace cyber {
31 | namespace data {
32 |
33 | class DataVisitorBase {
34 | public:
35 | DataVisitorBase() : notifier_(new Notifier()) {}
36 |
37 | void RegisterNotifyCallback(std::function&& callback) {
38 | notifier_->callback = callback;
39 | }
40 |
41 | protected:
42 | DataVisitorBase(const DataVisitorBase&) = delete;
43 | DataVisitorBase& operator=(const DataVisitorBase&) = delete;
44 |
45 | uint64_t next_msg_index_ = 0;
46 | DataNotifier* data_notifier_ = DataNotifier::Instance();
47 | std::shared_ptr notifier_;
48 | };
49 |
50 | } // namespace data
51 | } // namespace cyber
52 | } // namespace apollo
53 |
54 | #endif // CYBER_DATA_DATA_VISITOR_BASE_H_
55 |
--------------------------------------------------------------------------------
/cyber/examples/paramserver.cc:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #include "cyber/cyber.h"
18 | #include "cyber/parameter/parameter_client.h"
19 | #include "cyber/parameter/parameter_server.h"
20 |
21 | using apollo::cyber::Parameter;
22 | using apollo::cyber::ParameterClient;
23 | using apollo::cyber::ParameterServer;
24 |
25 | int main(int argc, char** argv) {
26 | apollo::cyber::Init(*argv);
27 | std::shared_ptr node =
28 | apollo::cyber::CreateNode("parameter");
29 | auto param_server = std::make_shared(node);
30 | auto param_client = std::make_shared(node, "parameter");
31 | param_server->SetParameter(Parameter("int", 1));
32 | Parameter parameter;
33 | param_server->GetParameter("int", ¶meter);
34 | AINFO << "int: " << parameter.AsInt64();
35 | param_client->SetParameter(Parameter("string", "test"));
36 | param_client->GetParameter("string", ¶meter);
37 | AINFO << "string: " << parameter.AsString();
38 | param_client->GetParameter("int", ¶meter);
39 | AINFO << "int: " << parameter.AsInt64();
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/cyber/tools/cyber_recorder/player/play_task_buffer.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *****************************************************************************/
16 |
17 | #ifndef CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAY_TASK_BUFFER_H_
18 | #define CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAY_TASK_BUFFER_H_
19 |
20 | #include
21 | #include