Skip to content

Commit 7410719

Browse files
committed
Merge branch 'master' of github.com:ichiro-its/suiryoku into feature/adjust-function-for-dynamic-kick
2 parents bef5814 + 8c7f8e2 commit 7410719

File tree

8 files changed

+258
-287
lines changed

8 files changed

+258
-287
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ find_package(ament_index_cpp REQUIRED)
1818
find_package(aruku REQUIRED)
1919
find_package(aruku_interfaces REQUIRED)
2020
find_package(atama_interfaces REQUIRED)
21+
find_package(jitsuyo REQUIRED)
2122
find_package(kansei REQUIRED)
2223
find_package(kansei_interfaces REQUIRED)
2324
find_package(keisan REQUIRED)
@@ -31,7 +32,6 @@ include_directories(${EIGEN3_INCLUDE_DIRS})
3132

3233
add_library(${PROJECT_NAME} SHARED
3334
"src/${PROJECT_NAME}/config/node/config_node.cpp"
34-
"src/${PROJECT_NAME}/config/utils/config.cpp"
3535
"src/${PROJECT_NAME}/locomotion/control/helper/parameter.cpp"
3636
"src/${PROJECT_NAME}/locomotion/control/node/control_node.cpp"
3737
"src/${PROJECT_NAME}/locomotion/model/robot.cpp"
@@ -47,6 +47,7 @@ ament_target_dependencies(${PROJECT_NAME}
4747
aruku
4848
aruku_interfaces
4949
atama_interfaces
50+
jitsuyo
5051
kansei
5152
kansei_interfaces
5253
keisan
@@ -111,6 +112,7 @@ ament_export_dependencies(
111112
aruku
112113
aruku_interfaces
113114
atama_interfaces
115+
jitsuyo
114116
kansei
115117
kansei_interfaces
116118
keisan

include/suiryoku/config/config.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#ifndef SUIRYOKU__CONFIG__CONFIG_HPP_
2222
#define SUIRYOKU__CONFIG__CONFIG_HPP_
2323

24-
#include "suiryoku/config/utils/config.hpp"
2524
#include "suiryoku/config/node/config_node.hpp"
2625

2726
#endif // SUIRYOKU__CONFIG__CONFIG_HPP_

include/suiryoku/config/node/config_node.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <string>
2626

2727
#include "rclcpp/rclcpp.hpp"
28-
#include "suiryoku/config/utils/config.hpp"
2928
#include "suiryoku_interfaces/msg/set_config.hpp"
3029
#include "suiryoku_interfaces/srv/get_config.hpp"
3130
#include "suiryoku_interfaces/srv/save_config.hpp"
@@ -48,7 +47,6 @@ class ConfigNode
4847
private:
4948
std::string get_node_prefix() const;
5049

51-
Config config;
5250
rclcpp::Node::SharedPtr node;
5351

5452
rclcpp::Service<GetConfig>::SharedPtr get_config_server;

include/suiryoku/config/utils/config.hpp

-47
This file was deleted.

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<depend>aruku</depend>
1212
<depend>aruku_interfaces</depend>
1313
<depend>atama_interfaces</depend>
14+
<depend>jitsuyo</depend>
1415
<depend>kansei</depend>
1516
<depend>kansei_interfaces</depend>
1617
<depend>keisan</depend>

src/suiryoku/config/node/config_node.cpp

+10-17
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,31 @@
2323
#include <string>
2424

2525
#include "suiryoku/config/node/config_node.hpp"
26+
#include "jitsuyo/config.hpp"
2627

2728
#include "nlohmann/json.hpp"
2829
#include "rclcpp/rclcpp.hpp"
29-
#include "suiryoku/config/utils/config.hpp"
3030

3131
namespace suiryoku
3232
{
3333

3434
ConfigNode::ConfigNode(rclcpp::Node::SharedPtr node, const std::string & path)
35-
: node(node), config(path), set_config_subscriber(nullptr)
35+
: node(node), set_config_subscriber(nullptr)
3636
{
3737
get_config_server = node->create_service<GetConfig>(
3838
get_node_prefix() + "/get_config",
39-
[this](GetConfig::Request::SharedPtr request, GetConfig::Response::SharedPtr response) {
40-
response->json = this->config.get_config();
39+
[this, path](GetConfig::Request::SharedPtr request, GetConfig::Response::SharedPtr response) {
40+
nlohmann::json data;
41+
if (!jitsuyo::load_config(path, "/head.json", data)) {
42+
return;
43+
}
44+
response->json = data.dump();
4145
});
4246

4347
save_config_server = node->create_service<SaveConfig>(
4448
get_node_prefix() + "/save_config",
45-
[this](SaveConfig::Request::SharedPtr request, SaveConfig::Response::SharedPtr response) {
46-
try {
47-
nlohmann::json data = nlohmann::json::parse(request->json);
48-
49-
this->config.save_config(data);
50-
response->status = true;
51-
} catch (std::ofstream::failure) {
52-
// TODO(maroqijalil): log it
53-
response->status = false;
54-
} catch (nlohmann::json::exception) {
55-
// TODO(maroqijalil): log it
56-
response->status = false;
57-
}
49+
[this, path](SaveConfig::Request::SharedPtr request, SaveConfig::Response::SharedPtr response) {
50+
response->status = jitsuyo::save_config(path, "locomotion.json", nlohmann::json::parse(request->json));
5851
});
5952
}
6053

src/suiryoku/config/utils/config.cpp

-53
This file was deleted.

0 commit comments

Comments
 (0)