Untitled

 avatar
unknown
plain_text
a year ago
1.1 kB
5
Indexable
class CommsDriver {
public:
    // Suponiendo que estas son tus variables miembro y sus tipos.
    float afUncompAccel_[3];
    float afUncompGyro_[3];
    float afUncompMag_[3];
    float fTemp_;
    float fPressure_;

    void vPrintData_() {
        // Abrir archivo en modo de adición, para no sobrescribir los datos existentes.
        std::ofstream outFile("datos_imu.csv", std::ios_base::app);

        // Comprobar si el archivo se abrió correctamente.
        if (!outFile.is_open()) {
            std::cerr << "Error al abrir el archivo para escritura.\n";
            return;
        }

        // Escribir datos en formato CSV.
        outFile << afUncompAccel_[0] << "," << afUncompAccel_[1] << "," << afUncompAccel_[2] << ","
                << afUncompGyro_[0] << "," << afUncompGyro_[1] << "," << afUncompGyro_[2] << ","
                << afUncompMag_[0] << "," << afUncompMag_[1] << "," << afUncompMag_[2] << ","
                << fTemp_ << "," << fPressure_ << "\n";

        // Cerrar el archivo después de la escritura.
        outFile.close();
    }
};
Editor is loading...
Leave a Comment