Skip to content

Commit 0935ed7

Browse files
[pre-commit] Fix style to comply with clang Google format.
1 parent 68a0dc4 commit 0935ed7

34 files changed

+2130
-2525
lines changed

include/dynamic_graph_bridge/ros.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#include "rclcpp/rclcpp.hpp"
1616
#include "std_srvs/srv/empty.hpp"
1717

18-
namespace dynamic_graph_bridge
19-
{
18+
namespace dynamic_graph_bridge {
2019
const std::string DG_ROS_NODE_NAME = "dynamic_graph";
2120
const std::string HWC_ROS_NODE_NAME = "hardware_communication";
2221

@@ -29,7 +28,8 @@ typedef rclcpp::executors::MultiThreadedExecutor RosExecutor;
2928
typedef std::shared_ptr<RosExecutor> RosExecutorPtr;
3029

3130
// Python commands shortcuts
32-
typedef dynamic_graph_bridge_msgs::srv::RunPythonCommand RunPythonCommandSrvType;
31+
typedef dynamic_graph_bridge_msgs::srv::RunPythonCommand
32+
RunPythonCommandSrvType;
3333
typedef rclcpp::Service<RunPythonCommandSrvType>::SharedPtr
3434
RunPythonCommandServerPtr;
3535
typedef rclcpp::Client<RunPythonCommandSrvType>::SharedPtr

include/dynamic_graph_bridge/ros_parameter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "rclcpp/node.hpp"
55
namespace dynamicgraph {
66

7-
bool parameter_server_read_robot_description(rclcpp::Node::SharedPtr nh);
7+
bool parameter_server_read_robot_description(rclcpp::Node::SharedPtr nh);
88

99
}
1010
#endif /* _ROS_DYNAMIC_GRAPH_PARAMETER_ */

include/dynamic_graph_bridge/ros_python_interpreter_client.hpp

Lines changed: 114 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -12,141 +12,124 @@
1212

1313
#include "dynamic_graph_bridge/ros.hpp"
1414

15-
namespace dynamic_graph_bridge
16-
{
15+
namespace dynamic_graph_bridge {
1716
/**
1817
* @brief Client of the RosPythonInterpreterServer through rosservices.
1918
*/
20-
class RosPythonInterpreterClient
21-
{
22-
public:
23-
/**
24-
* @brief Construct a new RosPythonInterpreterClient object.
25-
*/
26-
RosPythonInterpreterClient();
27-
28-
/**
29-
* @brief Destroy the RosPythonInterpreterClient object.
30-
*/
31-
~RosPythonInterpreterClient()
32-
{
19+
class RosPythonInterpreterClient {
20+
public:
21+
/**
22+
* @brief Construct a new RosPythonInterpreterClient object.
23+
*/
24+
RosPythonInterpreterClient();
25+
26+
/**
27+
* @brief Destroy the RosPythonInterpreterClient object.
28+
*/
29+
~RosPythonInterpreterClient() {}
30+
31+
/**
32+
* @brief Call the rosservice of the current running DynamicGraphManager.
33+
*
34+
* @param code_string To be executed in the embeded python interpreter.
35+
* @return std::string
36+
*/
37+
std::string run_python_command(const std::string& code_string);
38+
39+
/**
40+
* @brief Call the rosservice of the current running DynamicGraphManager.
41+
*
42+
* @param filename
43+
*/
44+
std::string run_python_script(const std::string& filename);
45+
46+
private:
47+
/**
48+
* @brief Connect to a designated service.
49+
*
50+
* @tparam RosServiceType
51+
* @param service_name
52+
* @param client
53+
* @param timeout
54+
*/
55+
template <typename RosServiceType>
56+
typename rclcpp::Client<RosServiceType>::SharedPtr connect_to_rosservice(
57+
const std::string& service_name, const DurationSec& timeout) {
58+
typename rclcpp::Client<RosServiceType>::SharedPtr client;
59+
try {
60+
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
61+
"Waiting for service %s ...", service_name.c_str());
62+
// let use wait for the existance of the services
63+
client = ros_node_->create_client<RosServiceType>(service_name.c_str());
64+
if (client->wait_for_service(timeout)) {
65+
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
66+
"Successfully connected to %s", service_name.c_str());
67+
} else {
68+
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
69+
"Failed to connect to %s", service_name.c_str());
70+
}
71+
} catch (...) {
72+
throw std::runtime_error(service_name + " not available.");
3373
}
34-
35-
/**
36-
* @brief Call the rosservice of the current running DynamicGraphManager.
37-
*
38-
* @param code_string To be executed in the embeded python interpreter.
39-
* @return std::string
40-
*/
41-
std::string run_python_command(const std::string& code_string);
42-
43-
/**
44-
* @brief Call the rosservice of the current running DynamicGraphManager.
45-
*
46-
* @param filename
47-
*/
48-
std::string run_python_script(const std::string& filename);
49-
50-
private:
51-
/**
52-
* @brief Connect to a designated service.
53-
*
54-
* @tparam RosServiceType
55-
* @param service_name
56-
* @param client
57-
* @param timeout
58-
*/
59-
template <typename RosServiceType>
60-
typename rclcpp::Client<RosServiceType>::SharedPtr connect_to_rosservice(
61-
const std::string& service_name, const DurationSec& timeout)
62-
{
63-
typename rclcpp::Client<RosServiceType>::SharedPtr client;
64-
try
65-
{
66-
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
67-
"Waiting for service %s ...",
68-
service_name.c_str());
69-
// let use wait for the existance of the services
70-
client =
71-
ros_node_->create_client<RosServiceType>(service_name.c_str());
72-
if (client->wait_for_service(timeout))
73-
{
74-
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
75-
"Successfully connected to %s",
76-
service_name.c_str());
77-
}
78-
else
79-
{
80-
RCLCPP_INFO(rclcpp::get_logger("RosPythonInterpreterClient"),
81-
"Failed to connect to %s",
82-
service_name.c_str());
83-
}
84-
}
85-
catch (...)
86-
{
87-
throw std::runtime_error(service_name + " not available.");
88-
}
89-
return client;
90-
}
91-
92-
/**
93-
* @brief Connects to the RunCommand rosservice.
94-
*
95-
* @param timeout [in]
96-
*/
97-
void connect_to_rosservice_run_python_command(
98-
const DurationSec& timeout = DurationSec(-1))
99-
{
100-
command_client_ = connect_to_rosservice<RunPythonCommandSrvType>(
101-
run_command_service_name_, timeout);
102-
}
103-
104-
/**
105-
* @brief Connects to the RunPythonFile rosservice.
106-
*
107-
* @param timeout [in]
108-
*/
109-
void connect_to_rosservice_run_python_script(
110-
const DurationSec& timeout = DurationSec(-1))
111-
{
112-
script_client_ = connect_to_rosservice<RunPythonFileSrvType>(
113-
run_script_service_name_, timeout);
114-
}
115-
116-
private:
117-
/**
118-
* @brief Name of the local ros_node;
119-
*/
120-
std::string ros_node_name_;
121-
122-
/** @brief Handle for manipulating ROS objects. */
123-
RosNodePtr ros_node_;
124-
125-
/** @brief Name of the DynamicGraphManager RosPythonInterpreterServer
126-
* rosservice for running a python command. */
127-
std::string run_command_service_name_;
128-
129-
/** @brief Rosservice to run a python command.
130-
* @see run_command_service_name_ */
131-
RunPythonCommandClientPtr command_client_;
132-
133-
/** @brief Input of the rosservice. */
134-
RunPythonCommandRequestPtr run_command_request_;
135-
136-
/** @brief Name of the DynamicGraphManager RosPythonInterpreterServer
137-
* rosservice for running a python script. */
138-
std::string run_script_service_name_;
139-
140-
/** @brief Rosservice to run a python script.
141-
* @see run_command_service_name_ */
142-
RunPythonFileClientPtr script_client_;
143-
144-
/** @brief Input of the rosservice. */
145-
RunPythonFileRequestPtr run_file_request_;
146-
147-
/** @brief timeout used during the connection to the rosservices in
148-
* seconds. */
149-
DurationSec timeout_connection_s_;
74+
return client;
75+
}
76+
77+
/**
78+
* @brief Connects to the RunCommand rosservice.
79+
*
80+
* @param timeout [in]
81+
*/
82+
void connect_to_rosservice_run_python_command(
83+
const DurationSec& timeout = DurationSec(-1)) {
84+
command_client_ = connect_to_rosservice<RunPythonCommandSrvType>(
85+
run_command_service_name_, timeout);
86+
}
87+
88+
/**
89+
* @brief Connects to the RunPythonFile rosservice.
90+
*
91+
* @param timeout [in]
92+
*/
93+
void connect_to_rosservice_run_python_script(
94+
const DurationSec& timeout = DurationSec(-1)) {
95+
script_client_ = connect_to_rosservice<RunPythonFileSrvType>(
96+
run_script_service_name_, timeout);
97+
}
98+
99+
private:
100+
/**
101+
* @brief Name of the local ros_node;
102+
*/
103+
std::string ros_node_name_;
104+
105+
/** @brief Handle for manipulating ROS objects. */
106+
RosNodePtr ros_node_;
107+
108+
/** @brief Name of the DynamicGraphManager RosPythonInterpreterServer
109+
* rosservice for running a python command. */
110+
std::string run_command_service_name_;
111+
112+
/** @brief Rosservice to run a python command.
113+
* @see run_command_service_name_ */
114+
RunPythonCommandClientPtr command_client_;
115+
116+
/** @brief Input of the rosservice. */
117+
RunPythonCommandRequestPtr run_command_request_;
118+
119+
/** @brief Name of the DynamicGraphManager RosPythonInterpreterServer
120+
* rosservice for running a python script. */
121+
std::string run_script_service_name_;
122+
123+
/** @brief Rosservice to run a python script.
124+
* @see run_command_service_name_ */
125+
RunPythonFileClientPtr script_client_;
126+
127+
/** @brief Input of the rosservice. */
128+
RunPythonFileRequestPtr run_file_request_;
129+
130+
/** @brief timeout used during the connection to the rosservices in
131+
* seconds. */
132+
DurationSec timeout_connection_s_;
150133
};
151134

152135
} // namespace dynamic_graph_bridge

0 commit comments

Comments
 (0)