Skip to content

Commit 3dd6eee

Browse files
committed
format
1 parent 4f61ade commit 3dd6eee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+694
-548
lines changed

CMakeLists.txt

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,99 @@
33
# Author: Florent Lamiraux, Nirmal Giftsun, Guilhem Saurel
44
#
55

6-
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
6+
cmake_minimum_required(VERSION 3.1)
77

88
# Project properties
9-
SET(PROJECT_ORG stack-of-tasks)
10-
SET(PROJECT_NAME dynamic_graph_bridge)
11-
SET(PROJECT_DESCRIPTION "Dynamic graph bridge library")
12-
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
9+
set(PROJECT_ORG stack-of-tasks)
10+
set(PROJECT_NAME dynamic_graph_bridge)
11+
set(PROJECT_DESCRIPTION "Dynamic graph bridge library")
12+
set(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
1313

1414
# Project options
15-
OPTION(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
15+
option(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
1616

1717
# Project configuration
18-
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
19-
SET(CUSTOM_HEADER_DIR ${PROJECT_NAME})
18+
set(PROJECT_USE_CMAKE_EXPORT TRUE)
19+
set(CUSTOM_HEADER_DIR ${PROJECT_NAME})
2020
set(CXX_DISABLE_WERROR FALSE)
21-
SET(DOXYGEN_USE_MATHJAX YES)
22-
SET(CATKIN_ENABLE_TESTING OFF)
21+
set(DOXYGEN_USE_MATHJAX YES)
22+
set(CATKIN_ENABLE_TESTING OFF)
2323

2424
# JRL-cmakemodule setup
25-
INCLUDE(cmake/base.cmake)
26-
INCLUDE(cmake/boost.cmake)
27-
INCLUDE(cmake/ros.cmake)
25+
include(cmake/base.cmake)
26+
include(cmake/boost.cmake)
27+
include(cmake/ros.cmake)
2828

2929
# Project definition
30-
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
31-
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
30+
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
31+
project(${PROJECT_NAME} ${PROJECT_ARGS})
3232

3333
# Project dependencies
34-
SET(CATKIN_REQUIRED_COMPONENTS roscpp std_msgs message_generation std_srvs geometry_msgs sensor_msgs tf2_ros
34+
set(CATKIN_REQUIRED_COMPONENTS
35+
roscpp
36+
std_msgs
37+
message_generation
38+
std_srvs
39+
geometry_msgs
40+
sensor_msgs
41+
tf2_ros
3542
realtime_tools)
3643

37-
IF(BUILD_PYTHON_INTERFACE)
38-
ADD_PROJECT_DEPENDENCY(dynamic-graph-python 4.0.0 REQUIRED)
39-
STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
40-
SET(CATKIN_REQUIRED_COMPONENTS ${CATKIN_REQUIRED_COMPONENTS} rospy)
41-
ENDIF(BUILD_PYTHON_INTERFACE)
44+
if(BUILD_PYTHON_INTERFACE)
45+
add_project_dependency(dynamic-graph-python 4.0.0 REQUIRED)
46+
string(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
47+
set(CATKIN_REQUIRED_COMPONENTS ${CATKIN_REQUIRED_COMPONENTS} rospy)
48+
endif(BUILD_PYTHON_INTERFACE)
4249

43-
ADD_PROJECT_DEPENDENCY(Boost REQUIRED COMPONENTS program_options)
44-
ADD_PROJECT_DEPENDENCY(dynamic_graph_bridge_msgs 0.3.0 REQUIRED)
45-
ADD_PROJECT_DEPENDENCY(sot-core REQUIRED)
50+
add_project_dependency(Boost REQUIRED COMPONENTS program_options)
51+
add_project_dependency(dynamic_graph_bridge_msgs 0.3.0 REQUIRED)
52+
add_project_dependency(sot-core REQUIRED)
4653

47-
IF(Boost_VERSION GREATER 107299 OR Boost_VERSION_MACRO GREATER 107299)
54+
if(Boost_VERSION GREATER 107299 OR Boost_VERSION_MACRO GREATER 107299)
4855
# Silence a warning about a deprecated use of boost bind by boost >= 1.73
4956
# without dropping support for boost < 1.73
50-
ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
51-
ENDIF()
57+
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
58+
endif()
5259

5360
find_package(catkin REQUIRED COMPONENTS ${CATKIN_REQUIRED_COMPONENTS})
5461

5562
# Main Library
5663
set(${PROJECT_NAME}_HEADERS
57-
include/${PROJECT_NAME}/fwd.hh
58-
include/${PROJECT_NAME}/ros_init.hh
59-
include/${PROJECT_NAME}/sot_loader.hh
60-
include/${PROJECT_NAME}/sot_loader_basic.hh
61-
include/${PROJECT_NAME}/ros_interpreter.hh
62-
src/converter.hh
63-
src/sot_to_ros.hh
64-
)
65-
66-
SET(${PROJECT_NAME}_SOURCES
67-
src/ros_init.cpp
68-
src/sot_to_ros.cpp
69-
src/ros_parameter.cpp
70-
)
71-
72-
ADD_LIBRARY(ros_bridge SHARED
73-
${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
74-
TARGET_INCLUDE_DIRECTORIES(ros_bridge SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
75-
TARGET_INCLUDE_DIRECTORIES(ros_bridge PUBLIC $<INSTALL_INTERFACE:include>)
76-
TARGET_LINK_LIBRARIES(ros_bridge ${catkin_LIBRARIES}
77-
sot-core::sot-core pinocchio::pinocchio)
78-
79-
IF(SUFFIX_SO_VERSION)
80-
SET_TARGET_PROPERTIES(ros_bridge PROPERTIES SOVERSION ${PROJECT_VERSION})
81-
ENDIF(SUFFIX_SO_VERSION)
82-
83-
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
84-
INSTALL(TARGETS ros_bridge EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
85-
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
64+
include/${PROJECT_NAME}/fwd.hh
65+
include/${PROJECT_NAME}/ros_init.hh
66+
include/${PROJECT_NAME}/sot_loader.hh
67+
include/${PROJECT_NAME}/sot_loader_basic.hh
68+
include/${PROJECT_NAME}/ros_interpreter.hh
69+
src/converter.hh
70+
src/sot_to_ros.hh)
71+
72+
set(${PROJECT_NAME}_SOURCES src/ros_init.cpp src/sot_to_ros.cpp
73+
src/ros_parameter.cpp)
74+
75+
add_library(ros_bridge SHARED ${${PROJECT_NAME}_SOURCES}
76+
${${PROJECT_NAME}_HEADERS})
77+
target_include_directories(ros_bridge SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
78+
target_include_directories(ros_bridge PUBLIC $<INSTALL_INTERFACE:include>)
79+
target_link_libraries(ros_bridge ${catkin_LIBRARIES} sot-core::sot-core
80+
pinocchio::pinocchio)
81+
82+
if(SUFFIX_SO_VERSION)
83+
set_target_properties(ros_bridge PROPERTIES SOVERSION ${PROJECT_VERSION})
84+
endif(SUFFIX_SO_VERSION)
85+
86+
if(NOT INSTALL_PYTHON_INTERFACE_ONLY)
87+
install(
88+
TARGETS ros_bridge
89+
EXPORT ${TARGETS_EXPORT_NAME}
90+
DESTINATION lib)
91+
endif(NOT INSTALL_PYTHON_INTERFACE_ONLY)
8692

8793
add_subdirectory(src)
8894
add_subdirectory(tests)
8995

90-
#install ros executables
91-
install(PROGRAMS
92-
scripts/robot_pose_publisher
93-
scripts/run_command
94-
scripts/tf_publisher
95-
DESTINATION share/${PROJECT_NAME}
96-
)
96+
# install ros executables
97+
install(PROGRAMS scripts/robot_pose_publisher scripts/run_command
98+
scripts/tf_publisher DESTINATION share/${PROJECT_NAME})
9799

98100
# Install package information
99101
install(FILES manifest.xml package.xml DESTINATION share/${PROJECT_NAME})

doc/Doxyfile.extra.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
INPUT = @PROJECT_SOURCE_DIR@/include \
22
@PROJECT_SOURCE_DIR@/doc
3-

include/dynamic_graph_bridge/fwd.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <dynamic-graph/python/fwd.hh>
1313

1414
namespace dynamicgraph {
15-
// classes defined in sot-core
16-
class Interpreter;
17-
typedef shared_ptr<Interpreter> InterpreterPtr_t;
18-
}// namespace dynamicgraph
15+
// classes defined in sot-core
16+
class Interpreter;
17+
typedef shared_ptr<Interpreter> InterpreterPtr_t;
18+
} // namespace dynamicgraph
1919

20-
#endif // DYNAMIC_GRAPH_PYTHON_FWD_HH
20+
#endif // DYNAMIC_GRAPH_PYTHON_FWD_HH

include/dynamic_graph_bridge/ros_init.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <ros/ros.h>
44

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

89
/// \brief Return spinner or throw an exception if spinner
910
/// creation has been disabled at startup.

include/dynamic_graph_bridge/ros_interpreter.hh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
#include <ros/ros.h>
66
#pragma GCC diagnostic pop
77

8-
#include <dynamic_graph_bridge/fwd.hh>
98
#include <dynamic_graph_bridge_msgs/RunCommand.h>
109
#include <dynamic_graph_bridge_msgs/RunPythonFile.h>
10+
1111
#include <dynamic-graph/python/interpreter.hh>
12+
#include <dynamic_graph_bridge/fwd.hh>
1213

1314
namespace dynamicgraph {
1415
/// \brief This class wraps the implementation of the runCommand
@@ -19,19 +20,22 @@ namespace dynamicgraph {
1920
/// the outside.
2021
class Interpreter {
2122
public:
22-
typedef boost::function<bool(dynamic_graph_bridge_msgs::RunCommand::Request&,
23-
dynamic_graph_bridge_msgs::RunCommand::Response&)>
23+
typedef boost::function<bool(
24+
dynamic_graph_bridge_msgs::RunCommand::Request&,
25+
dynamic_graph_bridge_msgs::RunCommand::Response&)>
2426
runCommandCallback_t;
2527

26-
typedef boost::function<bool(dynamic_graph_bridge_msgs::RunPythonFile::Request&,
27-
dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
28+
typedef boost::function<bool(
29+
dynamic_graph_bridge_msgs::RunPythonFile::Request&,
30+
dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
2831
runPythonFileCallback_t;
2932

3033
explicit Interpreter(ros::NodeHandle& nodeHandle);
3134

3235
/// \brief Method to start python interpreter and deal with messages.
3336
/// \param Command string to execute, result, stdout, stderr strings.
34-
void runCommand(const std::string& command, std::string& result, std::string& out, std::string& err);
37+
void runCommand(const std::string& command, std::string& result,
38+
std::string& out, std::string& err);
3539

3640
/// \brief Method to parse python scripts.
3741
/// \param Input file name to parse.
@@ -46,8 +50,9 @@ class Interpreter {
4650
dynamic_graph_bridge_msgs::RunCommand::Response& res);
4751

4852
/// \brief Run a Python file.
49-
bool runPythonFileCallback(dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
50-
dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
53+
bool runPythonFileCallback(
54+
dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
55+
dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
5156

5257
private:
5358
python::Interpreter interpreter_;

include/dynamic_graph_bridge/sot_loader.hh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@
2222
#include <pinocchio/fwd.hpp>
2323

2424
// Boost includes
25-
#include <boost/program_options.hpp>
2625
#include <boost/foreach.hpp>
2726
#include <boost/format.hpp>
27+
#include <boost/program_options.hpp>
2828
#include <boost/thread/thread.hpp>
2929

3030
// ROS includes
31-
#include "ros/ros.h"
32-
#include "std_srvs/Empty.h"
3331
#include <sensor_msgs/JointState.h>
3432
#include <tf2_ros/transform_broadcaster.h>
3533

34+
#include "ros/ros.h"
35+
#include "std_srvs/Empty.h"
36+
3637
// Sot Framework includes
37-
#include <sot/core/debug.hh>
3838
#include <sot/core/abstract-sot-external-interface.hh>
39+
#include <sot/core/debug.hh>
3940

4041
// Dynamic-graph-bridge includes.
4142
#include <dynamic_graph_bridge/sot_loader_basic.hh>

include/dynamic_graph_bridge/sot_loader_basic.hh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@
2222
#include <pinocchio/fwd.hpp>
2323

2424
// Boost includes
25-
#include <boost/program_options.hpp>
2625
#include <boost/foreach.hpp>
2726
#include <boost/format.hpp>
27+
#include <boost/program_options.hpp>
2828

2929
// ROS includes
30+
#include <sensor_msgs/JointState.h>
31+
3032
#include "ros/ros.h"
3133
#include "std_srvs/Empty.h"
32-
#include <sensor_msgs/JointState.h>
3334

3435
// Sot Framework includes
35-
#include <sot/core/debug.hh>
3636
#include <sot/core/abstract-sot-external-interface.hh>
37+
#include <sot/core/debug.hh>
3738

3839
namespace po = boost::program_options;
3940
namespace dgs = dynamicgraph::sot;
@@ -94,10 +95,12 @@ class SotLoaderBasic {
9495
virtual void initializeRosNode(int argc, char* argv[]);
9596

9697
// \brief Callback function when starting dynamic graph.
97-
bool start_dg(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
98+
bool start_dg(std_srvs::Empty::Request& request,
99+
std_srvs::Empty::Response& response);
98100

99101
// \brief Callback function when stopping dynamic graph.
100-
bool stop_dg(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
102+
bool stop_dg(std_srvs::Empty::Request& request,
103+
std_srvs::Empty::Response& response);
101104

102105
// \brief Read the state vector description based upon the robot links.
103106
int readSotVectorStateParam();

scripts/robot_pose_publisher

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@ import rospy
88
import tf
99
import sensor_msgs.msg
1010

11-
frame = ''
12-
childFrame = ''
11+
frame = ""
12+
childFrame = ""
13+
1314

14-
#DEPRECATED. Robot Pose is already being published
1515
def pose_broadcaster(msg):
16-
translation = msg.position[0:3];
17-
rotation = tf.transformations.quaternion_from_euler(msg.position[3], msg.position[4], msg.position[5])
16+
# DEPRECATED. Robot Pose is already being published
17+
translation = msg.position[0:3]
18+
rotation = tf.transformations.quaternion_from_euler(
19+
msg.position[3], msg.position[4], msg.position[5]
20+
)
1821
tfbr = tf.TransformBroadcaster()
19-
tfbr.sendTransform(translation, rotation,
20-
rospy.Time.now(), childFrame, frame)
22+
tfbr.sendTransform(translation, rotation, rospy.Time.now(), childFrame, frame)
23+
24+
25+
if __name__ == "__main__":
26+
rospy.init_node("robot_pose_publisher", anonymous=True)
2127

22-
if __name__ == '__main__':
23-
rospy.init_node('robot_pose_publisher', anonymous=True)
28+
frame = rospy.get_param("~frame", "odom")
29+
childFrame = rospy.get_param("~child_frame", "base_link")
30+
topic = rospy.get_param("~topic", "joint_states")
2431

25-
frame = rospy.get_param('~frame', 'odom')
26-
childFrame = rospy.get_param('~child_frame', 'base_link')
27-
topic = rospy.get_param('~topic', 'joint_states')
28-
2932
rospy.Subscriber(topic, sensor_msgs.msg.JointState, pose_broadcaster)
3033
rospy.spin()

0 commit comments

Comments
 (0)