Description of Changes
The bulk of the changes in this Pull Request are focused around the new RCameraService.c. This file bridges the low-level functions used to interact with the CubeSense board, and the system tasks executing the normal satellite operations. RCameraService.c contains functions for both ADCS detection and image capture.
Implementation has been done in RAdcsCaptureTask.c and RImageCaptureTask.c for the automatic capture of ADCS measurements and the automatic capture and download of an image, respectively. Each are using settings (ex: task delay) that can be customized via a telecommand. More details are available on a flow diagram provided by email.
Communication with the Ground Station:
Implementation of telecommands or downlink/uplink is not part of this Pull Request. A list of telecommands needed to control the cameras has been sent by email and will need to be implemented.
ADCS measurements downlink:
Automatic ADCS capture executes a burst of measurements (default is 5), where resulting alpha/beta angles are available only if the CubeSense detection algorithm was successful. Inside the ADCS result struct, the number of successful detections will be available in the field validMeasurementsCount, which can be used to iterate in the results array:
// Validate that ADCS results are available
uint8_t adcsReadyForDownlink = !getADCSReadyForNewBurstState();
if (adcsReadyForDownlink) {
// Get the ADCS burst results
adcs_detection_results_t * adcsResults = getADCSBurstResults();
if (adcsResults != NULL) {
// TODO
// The number of valid measurements is available in: adcsResults->validMeasurementsCount
// Results are stored in the following array (dynamic size): adcsResults->results
}
}
Once downlink is considered complete and the stored ADCS results are no longer needed, the function setADCSReadyForNewBurst() needs to be called to restart the automatic ADCS capture.
Image frames downlink:
Image capture and download will store an image in OBC memory, corresponding to a specific download size. The download size can be changed via telecommand. After an image has been downloaded and stored in memory, another download is required if a different image size is needed, which will replace the last stored image. When an image is stored in memory, it is flagged as ready for downlink. In the simplest case, downlink implementation can be done as follows:
// Validate that an image is ready for downlink
if (getImageReadyForDownlinkState()) {
// Get the number of frames in the stored image
uint16_t imageFramesCount = getImageFramesCount();
if (imageFramesCount > 0) {
image_frame_t frame = {0};
for (int i = 0; i < imageFramesCount; i++) {
// Get the next image frame using an internal circular index
// The index increments at the start of this function, so to get frame "0", index should be "-1" (default value)
uint8_t frameSize = imageTransferNextFrame(&frame);
if (frameSize == 0) {
printf("Error getting image frame...\n");
break;
}
// TODO
// The image frame index received is available in: frame.frameIndex
// The array of bytes forming the image frame is available in: frame.image_bytes
}
}
}
If the downlink of an image frame fails, or there is not enough time to downlink all frames during a single pass, then the following RCameraService functions are also available to manage the image frame transfer:
imageTransferCurrentFrame(&frame): Get the image frame at the current internal image frame index.
imageTransferSpecificFrame(&frame, frameIndex): Get the image frame at the frame index value of frameIndex.
setImageTransferFrameIndex(frameIndex): Update the internal image frame index to the value of argument frameIndex. This allows to restart loop execution (using imageTransferNextFrame()) at a given index.
Once downlink is considered complete and the stored image is no longer needed, the function setImageReadyForNewCapture() needs to be called to restart the automatic image capture.
Note on Telecommands:
Comments have been left inside RTelecommandService.c to help with the upcoming implementation of some of the function calls to RCameraService.
Description of Changes The bulk of the changes in this Pull Request are focused around the new
RCameraService.c
. This file bridges the low-level functions used to interact with the CubeSense board, and the system tasks executing the normal satellite operations.RCameraService.c
contains functions for both ADCS detection and image capture.Implementation has been done in
RAdcsCaptureTask.c
andRImageCaptureTask.c
for the automatic capture of ADCS measurements and the automatic capture and download of an image, respectively. Each are using settings (ex: task delay) that can be customized via a telecommand. More details are available on a flow diagram provided by email.Communication with the Ground Station: Implementation of telecommands or downlink/uplink is not part of this Pull Request. A list of telecommands needed to control the cameras has been sent by email and will need to be implemented.
validMeasurementsCount
, which can be used to iterate in theresults
array:Once downlink is considered complete and the stored ADCS results are no longer needed, the function
setADCSReadyForNewBurst()
needs to be called to restart the automatic ADCS capture.Image frames downlink: Image capture and download will store an image in OBC memory, corresponding to a specific download size. The download size can be changed via telecommand. After an image has been downloaded and stored in memory, another download is required if a different image size is needed, which will replace the last stored image. When an image is stored in memory, it is flagged as ready for downlink. In the simplest case, downlink implementation can be done as follows:
If the downlink of an image frame fails, or there is not enough time to downlink all frames during a single pass, then the following
RCameraService
functions are also available to manage the image frame transfer:imageTransferCurrentFrame(&frame)
: Get the image frame at the current internal image frame index.imageTransferSpecificFrame(&frame, frameIndex)
: Get the image frame at the frame index value offrameIndex
.setImageTransferFrameIndex(frameIndex)
: Update the internal image frame index to the value of argumentframeIndex
. This allows to restart loop execution (usingimageTransferNextFrame()
) at a given index.Once downlink is considered complete and the stored image is no longer needed, the function
setImageReadyForNewCapture()
needs to be called to restart the automatic image capture.Note on Telecommands: Comments have been left inside
RTelecommandService.c
to help with the upcoming implementation of some of the function calls toRCameraService
.