I have my own controller module, which works fine other than this problem. I have an m by n array stored in a .csv file on the microsd card that I want to read in and use in the controller module. What I am currently doing is not working:
static const char *csv_file = PX4_ROOTFSDIR"/fs/microsd/myfile.csv";
FILE* stream = fopen(csv_file, "r");
PX4_INFO("Arbitrary message");
...parse into vector of vectors...
For some reason, I can never even get as far as the arbitrary message.
I’m not sure if I’m doing something fundamentally wrong, but alternatively I would really appreciate any higher-level advice about how to go about this objective: reading an array from a .csv file into a vector of vectors in my controller module. I would not call myself a programmer in any language, let alone C/C++, so any help is useful!
If I understand you correctly, I’m running this at startup time. I’m using HITL and running it when I switch into my controller module in the flight simulation.
Yes, I have the NSH attached.
I’m hoping I can do this all in HITL.
Now I’ve tried hardcoding (copy/pasting essentially) my vector of vectors into the module itself, as to avoid having to read anything off the sd card. But with the size of my matrices - four matrices, each around 100 by 20 - I’m running into memory issues.
It now seems I shouldn’t even bother worrying about this reading function until I can figure out what to do about the size of the data I want to read in.
Just briefly…If I want to use about 100KB for these vectors, is that ever going to work with the Pixhawk or might I just as well give up on that?
Are you sure you need them all in memory at the same time? Run free on your pixhawk to see what’s available.
I don’t know what you’re trying to do, but one option could be offloading the computation to a companion computer (intel edison or odroid) connected to the pixhawk