Skip to content

Commit d5f2770

Browse files
Fix several bugs in logging with the new logging architecture.
1 parent 0bd99a0 commit d5f2770

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/log.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void Log::init(ProfileLog &aProfileLog)
6262

6363
void Log::record(DataToLog &aDataToLog)
6464
{
65-
if ( (aDataToLog.motor_angle.size()!=aDataToLog.nbDofs()) ||
66-
(aDataToLog.velocities.size()!=aDataToLog.nbDofs()))
65+
if ( (aDataToLog.motor_angle.size()!=profileLog_.nbDofs) ||
66+
(aDataToLog.velocities.size()!=profileLog_.nbDofs))
6767
return;
6868

6969
for(unsigned int JointID=0;JointID<aDataToLog.nbDofs();JointID++)
@@ -105,9 +105,9 @@ void Log::record(DataToLog &aDataToLog)
105105

106106
StoredData_.duration[lrefts_] = time_stop_it_ - time_start_it_;
107107

108-
lref_ += aDataToLog.nbDofs();
108+
lref_ += profileLog_.nbDofs;
109109
lrefts_ ++;
110-
if (lref_>=aDataToLog.nbDofs()*aDataToLog.length())
110+
if (lref_>=profileLog_.nbDofs*profileLog_.length)
111111
{
112112
lref_=0;
113113
lrefts_=0;
@@ -153,7 +153,7 @@ void Log::save(std::string &fileName)
153153
ostringstream oss;
154154
oss << "-forceSensors.log";
155155
suffix = oss.str();
156-
saveVector(fileName,suffix,StoredData_.force_sensors, 6);
156+
saveVector(fileName,suffix,StoredData_.force_sensors, 6 * profileLog_.nbForceSensors);
157157

158158
suffix = "-temperatures.log";
159159
saveVector(fileName,suffix,StoredData_.temperatures, profileLog_.nbDofs);

src/roscontrol-sot-controller.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,17 @@ namespace sot_controller
124124
void RCSotController::initLogs()
125125
{
126126
ROS_INFO_STREAM("Initialize log data structure");
127-
128-
/// Initialize the size of the data to store.
127+
/// Initialize the size of the data to store.
128+
/// Set temporary profileLog to one
129+
/// because DataOneIter is just for one iteration.
130+
unsigned tmp_length = profileLog_.length;
131+
profileLog_.length = 1;
129132
DataOneIter_.init(profileLog_);
130-
133+
134+
/// Set profile Log to real good value for the stored data.
135+
profileLog_.length= tmp_length;
131136
/// Initialize the data logger for 300s.
132-
RcSotLog.init(profileLog_);
137+
RcSotLog_.init(profileLog_);
133138

134139
}
135140

@@ -909,7 +914,7 @@ namespace sot_controller
909914
void RCSotController::one_iteration()
910915
{
911916
// Chrono start
912-
RcSotLog.start_it();
917+
RcSotLog_.start_it();
913918

914919
/// Update the sensors.
915920
fillSensors();
@@ -926,10 +931,10 @@ namespace sot_controller
926931
readControl(controlValues_);
927932

928933
// Chrono stop.
929-
RcSotLog.stop_it();
934+
RcSotLog_.stop_it();
930935

931936
/// Store everything in Log.
932-
RcSotLog.record(DataOneIter_);
937+
RcSotLog_.record(DataOneIter_);
933938
}
934939

935940
void RCSotController::
@@ -1038,7 +1043,7 @@ namespace sot_controller
10381043
stopping(const ros::Time &)
10391044
{
10401045
std::string afilename("/tmp/sot.log");
1041-
RcSotLog.save(afilename);
1046+
RcSotLog_.save(afilename);
10421047

10431048
SotLoaderBasic::CleanUp();
10441049

src/roscontrol-sot-controller.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ namespace sot_controller
140140
/// @}
141141

142142
/// \brief Log
143-
rc_sot_system::Log RcSotLog;
143+
rc_sot_system::Log RcSotLog_;
144144
/// @}
145145

146146
const std::string type_name_;

0 commit comments

Comments
 (0)