Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: data collection now averages data #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 19 additions & 12 deletions src/cellular/dataCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,26 @@ void SS_ensemble10Func()

// ensData.header.elapsedTime_ds = Ens_getStartTime(pDeployment->startTime);
// SF_OSAL_printf("Ensemble timestamp: %d\n", ensData.header.elapsedTime_ds);
ensData.data.ens10.rawTemp = N_TO_B_ENDIAN_2(temp / 0.0078125);
ensData.data.ens10.rawAcceleration[0] = N_TO_B_ENDIAN_2(pData->acc[0]) ;
ensData.data.ens10.rawAcceleration[1] = N_TO_B_ENDIAN_2(pData->acc[1]) ;
ensData.data.ens10.rawAcceleration[2] = N_TO_B_ENDIAN_2(pData->acc[2]) ;
ensData.data.ens10.rawAngularVel[0] = N_TO_B_ENDIAN_2(pData->ang[0]) ;
ensData.data.ens10.rawAngularVel[1] = N_TO_B_ENDIAN_2(pData->ang[1]) ;
ensData.data.ens10.rawAngularVel[2] = N_TO_B_ENDIAN_2(pData->ang[2]) ;
ensData.data.ens10.rawMagField[0] = N_TO_B_ENDIAN_2(pData->mag[0]) ;
ensData.data.ens10.rawMagField[1] = N_TO_B_ENDIAN_2(pData->mag[1]) ;
ensData.data.ens10.rawMagField[2] = N_TO_B_ENDIAN_2(pData->mag[2]) ;
ensData.data.ens11.location[0] = N_TO_B_ENDIAN_4(pData->location[0]) ;
ensData.data.ens11.location[1] = N_TO_B_ENDIAN_4(pData->location[1]) ;

// average data by accumulation count
if (pData->accumulateCount > 0)
{
Ensemble10_data_t &ens10 = ensData.data.ens10;
Ensemble11_data_t &ens11 = ensData.data.ens11;
uint32_t &count = pData->accumulateCount;
ens10.rawTemp = N_TO_B_ENDIAN_2(temp / (0.0078125 * count));
ens10.rawAcceleration[0] = N_TO_B_ENDIAN_2(pData->acc[0] / count);
ens10.rawAcceleration[1] = N_TO_B_ENDIAN_2(pData->acc[1] / count);
ens10.rawAcceleration[2] = N_TO_B_ENDIAN_2(pData->acc[2] / count);
ens10.rawAngularVel[0] = N_TO_B_ENDIAN_2(pData->ang[0] / count);
ens10.rawAngularVel[1] = N_TO_B_ENDIAN_2(pData->ang[1] / count);
ens10.rawAngularVel[2] = N_TO_B_ENDIAN_2(pData->ang[2] / count);
ens10.rawMagField[0] = N_TO_B_ENDIAN_2(pData->mag[0] / count);
ens10.rawMagField[1] = N_TO_B_ENDIAN_2(pData->mag[1] / count);
ens10.rawMagField[2] = N_TO_B_ENDIAN_2(pData->mag[2] / count);
ens11.location[0] = N_TO_B_ENDIAN_4(pData->location[0] / count);
ens11.location[1] = N_TO_B_ENDIAN_4(pData->location[1] / count);
Comment on lines +107 to +121
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this hides too much the notion that ens10 and ens11 are overlapping memory regions. It probably is best to write this as originally.

We probably also want to delay this until the final count of the average, but that might be best done differently.

}

ensData.header.ensembleType = ENS_TEMP_IMU;
int x = pSystemDesc->pRecorder->putBytes(&ensData, sizeof(EnsembleHeader_t) + sizeof(Ensemble10_data_t));
Expand Down