NASA's Perseverance rover has been touring the Red Planet since it landed on Mars earlier this year. In late March, Perseverance sent back a selfie. The rover captured another selfie with the Ingenuity helicopter on April 6, the 46th sol of Perseverance's mission.

Over two months later, NASA has released a new video showing how the selfie was created. If you thought it was as simple as the rover taking a single image, think again. The rover's robotic arm twisted and maneuvered to capture 62 images, which were then composited into a single selfie.

NASA writes, 'Perseverance's selfie came together with the help of a core group of about a dozen people, including rover drivers, engineers who ran tests at JPL, and camera operations engineers who developed the camera sequence, processed the images, and stitched them together. It took about a week to plot out all the individual commands required.' There's a lot to the selfie.

Perseverance's self-portrait serves multiple purposes. The selfie allows engineers back on Earth to check wear and tear on the rover. Further, images like the recent selfie inspire people and help craft a new generation of space enthusiasts. Vandi Verma, Perseverance's chief engineer for robotic operations at NASA's Jet Propulsion Laboratory (JPL) in Southern California, said, 'I got into this because I saw a picture from Sojourner, NASA's first Mars rover.' Verma also worked on Curiosity's first selfie in October 2012. 'When we took that first selfie, we didn't realize these would become so iconic and routine,' Verma continued.

Selfies are serious business on Mars. Team members sometimes passed up on precious opportunities to sleep to ensure that Perseverance captured a nice selfie. JPL worked with Malin Space Science Systems (MSSS) in San Diego. MSSS built the camera used for the selfie, the WATSON (Wide Angle Topographic Sensor for Operations and eNgineering). This camera is used primarily to capture close-up shots of rock textures, not wide-angle images. This means that WATSON covers only a small portion of the scene, meaning dozens of images must be stitched together to create a selfie of the rover.

JPL had to create special software to ensure that Perseverance's arm doesn't collide with the rover. NASA writes, 'Each time a collision is detected in simulations on Earth, the engineering team adjusts the arm trajectory; the process repeats dozens of times to confirm the arm motion is safe.' The final command sequence aims to get the robotic arm as close as possible to the rover's body.

'The thing that took the most attention was getting Ingenuity into the right place in the selfie,' said Mike Ravine, Advanced Projects Manager at MSSS. 'Given how small it is, I thought we did a pretty good job.' When images arrived from Mars, MSSS image processing engineers immediately went to work. They start by cleaning up blemishes caused by dust that settled on WATSON's light detector. Next, they assemble individual frames into a mosaic and smooth out the seams using software. Finally, an engineer warps the image to more closely resemble a normal photo that the public typically sees.