Skip to content

Commit 947df3e

Browse files
authored
fineCalibrationChecker: add withGui parameter (#1037)
1 parent 4ed3cab commit 947df3e

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/libraries/icubmod/fineCalibrationChecker/src/FineCalibrationChecker.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ bool FineCalibrationChecker::open(yarp::os::Searchable& config)
142142
}
143143
}
144144

145+
_withGui = property.check("withGui", yarp::os::Value(false)).asBool();
146+
145147
yCDebug(FineCalibrationCheckerCOMPONENT) << _deviceName << "Initialized device driver";
146148
_deviceStatus = deviceStatus::INITIALIZED;
147149

@@ -232,7 +234,7 @@ bool FineCalibrationChecker::threadInit()
232234
yCError(FineCalibrationCheckerCOMPONENT) << _deviceName << "Unable to open encoders interface. Aborting...";
233235
return false;
234236
}
235-
237+
236238

237239
if (!_remappedControlBoardDevice->view(remappedControlBoardInterfaces._ienc) || remappedControlBoardInterfaces._ienc == nullptr)
238240
{
@@ -288,7 +290,7 @@ void FineCalibrationChecker::run()
288290
if (_deviceStatus == deviceStatus::CONFIGURED)
289291
{
290292
auto now = std::chrono::steady_clock::now();
291-
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - lastTimerLog).count() > 1000)
293+
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - lastTimerLog).count() > 1000)
292294
{
293295
yCDebug(FineCalibrationCheckerCOMPONENT) << _deviceName << "Device configured, waiting for attachAll() to be called.";
294296
lastTimerLog = now;
@@ -350,7 +352,7 @@ void FineCalibrationChecker::run()
350352
else if(_deviceStatus == deviceStatus::CHECK_COMPLETED)
351353
{
352354
auto now = std::chrono::steady_clock::now();
353-
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - shoutdownTimer).count() > 5000)
355+
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - shoutdownTimer).count() > 5000)
354356
{
355357
yCDebug(FineCalibrationCheckerCOMPONENT) << _deviceName << "Operation completed successfully. Waiting yarprobotinterface to stop the thread...";
356358
// shoutdownTimer = now;
@@ -529,7 +531,7 @@ void FineCalibrationChecker::evaluateHardStopPositionDelta(const std::string& ke
529531
// are stored in a vector whose legth is joints_number*3, where each sub-array is made such
530532
// [raw_val_primary_enc, raw_val_secondary_enc, rraw_val_auxiliary_enc]
531533
// and we want the first value for each joint
532-
rescaledPos = rawPosition * ICUB_DEGREES_RANGE / resolution; // Rescale the encoder raw position to iCubDegrees
534+
rescaledPos = rawPosition * ICUB_DEGREES_RANGE / resolution; // Rescale the encoder raw position to iCubDegrees
533535
delta = std::abs(goldPosition - rescaledPos) / (ICUB_DEGREES_RANGE/360) - homePositions[i]; // Calculate the delta in degrees
534536
delta = std::abs(delta) + static_cast<int64_t>(calibrationDelta[i]); // Add the calibration delta to the delta
535537
yCDebug(FineCalibrationCheckerCOMPONENT) << "GP:" << goldPosition << "HP:" << homePositions[i] << "RSP:" << rescaledPos << "RWP:" << rawPosition << "DD:" << delta;
@@ -553,8 +555,10 @@ void FineCalibrationChecker::evaluateHardStopPositionDelta(const std::string& ke
553555

554556
outFile.close();
555557
yCDebug(FineCalibrationCheckerCOMPONENT) << "Output CSV written to:" << outputPath.string();
556-
557-
generateOutputImage(1800, 400, sampleItems);
558+
// Generate output image
559+
if(_withGui) {
560+
generateOutputImage(1800, 400, sampleItems);
561+
}
558562
}
559563

560564
void FineCalibrationChecker::generateOutputImage(int frameWidth, int frameHeight, const std::vector<ItemData>& items)

src/libraries/icubmod/fineCalibrationChecker/src/FineCalibrationChecker.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FineCalibrationChecker : public yarp::dev::DeviceDriver,
5252
{
5353
public:
5454
// Enum for device status
55-
enum class deviceStatus
55+
enum class deviceStatus
5656
{
5757
INITIALIZED = 0,
5858
OPENED = 1,
@@ -100,15 +100,16 @@ class FineCalibrationChecker : public yarp::dev::DeviceDriver,
100100

101101
private:
102102
// Private members
103-
103+
104104
// Configuration parameters
105105
std::string _portPrefix = "/fineCalibrationChecker";
106106
std::string _robotName= "";
107107
std::string _deviceName= "fineCalibrationChecker";
108108
std::string _remoteRawValuesPort = "";
109-
109+
bool _withGui = false;
110+
110111
deviceStatus _deviceStatus = deviceStatus::NONE;
111-
112+
112113
yarp::os::Bottle _axesNamesList = yarp::os::Bottle();
113114
yarp::os::Bottle _goldPositionsList = yarp::os::Bottle();
114115
yarp::os::Bottle _encoderResolutionsList = yarp::os::Bottle();
@@ -128,7 +129,7 @@ class FineCalibrationChecker : public yarp::dev::DeviceDriver,
128129
yarp::dev::IMotor* _imot { nullptr };
129130
yarp::dev::IEncoders* _ienc { nullptr };
130131
} remappedControlBoardInterfaces;
131-
132+
132133
iCub::debugLibrary::IRawValuesPublisher* _iravap;
133134

134135
// Client drivers to communicate with interfaces

0 commit comments

Comments
 (0)