Skip to content

Commit 80ea973

Browse files
authored
Merge pull request #31 from DianeBury/devel
Add RCSotController destructor
2 parents def1c9c + 84148e1 commit 80ea973

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/roscontrol-sot-controller.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ RCSotController::RCSotController()
7777
RESETDEBUG4();
7878
}
7979

80+
RCSotController::~RCSotController() {
81+
SotLoaderBasic::CleanUp();
82+
using namespace ::dynamicgraph;
83+
RealTimeLogger::destroy();
84+
}
85+
8086
void RCSotController::displayClaimedResources(
8187
ClaimedResources &claimed_resources) {
8288
#ifdef CONTROLLER_INTERFACE_KINETIC
@@ -127,6 +133,10 @@ void RCSotController::initLogs(ros::NodeHandle &robot_nh) {
127133
profileLog_.length = length;
128134
/// Initialize the data logger for 300s.
129135
RcSotLog_.init(profileLog_);
136+
137+
using namespace ::dynamicgraph;
138+
RealTimeLogger::instance().addOutputStream(
139+
LoggerStreamPtr_t(new LoggerROSStream()));
130140
}
131141

132142
bool RCSotController::initRequest(lhi::RobotHW *robot_hw,
@@ -944,7 +954,6 @@ void RCSotController::readControl(
944954
void RCSotController::one_iteration() {
945955
// Chrono start
946956
RcSotLog_.start_it();
947-
948957
/// Update the sensors.
949958
fillSensors();
950959

@@ -959,6 +968,7 @@ void RCSotController::one_iteration() {
959968

960969
throw e;
961970
}
971+
962972
try {
963973
sotController_->getControl(controlValues_);
964974
} catch (std::exception &e) {
@@ -1111,20 +1121,15 @@ void RCSotController::update(const ros::Time &, const ros::Duration &period) {
11111121

11121122
void RCSotController::starting(const ros::Time &) {
11131123
using namespace ::dynamicgraph;
1114-
RealTimeLogger::instance().addOutputStream(
1115-
LoggerStreamPtr_t(new LoggerROSStream()));
1116-
11171124
fillSensors();
11181125
}
11191126

11201127
void RCSotController::stopping(const ros::Time &) {
11211128
std::string afilename("/tmp/sot.log");
1122-
RcSotLog_.save(afilename);
11231129

1124-
SotLoaderBasic::CleanUp();
1130+
RcSotLog_.record(DataOneIter_);
1131+
RcSotLog_.save(afilename);
11251132

1126-
using namespace ::dynamicgraph;
1127-
RealTimeLogger::destroy();
11281133
}
11291134

11301135
PLUGINLIB_EXPORT_CLASS(sot_controller::RCSotController, lci::ControllerBase)

src/roscontrol-sot-controller.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ private:
159159
public:
160160
RCSotController();
161161

162+
virtual ~RCSotController();
163+
162164
/// \brief Read the configuration files,
163165
/// claims the request to the robot and initialize the Stack-Of-Tasks.
164166
bool initRequest(lhi::RobotHW *robot_hw, ros::NodeHandle &robot_nh,

0 commit comments

Comments
 (0)