XT2 has 2 SD cards, they are storing visual and thermal images respectively. Therefore you have to get the object instance from the correct SD cards from the correct camera. You can get the correct camera instance from the code below:
index=0 means visual camera, index=2 means thermal camera.
If you only want to format XT2's index 0 camera's SD card, you can call the code below:
If you trying to format a SD card slot which does not have a SD card, you will receive an error: undenfined Error.