Skip to content

Commit 0f86e7b

Browse files
authored
Merge pull request #24 from jmirabel/devel
Add warning msg + Fix optionnal dep temperature_sensor_controller
2 parents 98edaef + 94bc5c7 commit 0f86e7b

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ SEARCH_FOR_BOOST_PYTHON()
3434
add_required_dependency(bullet)
3535
add_required_dependency(urdfdom)
3636

37-
SET(CATKIN_REQUIRED_COMPONENTS
38-
temperature_sensor_controller
37+
find_package(catkin REQUIRED COMPONENTS
3938
pal_hardware_interfaces
4039
controller_interface
4140
controller_manager
@@ -47,8 +46,7 @@ SET(CATKIN_REQUIRED_COMPONENTS
4746
realtime_tools
4847
rospy
4948
)
50-
51-
find_package(catkin REQUIRED COMPONENTS ${CATKIN_REQUIRED_COMPONENTS})
49+
find_package(temperature_sensor_controller)
5250

5351
ADD_PROJECT_DEPENDENCY(dynamic-graph-python 4.0.0 REQUIRED)
5452
ADD_PROJECT_DEPENDENCY(dynamic_graph_bridge REQUIRED)
@@ -65,19 +63,26 @@ endif(controller_interface_FOUND)
6563

6664
# Detect if temperature sensor controller package is found
6765
# if yes then it is a PAL Robotics Forked code.
68-
if(temperature_sensor_controller_FOUND)
69-
add_definitions(-DTEMPERATURE_SENSOR_CONTROLLER)
70-
endif(temperature_sensor_controller_FOUND)
7166

7267
add_library(rcsot_controller
7368
src/roscontrol-sot-controller.cpp
7469
src/log.cpp
7570
)
76-
TARGET_INCLUDE_DIRECTORIES(rcsot_controller SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
77-
TARGET_INCLUDE_DIRECTORIES(rcsot_controller PUBLIC $<INSTALL_INTERFACE:include>)
78-
TARGET_LINK_LIBRARIES(rcsot_controller ${catkin_LIBRARIES} ${bullet_LIBRARIES}
79-
sot-core::sot-core dynamic_graph_bridge::sot_loader
71+
target_include_directories(rcsot_controller SYSTEM PUBLIC
72+
${catkin_INCLUDE_DIRS}
73+
$<INSTALL_INTERFACE:include>)
74+
target_link_libraries(rcsot_controller
75+
${catkin_LIBRARIES}
76+
${bullet_LIBRARIES}
77+
sot-core::sot-core
78+
dynamic_graph_bridge::sot_loader
8079
${control_toolbox_LIBRARIES})
80+
if (temperature_sensor_controller_FOUND)
81+
target_compile_definitions(rcsot_controller PUBLIC TEMPERATURE_SENSOR_CONTROLLER)
82+
message("temperature_sensor_controller_LIBRARIES: ${temperature_sensor_controller_LIBRARIES}")
83+
target_include_directories(rcsot_controller SYSTEM PUBLIC ${temperature_sensor_controller_INCLUDE_DIRS})
84+
target_link_libraries(rcsot_controller ${temperature_sensor_controller_LIBRARIES})
85+
endif()
8186

8287
IF(SUFFIX_SO_VERSION)
8388
SET_TARGET_PROPERTIES(rcsot_controller PROPERTIES SOVERSION ${PROJECT_VERSION})

src/log.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ void Log::start_it() {
114114
timeorigin_;
115115
}
116116

117-
void Log::stop_it() {
117+
double Log::stop_it() {
118118
struct timeval current;
119119
gettimeofday(&current, 0);
120120

121121
time_stop_it_ =
122122
((double)current.tv_sec + 0.000001 * (double)current.tv_usec) -
123123
timeorigin_;
124+
125+
return time_stop_it_ - time_start_it_;
124126
}
125127

126128
void Log::save(std::string &fileName) {

src/log.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public:
9292

9393
void save(std::string &fileName);
9494
void start_it();
95-
void stop_it();
95+
/// \return the elapsed time since the previous \ref start_it
96+
double stop_it();
9697
};
9798
} // namespace rc_sot_system
9899

src/roscontrol-sot-controller.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,11 @@ void RCSotController::one_iteration() {
967967
readControl(controlValues_);
968968

969969
// Chrono stop.
970-
RcSotLog_.stop_it();
970+
double it_duration = RcSotLog_.stop_it();
971+
if (it_duration > dt_) {
972+
ROS_WARN_THROTTLE(1, "Iteration duration (%d) bigger than max period (%d)",
973+
it_duration, dt_);
974+
}
971975

972976
/// Store everything in Log.
973977
RcSotLog_.record(DataOneIter_);

0 commit comments

Comments
 (0)