├── README.md
├── low_power_consumption
├── lib
│ └── libpm_client.so
├── package.xml
├── src
│ ├── main.cpp
│ └── power_consumption_manager.cpp
├── CMakeLists.txt
└── include
│ └── low_power_consumption
│ ├── pm_if.h
│ ├── power_consumption_manager.hpp
│ └── low_power_consumption.hpp
├── .github
├── ISSUE_TEMPLATE
│ ├── custom.md
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── workflow.yml
├── .gitignore
├── manager_base
├── package.xml
├── CMakeLists.txt
└── include
│ └── manager_base
│ └── manager_base.hpp
├── black_box
├── package.xml
├── src
│ └── test_black_box.cpp
├── CMakeLists.txt
└── include
│ └── black_box
│ └── black_box.hpp
├── user_info_manager
├── package.xml
├── CMakeLists.txt
├── src
│ └── test_inteface_node.cpp
├── include
│ └── user_info_manager
│ │ └── UserAccountManager.hpp
└── test
│ └── test.cpp
├── cyberdog_permissions
├── package.xml
├── src
│ ├── main.cpp
│ └── cyberdog_permission.cpp
├── CMakeLists.txt
└── include
│ └── cyberdog_permission
│ ├── cyberdog_permission.hpp
│ └── board_info.hpp
├── cyberdog_manager
├── package.xml
├── src
│ ├── main.cpp
│ └── cyberdog_manager.cpp
├── CMakeLists.txt
└── include
│ └── cyberdog_manager
│ ├── cyberdog_manager.hpp
│ ├── env_contex.hpp
│ ├── error_context.hpp
│ ├── audio_info.hpp
│ ├── touch_info.hpp
│ ├── battery_capacity_info.hpp
│ ├── heart_context.hpp
│ ├── power_brd_info.hpp
│ ├── led_info.hpp
│ ├── power_consumption_info.hpp
│ ├── account_info.hpp
│ └── ready_info.hpp
└── LICENSE.txt
/README.md:
--------------------------------------------------------------------------------
1 | # cyberdog_manager
2 |
3 |
--------------------------------------------------------------------------------
/low_power_consumption/lib/libpm_client.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MiRoboticsLab/manager/HEAD/low_power_consumption/lib/libpm_client.so
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # cache and binary files during ros build
2 | build/
3 | log/
4 | install/
5 |
6 | # files create by macOS
7 | *.DS_Store
8 |
9 | # vs code workspace
10 | .vscode/
11 |
12 | # swp files
13 | *.swp
14 |
15 | .github
16 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/manager_base/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | manager_base
5 | 0.0.0
6 | TODO: Package description
7 | dukun
8 | TODO: License declaration
9 |
10 | ament_cmake
11 |
12 | rclcpp
13 | protocol
14 | cyberdog_system
15 | ament_lint_auto
16 | ament_lint_common
17 |
18 |
19 | ament_cmake
20 |
21 |
22 |
--------------------------------------------------------------------------------
/black_box/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | black_box
5 | 0.0.0
6 | TODO: Package description
7 | dukun
8 | Apache License, Version 2.0
9 |
10 | ament_cmake
11 | rclcpp
12 | protocol
13 | cyberdog_common
14 | params
15 | ament_lint_auto
16 | ament_lint_common
17 |
18 |
19 | ament_cmake
20 |
21 |
22 |
--------------------------------------------------------------------------------
/user_info_manager/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | user_info_manager
5 | 0.0.0
6 | TODO: Package description
7 | yp
8 | Apache License, Version 2.0
9 | ament_cmake
10 | rclcpp
11 | rapidjson
12 | cyberdog_common
13 | black_box
14 | ament_lint_auto
15 | ament_lint_common
16 |
17 | ament_cmake
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/low_power_consumption/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | low_power_consumption
5 | 0.0.0
6 | TODO: Package description
7 | dukun
8 | TODO: License declaration
9 |
10 | ament_cmake
11 | rclcpp
12 | cyberdog_common
13 | std_srvs
14 | protocol
15 |
16 | ament_lint_auto
17 | ament_lint_common
18 |
19 | ament_cmake
20 |
21 |
22 |
--------------------------------------------------------------------------------
/cyberdog_permissions/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | cyberdog_permission
5 | 0.0.0
6 | TODO: Package description
7 | liukai
8 | TODO: License declaration
9 |
10 | ament_cmake
11 | rclcpp
12 | std_msgs
13 | cyberdog_common
14 | std_srvs
15 | ament_index_cpp
16 |
17 | ament_lint_auto
18 | ament_lint_common
19 |
20 |
21 | ament_cmake
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/cyberdog_manager/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | cyberdog_manager
5 | 0.0.0
6 | TODO: Package description
7 | dukun
8 | TODO: License declaration
9 |
10 | ament_cmake
11 | rclcpp
12 | rclcpp_action
13 | cyberdog_system
14 | manager_base
15 | black_box
16 | cyberdog_common
17 | user_info_manager
18 | cyberdog_machine
19 | std_srvs
20 | protocol
21 | low_power_consumption
22 | ament_index_cpp
23 |
24 | ament_lint_auto
25 | ament_lint_common
26 |
27 |
28 | ament_cmake
29 |
30 |
31 |
--------------------------------------------------------------------------------
/manager_base/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(manager_base)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic)
6 | endif()
7 |
8 | if(NOT CMAKE_C_STANDARD)
9 | set(CMAKE_C_STANDARD 99)
10 | endif()
11 |
12 | if(NOT CMAKE_CXX_STANDARD)
13 | set(CMAKE_CXX_STANDARD 17)
14 | endif()
15 |
16 | # find dependencies
17 | find_package(ament_cmake REQUIRED)
18 | find_package(rclcpp REQUIRED)
19 | find_package(protocol REQUIRED)
20 | find_package(cyberdog_system REQUIRED)
21 |
22 |
23 | install(DIRECTORY include/
24 | DESTINATION include/)
25 |
26 | if(BUILD_TESTING)
27 | find_package(ament_lint_auto REQUIRED)
28 | # the following line skips the linter which checks for copyrights
29 | # uncomment the line when a copyright and license is not present in all source files
30 | #set(ament_cmake_copyright_FOUND TRUE)
31 | # the following line skips cpplint (only works in a git repo)
32 | # uncomment the line when this package is not in a git repo
33 | #set(ament_cmake_cpplint_FOUND TRUE)
34 | ament_lint_auto_find_test_dependencies()
35 | endif()
36 |
37 | ament_export_include_directories(include)
38 |
39 | ament_package()
40 |
--------------------------------------------------------------------------------
/low_power_consumption/src/main.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 | #include "low_power_consumption/power_consumption_manager.hpp"
17 |
18 | int main(int argc, char ** argv)
19 | {
20 | rclcpp::init(argc, argv);
21 | LOGGER_MAIN_INSTANCE("power_consumption_manager");
22 | std::shared_ptr power_manger =
23 | std::make_shared("cyberdog_poewr_manager");
24 | if (!power_manger->Init()) {
25 | ERROR("init error");
26 | }
27 | power_manger->Run();
28 | return 0;
29 | }
30 |
--------------------------------------------------------------------------------
/.github/workflows/workflow.yml:
--------------------------------------------------------------------------------
1 | name: GitHub Actions CI
2 | run-name: ${{ github.actor }} is run GitHub Actions 🚀
3 | on: [push]
4 | defaults:
5 | run:
6 | shell: bash
7 | jobs:
8 | build-job:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Login to Docker Hub
12 | uses: docker/login-action@v2
13 | with:
14 | registry: ghcr.io
15 | username: ${{ github.actor }}
16 | password: ${{ secrets.GIT_TOKEN }}
17 | - name: Install dependence
18 | run: |
19 | sudo apt install -y qemu-user-static binfmt-support
20 | - name: Download code
21 | uses: actions/checkout@v3
22 | - name: Build and code test
23 | run: |
24 | docker pull ghcr.io/miroboticslab/cyberdog:v1
25 | docker run -i -v $GITHUB_WORKSPACE:/home/ros2/src ghcr.io/miroboticslab/cyberdog:v1 bash -c \
26 | "cd /home/ros2 && source /opt/ros2/galactic/setup.bash \
27 | && colcon build --packages-up-to cyberdog_manager manager_base black_box user_info_manager \
28 | && colcon test --event-handlers console_cohesion+ --return-code-on-test-failure --packages-select cyberdog_manager manager_base black_box user_info_manager"
29 | # colcon build test
30 |
--------------------------------------------------------------------------------
/cyberdog_manager/src/main.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #include
15 | #include "cyberdog_manager/cyberdog_manager.hpp"
16 | #include "manager_base/manager_base.hpp"
17 | #include "cyberdog_common/cyberdog_log.hpp"
18 |
19 |
20 | int main(int argc, char ** argv)
21 | {
22 | rclcpp::init(argc, argv);
23 | LOGGER_MAIN_INSTANCE("cyberdog_manager");
24 |
25 | std::shared_ptr manager =
26 | std::make_shared("cyberdog_manager");
27 | std::thread t([&]() {
28 | if (!manager->Init()) {
29 | ERROR("init error");
30 | }
31 | });
32 | t.detach();
33 | manager->Run();
34 | return 0;
35 | }
36 |
--------------------------------------------------------------------------------
/cyberdog_permissions/src/main.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #include
15 | #include "cyberdog_permission/cyberdog_permission.hpp"
16 | #include "cyberdog_common/cyberdog_log.hpp"
17 |
18 |
19 | int main(int argc, char ** argv)
20 | {
21 | LOGGER_MAIN_INSTANCE(NODE_NAME);
22 | rclcpp::init(argc, argv);
23 | auto permission_node =
24 | std::make_shared();
25 | try {
26 | rclcpp::spin(permission_node);
27 | } catch (rclcpp::exceptions::RCLError & e) {
28 | ERROR(
29 | "node spin rcl error exception:(line:%d,file:%d,messgae:%s[%s])",
30 | e.line, e.file, e.message, e.formatted_message);
31 | } catch (const std::exception & e) {
32 | std::cerr << e.what() << '\n';
33 | } catch (...) {
34 | ERROR("node spin unkown exception");
35 | }
36 | rclcpp::shutdown();
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/cyberdog_permissions/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(cyberdog_permission)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic)
6 | endif()
7 |
8 | if(NOT CMAKE_C_STANDARD)
9 | set(CMAKE_C_STANDARD 99)
10 | endif()
11 |
12 | if(NOT CMAKE_CXX_STANDARD)
13 | set(CMAKE_CXX_STANDARD 17)
14 | endif()
15 |
16 | find_package(ament_cmake REQUIRED)
17 | find_package(rclcpp REQUIRED)
18 | find_package(std_msgs REQUIRED)
19 | find_package(std_srvs REQUIRED)
20 | find_package(cyberdog_common REQUIRED)
21 | find_package(ament_index_cpp REQUIRED)
22 |
23 | include_directories(include)
24 |
25 | add_executable(${PROJECT_NAME} src/cyberdog_permission.cpp src/main.cpp)
26 |
27 | ament_target_dependencies( ${PROJECT_NAME}
28 | rclcpp
29 | std_msgs
30 | std_srvs
31 | cyberdog_common
32 | ament_index_cpp)
33 |
34 | install(TARGETS ${PROJECT_NAME}
35 | DESTINATION lib/${PROJECT_NAME})
36 |
37 | if(BUILD_TESTING)
38 | find_package(ament_lint_auto REQUIRED)
39 | # the following line skips the linter which checks for copyrights
40 | # uncomment the line when a copyright and license is not present in all source files
41 | #set(ament_cmake_copyright_FOUND TRUE)
42 | # the following line skips cpplint (only works in a git repo)
43 | # uncomment the line when this package is not in a git repo
44 | #set(ament_cmake_cpplint_FOUND TRUE)
45 | ament_lint_auto_find_test_dependencies()
46 | endif()
47 |
48 |
49 | ament_package()
50 |
--------------------------------------------------------------------------------
/user_info_manager/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(user_info_manager)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-class-memaccess)
6 | endif()
7 |
8 | # find dependencies
9 | find_package(ament_cmake REQUIRED)
10 | find_package(rclcpp REQUIRED)
11 | find_package(rapidjson REQUIRED)
12 | find_package(cyberdog_common REQUIRED)
13 | find_package(black_box REQUIRED)
14 |
15 | set(dependencies
16 | cyberdog_common
17 | rapidjson
18 | rclcpp
19 | black_box
20 | )
21 |
22 | if(BUILD_TESTING)
23 | find_package(ament_lint_auto REQUIRED)
24 | ament_lint_auto_find_test_dependencies()
25 | endif()
26 |
27 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
28 | include_directories(include)
29 |
30 | add_executable(test_node src/test_inteface_node.cpp)
31 | add_executable(test_node2 test/test.cpp)
32 |
33 | #target_compile_definitions(test_node PRIVATE BenchmarkPath="${CMAKE_INSTALL_PREFIX}/lib/cyberdog_common")
34 | ament_target_dependencies(test_node rclcpp rapidjson cyberdog_common black_box)
35 | ament_target_dependencies(test_node2 rclcpp rapidjson cyberdog_common black_box)
36 |
37 | target_link_libraries(test_node ${cyberdog_log_LIBRARIES})
38 | install(
39 | TARGETS test_node test_node2
40 | DESTINATION lib/${PROJECT_NAME}
41 | )
42 | install(
43 | DIRECTORY include/
44 | DESTINATION include/
45 | )
46 | ament_export_include_directories(include)
47 | ament_export_dependencies(${dependencies})
48 | ament_package()
49 |
50 |
--------------------------------------------------------------------------------
/low_power_consumption/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(low_power_consumption)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic)
6 | endif()
7 |
8 | if(NOT CMAKE_C_STANDARD)
9 | set(CMAKE_C_STANDARD 99)
10 | endif()
11 |
12 | if(NOT CMAKE_CXX_STANDARD)
13 | set(CMAKE_CXX_STANDARD 17)
14 | endif()
15 |
16 | # find dependencies
17 | find_package(ament_cmake REQUIRED)
18 | find_package(rclcpp REQUIRED)
19 | find_package(protocol REQUIRED)
20 | find_package(std_srvs REQUIRED)
21 | find_package(cyberdog_common REQUIRED)
22 |
23 | include_directories(include)
24 |
25 | install(
26 | DIRECTORY include/
27 | DESTINATION include/
28 | )
29 |
30 | # install(
31 | # DIRECTORY lib/
32 | # DESTINATION lib/
33 | # )
34 | add_executable(${PROJECT_NAME} src/power_consumption_manager.cpp src/main.cpp)
35 | ament_target_dependencies( ${PROJECT_NAME}
36 | rclcpp
37 | protocol
38 | cyberdog_common
39 | std_srvs)
40 |
41 | install(TARGETS ${PROJECT_NAME}
42 | DESTINATION lib/${PROJECT_NAME})
43 |
44 | if(BUILD_TESTING)
45 | find_package(ament_lint_auto REQUIRED)
46 | # the following line skips the linter which checks for copyrights
47 | # uncomment the line when a copyright and license is not present in all source files
48 | #set(ament_cmake_copyright_FOUND TRUE)
49 | # the following line skips cpplint (only works in a git repo)
50 | # uncomment the line when this package is not in a git repo
51 | #set(ament_cmake_cpplint_FOUND TRUE)
52 | ament_lint_auto_find_test_dependencies()
53 | endif()
54 |
55 |
56 | ament_package()
57 |
--------------------------------------------------------------------------------
/black_box/src/test_black_box.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | int main(int argc, char * argv[])
22 | {
23 | rclcpp::init(argc, argv);
24 | LOGGER_MAIN_INSTANCE("Global_Name");
25 | auto node = rclcpp::Node::make_shared("test");
26 | cyberdog::manager::BlackBox test_data;
27 | test_data.AddUser("xiaomi");
28 | test_data.AddUser("xiaoxiao");
29 | test_data.ModifyUserName("xiaomi", "mimi");
30 | int filed_number;
31 | test_data.GetDataBaseList(filed_number);
32 | INFO("the filed number is %d \n", filed_number);
33 | auto black_box_ptr = std::make_shared(node);
34 | auto result = black_box_ptr->Init();
35 | INFO("init: %d", result);
36 | rclcpp::executors::SingleThreadedExecutor exec;
37 | exec.add_node(node);
38 | exec.spin();
39 | rclcpp::shutdown();
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/user_info_manager/src/test_inteface_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 | #include
17 | #include "rclcpp/rclcpp.hpp"
18 | #include "cyberdog_common/cyberdog_log.hpp"
19 | #include "user_info_manager/UserAccountManager.hpp"
20 | #include "vector"
21 | class Test_node : public rclcpp::Node
22 | {
23 | public:
24 | explicit Test_node(std::string name)
25 | : Node(name)
26 | {
27 | RCLCPP_INFO(this->get_logger(), "node name is %s.", name.c_str());
28 | INFO("enter test!!!!");
29 | cyberdog::common::CyberdogAccountManager account_manager;
30 | // account_manager.AddMember("ding");
31 | // account_manager.ModifyUserInformation("fff",100,0);
32 | // int result[2];
33 | // account_manager.SearchUser("ding",result);
34 | std::vector vectorUser;
35 | account_manager.SearAllUser(vectorUser);
36 | // account_manager.DeleteVoice("sss");
37 | // account_manager.DeleteFace("ding");
38 | // account_manager.DeleteUserInformation("eee");
39 | }
40 | };
41 |
42 | int main(int argc, char ** argv)
43 | {
44 | rclcpp::init(argc, argv);
45 | auto node = std::make_shared("test_node");
46 | rclcpp::spin(node);
47 | rclcpp::shutdown();
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/low_power_consumption/include/low_power_consumption/pm_if.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #ifndef LOW_POWER_CONSUMPTION__PM_IF_H_
15 | #define LOW_POWER_CONSUMPTION__PM_IF_H_
16 |
17 |
18 | #ifdef __cplusplus
19 | extern "C"
20 | {
21 | #endif
22 |
23 |
24 | enum PM_DEV
25 | {
26 | // bit 0-7 camera
27 | PM_CAM_REALSNS = 1 << 0, // 深度相机
28 | PM_CAM_AI = 1 << 1, // AI相机组件
29 | PM_CAM_FISH = 1<<2, // 鱼眼相机组件
30 | PM_CAM_ALL = 0Xff,
31 |
32 | // bit 8-11 motion
33 | PM_MOTION = 1 << 8, // 运动组件
34 | PM_MOTOR = 1 << 9, //电机断电
35 | // other
36 | PM_GPS = 1 << 12, // GPS 组件
37 | PM_LIDAR = 1 << 13, // 激光雷达组件,
38 | PM_TOF = 1 << 14, // TOF 组件
39 | PM_ULTRA = 1 << 15, // 超声波组件
40 | PM_ALL = 0xffffffff,
41 | PM_ALL_NO_MOTION = PM_ALL & (~PM_MOTION) & (~PM_MOTOR),
42 | PM_ALL_NO_TOF = PM_ALL & (~PM_TOF) & (~PM_MOTOR),
43 | PM_NO_MOTION_TOF = PM_ALL & (~PM_MOTION) & (~PM_TOF) & (~PM_MOTOR)
44 | };
45 |
46 | int PmRequest(unsigned int devs, unsigned int * err);
47 | int PmRelease(unsigned int devs, unsigned int * err);
48 | int PmQuery(unsigned int dev);
49 |
50 |
51 | enum PM_SYS
52 | {
53 | PM_SYS_SLEEP = 0,
54 | PM_SYS_REBOOT,
55 | PM_SYS_SHUTDOWN,
56 | };
57 |
58 | int PmSysRequest(int op);
59 |
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
65 |
66 | #endif // LOW_POWER_CONSUMPTION__PM_IF_H_
67 |
--------------------------------------------------------------------------------
/cyberdog_manager/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(cyberdog_manager)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic)
6 | endif()
7 |
8 | if(NOT CMAKE_C_STANDARD)
9 | set(CMAKE_C_STANDARD 99)
10 | endif()
11 |
12 | if(NOT CMAKE_CXX_STANDARD)
13 | set(CMAKE_CXX_STANDARD 17)
14 | endif()
15 |
16 | find_package(ament_cmake REQUIRED)
17 | find_package(rclcpp REQUIRED)
18 | find_package(rclcpp_action REQUIRED)
19 | find_package(manager_base REQUIRED)
20 | find_package(protocol REQUIRED)
21 | find_package(cyberdog_system REQUIRED)
22 | find_package(cyberdog_common REQUIRED)
23 | find_package(black_box REQUIRED)
24 | find_package(cyberdog_machine REQUIRED)
25 | find_package(std_srvs REQUIRED)
26 | find_package(protocol REQUIRED)
27 | find_package(low_power_consumption REQUIRED)
28 | find_package(ament_index_cpp REQUIRED)
29 | find_package(user_info_manager REQUIRED)
30 |
31 | include_directories(include)
32 |
33 | add_executable(${PROJECT_NAME} src/cyberdog_manager.cpp src/main.cpp)
34 |
35 | # MESSAGE('--------------${CMAKE_INSTALL_PREFIX}------------------')
36 |
37 | ament_target_dependencies( ${PROJECT_NAME}
38 | rclcpp
39 | rclcpp_action
40 | protocol
41 | manager_base
42 | cyberdog_system
43 | cyberdog_common
44 | black_box
45 | cyberdog_machine
46 | std_srvs
47 | protocol
48 | low_power_consumption
49 | ament_index_cpp
50 | user_info_manager )
51 |
52 | install(TARGETS ${PROJECT_NAME}
53 | DESTINATION lib/${PROJECT_NAME})
54 |
55 | if(BUILD_TESTING)
56 | find_package(ament_lint_auto REQUIRED)
57 | # the following line skips the linter which checks for copyrights
58 | # uncomment the line when a copyright and license is not present in all source files
59 | #set(ament_cmake_copyright_FOUND TRUE)
60 | # the following line skips cpplint (only works in a git repo)
61 | # uncomment the line when this package is not in a git repo
62 | #set(ament_cmake_cpplint_FOUND TRUE)
63 | ament_lint_auto_find_test_dependencies()
64 | endif()
65 |
66 |
67 | ament_package()
68 |
--------------------------------------------------------------------------------
/cyberdog_permissions/include/cyberdog_permission/cyberdog_permission.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #ifndef CYBERDOG_PERMISSION__CYBERDOG_PERMISSION_HPP_
15 | #define CYBERDOG_PERMISSION__CYBERDOG_PERMISSION_HPP_
16 | #include
17 | #include
18 | #include "rclcpp/rclcpp.hpp"
19 | #include "cyberdog_permission/board_info.hpp"
20 | #include "std_srvs/srv/trigger.hpp"
21 | #include "std_msgs/msg/string.hpp"
22 |
23 | #define NODE_NAME "cyberdog_permission"
24 |
25 | namespace cyberdog
26 | {
27 | namespace manager
28 | {
29 | class CyberdogPermission final : public rclcpp::Node
30 | {
31 | public:
32 | CyberdogPermission();
33 |
34 | private:
35 | void SnCallback(
36 | const std_srvs::srv::Trigger::Request::SharedPtr request,
37 | std_srvs::srv::Trigger::Response::SharedPtr response);
38 |
39 | void RealsenseRecovery(
40 | const std_srvs::srv::Trigger::Request::SharedPtr request,
41 | std_srvs::srv::Trigger::Response::SharedPtr response);
42 |
43 | private:
44 | bool Shell(const std::string & _command, int & _code, std::string & _message);
45 |
46 | private:
47 | std::string cyberdog_sn;
48 | // std::thread sn_thread;
49 | rclcpp::CallbackGroup::SharedPtr callback_group_;
50 | rclcpp::Service::SharedPtr sn_srv_;
51 | rclcpp::Service::SharedPtr realsense_recovery_srv_;
52 | rclcpp::Publisher::SharedPtr sn_pub_;
53 | }; // class CyberdogPermission
54 | } // namespace manager
55 | } // namespace cyberdog
56 |
57 | #endif // CYBERDOG_PERMISSION__CYBERDOG_PERMISSION_HPP_
58 |
--------------------------------------------------------------------------------
/black_box/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.8)
2 | project(black_box)
3 |
4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5 | add_compile_options(-Wall -Wextra -Wpedantic)
6 | endif()
7 |
8 | if(NOT CMAKE_C_STANDARD)
9 | set(CMAKE_C_STANDARD 99)
10 | endif()
11 |
12 | if(NOT CMAKE_CXX_STANDARD)
13 | set(CMAKE_CXX_STANDARD 17)
14 | endif()
15 |
16 | # find dependencies
17 | find_package(Boost COMPONENTS system filesystem REQUIRED)
18 | find_package(ament_cmake REQUIRED)
19 | find_package(rclcpp REQUIRED)
20 | find_package(protocol REQUIRED)
21 | find_package(sqlite3_vendor REQUIRED)
22 | find_package(SQLite3 REQUIRED)
23 | find_package(cyberdog_common REQUIRED)
24 | find_package(params REQUIRED)
25 | # uncomment the following section in order to fill in
26 | # further dependencies manually.
27 | # find_package( REQUIRED)
28 |
29 | include_directories(include)
30 |
31 | add_library(black_box SHARED src/black_box.cpp)
32 | target_link_libraries(black_box ${SQLite3_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY})
33 | ament_target_dependencies(black_box rclcpp protocol cyberdog_common params)
34 | ament_target_dependencies(black_box rclcpp cyberdog_common params)
35 | # target_include_directories(black_box
36 | # PUBLIC
37 | # $
38 | # $)
39 |
40 | add_executable(test_black_box src/test_black_box.cpp)
41 | target_link_libraries(test_black_box black_box)
42 | ament_target_dependencies(test_black_box rclcpp)
43 | # target_include_directories(test_black_box
44 | # PUBLIC
45 | # $
46 | # $)
47 |
48 | if(BUILD_TESTING)
49 | find_package(ament_lint_auto REQUIRED)
50 | ament_lint_auto_find_test_dependencies()
51 | endif()
52 |
53 | install(DIRECTORY
54 | include/
55 | DESTINATION include)
56 |
57 | install(TARGETS black_box test_black_box
58 | LIBRARY DESTINATION lib
59 | RUNTIME DESTINATION lib/${PROJECT_NAME}
60 | )
61 | ament_export_include_directories(include)
62 | ament_export_dependencies(sqlite3_vendor SQLite3 cyberdog_common)
63 | ament_export_libraries(black_box)
64 | ament_package()
65 |
--------------------------------------------------------------------------------
/low_power_consumption/include/low_power_consumption/power_consumption_manager.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef LOW_POWER_CONSUMPTION__POWER_CONSUMPTION_MANAGER_HPP_
16 | #define LOW_POWER_CONSUMPTION__POWER_CONSUMPTION_MANAGER_HPP_
17 |
18 | #include
19 | #include
20 | #include "rclcpp/rclcpp.hpp"
21 | #include "protocol/msg/motion_status.hpp"
22 | #include "low_power_consumption/low_power_consumption.hpp"
23 | #include "cyberdog_common/cyberdog_log.hpp"
24 |
25 | namespace cyberdog
26 | {
27 | namespace manager
28 | {
29 | class PowerConsumptionManager
30 | {
31 | public:
32 | explicit PowerConsumptionManager(const std::string & name);
33 | ~PowerConsumptionManager();
34 |
35 | bool low_power_consumption_set();
36 | bool nomal_power_consumption_set();
37 |
38 | bool Init();
39 | void Run();
40 |
41 | private:
42 | void sub_mostion_status_callback(const protocol::msg::MotionStatus msg);
43 | bool send_power_manager_request(const bool msg);
44 | void EnterLowPower(
45 | const std_srvs::srv::SetBool::Request::SharedPtr request,
46 | std_srvs::srv::SetBool::Response::SharedPtr response);
47 | rclcpp::Node::SharedPtr node_sub_motion_ptr_ {nullptr};
48 | rclcpp::Node::SharedPtr node_power_consump_ptr_ {nullptr};
49 | rclcpp::Subscription::SharedPtr motion_status_sub_ {nullptr};
50 | rclcpp::Client::SharedPtr power_comsumption_client_ {nullptr};
51 | rclcpp::Service::SharedPtr power_consumption_manager_srv_ {nullptr};
52 | std::unique_ptr lpc_ptr_ {nullptr};
53 | rclcpp::executors::MultiThreadedExecutor executor_;
54 | }; // class PowerConsumptionManager
55 |
56 | } // namespace manager
57 | } // namespace cyberdog
58 |
59 | #endif // LOW_POWER_CONSUMPTION__POWER_CONSUMPTION_MANAGER_HPP_
60 |
--------------------------------------------------------------------------------
/cyberdog_manager/include/cyberdog_manager/cyberdog_manager.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 Beijing Xiaomi Mobile Software Co., Ltd. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #ifndef CYBERDOG_MANAGER__CYBERDOG_MANAGER_HPP_
15 | #define CYBERDOG_MANAGER__CYBERDOG_MANAGER_HPP_
16 | #include
17 | #include