in servo_pkg/src/servo_mgr.cpp [200:221]
void ServoMgr::writeCalJSON(const std::unordered_map<int, std::unordered_map<std::string, int>> &calibrationMap,
const std::string &filePath) {
Json::Value calJsonValue;
auto itServo = calibrationMap.find(servo);
auto itMotor = calibrationMap.find(motor);
if (itServo != calibrationMap.end() && itMotor != calibrationMap.end()) {
for (auto servoMap : itServo->second) {
calJsonValue[HEADER_KEY][SERVO_KEY][servoMap.first] = servoMap.second;
}
for (auto motorMap : itMotor->second) {
calJsonValue[HEADER_KEY][MOTOR_KEY][motorMap.first] = motorMap.second;
}
calJsonValue[HEADER_KEY][VERSION_KEY] = CAL_FILE_VERSION;
}
else {
RCLCPP_ERROR(logger_, "Invalid calibration map");
return;
}
writeJSONToFile(calJsonValue, filePath);
}