Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autoupdate_branch: 'devel'
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
rev: v21.1.2
hooks:
- id: clang-format
args: [--style=Google]
Expand All @@ -24,8 +24,8 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.9.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand Down
32 changes: 16 additions & 16 deletions src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace rc_sot_system;

DataToLog::DataToLog() {}

void DataToLog::init(ProfileLog &aProfileLog) {
void DataToLog::init(ProfileLog& aProfileLog) {
profileLog_ = aProfileLog;
motor_angle.resize(aProfileLog.nbDofs * aProfileLog.length);
joint_angle.resize(aProfileLog.nbDofs * aProfileLog.length);
Expand Down Expand Up @@ -53,7 +53,7 @@ void DataToLog::init(ProfileLog &aProfileLog) {

Log::Log() : lref_(0), lrefts_(0) {}

void Log::init(ProfileLog &aProfileLog) {
void Log::init(ProfileLog& aProfileLog) {
profileLog_ = aProfileLog;
lref_ = 0;
lrefts_ = 0;
Expand All @@ -64,7 +64,7 @@ void Log::init(ProfileLog &aProfileLog) {
timeorigin_ = (double)current.tv_sec + 0.000001 * ((double)current.tv_usec);
}

void Log::record(DataToLog &aDataToLog) {
void Log::record(DataToLog& aDataToLog) {
if ((aDataToLog.motor_angle.size() != profileLog_.nbDofs) ||
(aDataToLog.velocities.size() != profileLog_.nbDofs))
return;
Expand Down Expand Up @@ -148,7 +148,7 @@ double Log::stop_it() {
return time_stop_it_ - time_start_it_;
}

void Log::save(std::string &fileName) {
void Log::save(std::string& fileName) {
assert(lref_ == lrefts_ * profileLog_.nbDofs);

std::string suffix("-mastate.log");
Expand Down Expand Up @@ -184,22 +184,22 @@ void Log::save(std::string &fileName) {
saveVector(fileName, suffix, StoredData_.duration, 1);
}

inline void writeHeaderToBinaryBuffer(ofstream &of, const std::size_t &nVector,
const std::size_t &vectorSize) {
of.write((const char *)(&nVector), sizeof(std::size_t));
of.write((const char *)(&vectorSize), sizeof(std::size_t));
inline void writeHeaderToBinaryBuffer(ofstream& of, const std::size_t& nVector,
const std::size_t& vectorSize) {
of.write((const char*)(&nVector), sizeof(std::size_t));
of.write((const char*)(&vectorSize), sizeof(std::size_t));
}

inline void writeToBinaryFile(ofstream &of, const double &t, const double &dt,
const std::vector<double> &data,
const std::size_t &idx, const std::size_t &size) {
of.write((const char *)&t, sizeof(double));
of.write((const char *)&dt, sizeof(double));
of.write((const char *)(&data[idx]), size * (sizeof(double)));
inline void writeToBinaryFile(ofstream& of, const double& t, const double& dt,
const std::vector<double>& data,
const std::size_t& idx, const std::size_t& size) {
of.write((const char*)&t, sizeof(double));
of.write((const char*)&dt, sizeof(double));
of.write((const char*)(&data[idx]), size * (sizeof(double)));
}

void Log::saveVector(std::string &fileName, std::string &suffix,
const std::vector<double> &avector, std::size_t size) {
void Log::saveVector(std::string& fileName, std::string& suffix,
const std::vector<double>& avector, std::size_t size) {
ostringstream oss;
oss << fileName;
oss << suffix.c_str();
Expand Down
12 changes: 6 additions & 6 deletions src/log.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct DataToLog {
ProfileLog profileLog_;

DataToLog();
void init(ProfileLog &aProfileLog);
void init(ProfileLog& aProfileLog);
std::size_t nbDofs() { return profileLog_.nbDofs; }
std::size_t nbForceSensors() { return profileLog_.nbForceSensors; }
std::size_t length() { return profileLog_.length; }
Expand Down Expand Up @@ -78,16 +78,16 @@ class Log {
// \param size number of contiguous values of avector that forms one line.
// \note avector is a circular buffer. Data will be written from
// start to N, and then from 0 to start.
void saveVector(std::string &filename, std::string &suffix,
const std::vector<double> &avector, std::size_t size);
void saveVector(std::string& filename, std::string& suffix,
const std::vector<double>& avector, std::size_t size);

public:
Log();

void init(ProfileLog &aProfileLog);
void record(DataToLog &aDataToLog);
void init(ProfileLog& aProfileLog);
void record(DataToLog& aDataToLog);

void save(std::string &fileName);
void save(std::string& fileName);
void start_it();
/// \return the elapsed time since the previous \ref start_it
double stop_it();
Expand Down
Loading