Skip to content

Commit 55342bd

Browse files
Fix style
1 parent becb1fc commit 55342bd

24 files changed

+2155
-2644
lines changed
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#ifndef ROS_INIT_HH
2-
# define ROS_INIT_HH
3-
# include <ros/ros.h>
2+
#define ROS_INIT_HH
3+
#include <ros/ros.h>
44

5-
namespace dynamicgraph
6-
{
7-
ros::NodeHandle& rosInit (bool createAsyncSpinner=false, bool createMultiThreadSpinner=true);
5+
namespace dynamicgraph {
6+
ros::NodeHandle& rosInit(bool createAsyncSpinner = false,
7+
bool createMultiThreadSpinner = true);
88

9-
/// \brief Return spinner or throw an exception if spinner
10-
/// creation has been disabled at startup.
11-
ros::AsyncSpinner& spinner ();
9+
/// \brief Return spinner or throw an exception if spinner
10+
/// creation has been disabled at startup.
11+
ros::AsyncSpinner& spinner();
1212

13-
/// \brief Return multi threaded spinner or throw an exception if spinner
14-
/// creation has been disabled at startup.
15-
ros::MultiThreadedSpinner& mtSpinner ();
13+
/// \brief Return multi threaded spinner or throw an exception if spinner
14+
/// creation has been disabled at startup.
15+
ros::MultiThreadedSpinner& mtSpinner();
1616

17+
} // end of namespace dynamicgraph.
1718

18-
} // end of namespace dynamicgraph.
19-
20-
#endif //! ROS_INIT_HH
19+
#endif //! ROS_INIT_HH
Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,59 @@
11
#ifndef DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
2-
# define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
3-
# include <ros/ros.h>
4-
# include <dynamic_graph_bridge_msgs/RunCommand.h>
5-
# include <dynamic_graph_bridge_msgs/RunPythonFile.h>
6-
# include <dynamic-graph/python/interpreter.hh>
7-
8-
namespace dynamicgraph
9-
{
10-
/// \brief This class wraps the implementation of the runCommand
11-
/// service.
12-
///
13-
/// This takes as input a ROS node handle and do not handle the
14-
/// callback so that the service behavior can be controlled from
15-
/// the outside.
16-
class Interpreter
17-
{
18-
public:
19-
typedef boost::function<
20-
bool (dynamic_graph_bridge_msgs::RunCommand::Request&,
21-
dynamic_graph_bridge_msgs::RunCommand::Response&)>
22-
runCommandCallback_t;
23-
24-
typedef boost::function<
25-
bool (dynamic_graph_bridge_msgs::RunPythonFile::Request&,
26-
dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
27-
runPythonFileCallback_t;
28-
29-
explicit Interpreter (ros::NodeHandle& nodeHandle);
30-
31-
/// \brief Method to start python interpreter and deal with messages.
32-
/// \param Command string to execute, result, stdout, stderr strings.
33-
void runCommand(const std::string & command, std::string &result,
34-
std::string &out, std::string &err);
35-
36-
/// \brief Method to parse python scripts.
37-
/// \param Input file name to parse.
38-
void runPythonFile(std::string ifilename);
39-
40-
/// Initialize service run_command
41-
void startRosService ();
42-
43-
protected:
44-
/// \brief Run a Python command and return result, stderr and stdout.
45-
bool runCommandCallback (dynamic_graph_bridge_msgs::RunCommand::Request& req,
46-
dynamic_graph_bridge_msgs::RunCommand::Response& res);
47-
48-
/// \brief Run a Python file.
49-
bool runPythonFileCallback (dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
50-
dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
51-
52-
private:
53-
python::Interpreter interpreter_;
54-
ros::NodeHandle& nodeHandle_;
55-
ros::ServiceServer runCommandSrv_;
56-
ros::ServiceServer runPythonFileSrv_;
57-
};
58-
} // end of namespace dynamicgraph.
59-
60-
#endif //! DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
2+
#define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
3+
#include <ros/ros.h>
4+
#include <dynamic_graph_bridge_msgs/RunCommand.h>
5+
#include <dynamic_graph_bridge_msgs/RunPythonFile.h>
6+
#include <dynamic-graph/python/interpreter.hh>
7+
8+
namespace dynamicgraph {
9+
/// \brief This class wraps the implementation of the runCommand
10+
/// service.
11+
///
12+
/// This takes as input a ROS node handle and do not handle the
13+
/// callback so that the service behavior can be controlled from
14+
/// the outside.
15+
class Interpreter {
16+
public:
17+
typedef boost::function<bool(
18+
dynamic_graph_bridge_msgs::RunCommand::Request&,
19+
dynamic_graph_bridge_msgs::RunCommand::Response&)>
20+
runCommandCallback_t;
21+
22+
typedef boost::function<bool(
23+
dynamic_graph_bridge_msgs::RunPythonFile::Request&,
24+
dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
25+
runPythonFileCallback_t;
26+
27+
explicit Interpreter(ros::NodeHandle& nodeHandle);
28+
29+
/// \brief Method to start python interpreter and deal with messages.
30+
/// \param Command string to execute, result, stdout, stderr strings.
31+
void runCommand(const std::string& command, std::string& result,
32+
std::string& out, std::string& err);
33+
34+
/// \brief Method to parse python scripts.
35+
/// \param Input file name to parse.
36+
void runPythonFile(std::string ifilename);
37+
38+
/// Initialize service run_command
39+
void startRosService();
40+
41+
protected:
42+
/// \brief Run a Python command and return result, stderr and stdout.
43+
bool runCommandCallback(dynamic_graph_bridge_msgs::RunCommand::Request& req,
44+
dynamic_graph_bridge_msgs::RunCommand::Response& res);
45+
46+
/// \brief Run a Python file.
47+
bool runPythonFileCallback(
48+
dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
49+
dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
50+
51+
private:
52+
python::Interpreter interpreter_;
53+
ros::NodeHandle& nodeHandle_;
54+
ros::ServiceServer runCommandSrv_;
55+
ros::ServiceServer runPythonFileSrv_;
56+
};
57+
} // end of namespace dynamicgraph.
58+
59+
#endif //! DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH

include/dynamic_graph_bridge/sot_loader.hh

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <sensor_msgs/JointState.h>
4242
#include <tf/transform_broadcaster.h>
4343

44-
// Sot Framework includes
44+
// Sot Framework includes
4545
#include <sot/core/debug.hh>
4646
#include <sot/core/abstract-sot-external-interface.hh>
4747

@@ -51,20 +51,15 @@
5151
namespace po = boost::program_options;
5252
namespace dgs = dynamicgraph::sot;
5353

54-
55-
class SotLoader: public SotLoaderBasic
56-
{
57-
58-
protected:
59-
60-
54+
class SotLoader : public SotLoaderBasic {
55+
protected:
6156
/// Map of sensor readings
62-
std::map <std::string,dgs::SensorValues> sensorsIn_;
57+
std::map<std::string, dgs::SensorValues> sensorsIn_;
6358
/// Map of control values
64-
std::map<std::string,dgs::ControlValues> controlValues_;
59+
std::map<std::string, dgs::ControlValues> controlValues_;
6560

6661
/// Angular values read by encoders
67-
std::vector <double> angleEncoder_;
62+
std::vector<double> angleEncoder_;
6863
/// Angular values sent to motors
6964
std::vector<double> angleControl_;
7065
/// Forces read by force sensors
@@ -74,26 +69,24 @@ protected:
7469
/// Attitude of the robot computed by extended Kalman filter.
7570
std::vector<double> baseAtt_;
7671
/// Accelerations read by Accelerometers
77-
std::vector <double> accelerometer_;
72+
std::vector<double> accelerometer_;
7873
/// Angular velocity read by gyrometers
79-
std::vector <double> gyrometer_;
74+
std::vector<double> gyrometer_;
8075

8176
/// URDF string description of the robot.
8277
std::string robot_desc_string_;
83-
8478

8579
/// The thread running dynamic graph
8680
boost::thread thread_;
87-
81+
8882
// \brief Start control loop
8983
virtual void startControlLoop();
9084

91-
92-
//Robot Pose Publisher
85+
// Robot Pose Publisher
9386
tf::TransformBroadcaster freeFlyerPublisher_;
9487
tf::Transform freeFlyerPose_;
9588

96-
public:
89+
public:
9790
SotLoader();
9891
~SotLoader();
9992

@@ -105,17 +98,13 @@ public:
10598
void oneIteration();
10699

107100
// \brief Fill the sensors value for the SoT.
108-
void fillSensors(std::map<std::string,
109-
dgs::SensorValues> & sensorsIn);
101+
void fillSensors(std::map<std::string, dgs::SensorValues> &sensorsIn);
110102

111103
// \brief Read the control computed by the SoT framework.
112-
void readControl(std::map<std::string,
113-
dgs::ControlValues> & controlValues);
104+
void readControl(std::map<std::string, dgs::ControlValues> &controlValues);
114105

115106
// \brief Prepare the SoT framework.
116107
void setup();
117-
118-
119108
};
120109

121110
#endif /* SOT_LOADER_HH_ */

include/dynamic_graph_bridge/sot_loader_basic.hh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,26 @@
3939
#include "std_srvs/Empty.h"
4040
#include <sensor_msgs/JointState.h>
4141

42-
// Sot Framework includes
42+
// Sot Framework includes
4343
#include <sot/core/debug.hh>
4444
#include <sot/core/abstract-sot-external-interface.hh>
4545

4646
namespace po = boost::program_options;
4747
namespace dgs = dynamicgraph::sot;
4848

49-
5049
class SotLoaderBasic {
51-
protected:
52-
50+
protected:
5351
// Dynamic graph is stopped.
5452
bool dynamic_graph_stopped_;
5553

5654
/// \brief the sot-hrp2 controller
57-
dgs::AbstractSotExternalInterface * sotController_;
55+
dgs::AbstractSotExternalInterface* sotController_;
5856

5957
po::variables_map vm_;
6058
std::string dynamicLibraryName_;
6159

6260
/// \brief Handle on the SoT library.
63-
void * sotRobotControllerLibrary_;
61+
void* sotRobotControllerLibrary_;
6462

6563
/// \brief Map between SoT state vector and some joint_state_links
6664
XmlRpc::XmlRpcValue stateVectorMap_;
@@ -76,24 +74,23 @@ protected:
7674

7775
/// Advertises stop_dynamic_graph services
7876
ros::ServiceServer service_stop_;
79-
77+
8078
// Joint state publication.
8179
ros::Publisher joint_pub_;
82-
80+
8381
// Joint state to be published.
8482
sensor_msgs::JointState joint_state_;
8583

8684
// Number of DOFs according to KDL.
8785
int nbOfJoints_;
8886
parallel_joints_to_state_vector_t::size_type nbOfParallelJoints_;
8987

90-
91-
public:
88+
public:
9289
SotLoaderBasic();
93-
~SotLoaderBasic() {};
90+
~SotLoaderBasic(){};
9491

9592
// \brief Read user input to extract the path of the SoT dynamic library.
96-
int parseOptions(int argc, char *argv[]);
93+
int parseOptions(int argc, char* argv[]);
9794

9895
/// \brief Load the SoT device corresponding to the robot.
9996
void Initialization();
@@ -102,16 +99,15 @@ public:
10299
void CleanUp();
103100

104101
// \brief Create a thread for ROS.
105-
virtual void initializeRosNode(int argc, char *argv[]);
106-
102+
virtual void initializeRosNode(int argc, char* argv[]);
107103

108104
// \brief Callback function when starting dynamic graph.
109-
bool start_dg(std_srvs::Empty::Request& request,
105+
bool start_dg(std_srvs::Empty::Request& request,
110106
std_srvs::Empty::Response& response);
111107

112108
// \brief Callback function when stopping dynamic graph.
113-
bool stop_dg(std_srvs::Empty::Request& request,
114-
std_srvs::Empty::Response& response);
109+
bool stop_dg(std_srvs::Empty::Request& request,
110+
std_srvs::Empty::Response& response);
115111

116112
// \brief Read the state vector description based upon the robot links.
117113
int readSotVectorStateParam();
@@ -120,13 +116,10 @@ public:
120116
int initPublication();
121117

122118
// \brief Get Status of dg.
123-
bool isDynamicGraphStopped()
124-
{ return dynamic_graph_stopped_; }
119+
bool isDynamicGraphStopped() { return dynamic_graph_stopped_; }
125120

126121
// \brief Specify the name of the dynamic library.
127-
void setDynamicLibraryName(std::string &afilename);
128-
129-
122+
void setDynamicLibraryName(std::string& afilename);
130123
};
131124

132125
#endif /* _SOT_LOADER_BASIC_HH_ */

0 commit comments

Comments
 (0)