Mars Rover Robotic Platform Using Arduino, ESP32 and Raspberry Pi - 3D Printed

by xRoboMaker in Circuits > Arduino

76 Views, 0 Favorites, 0 Comments

Mars Rover Robotic Platform Using Arduino, ESP32 and Raspberry Pi - 3D Printed

finished_rover_on_desk.jpeg
assembly55.jpeg
embedded_UI_and_web_dashboard.jpeg
assembly54.jpeg
embedded_UI.png
openrover_modules.png
Mars Perseverance Rover Replica using Arduino, ESP32 and Raspberry Pi

Context

Rovers are planetary surface exploration robots that space agencies like NASA send to Mars to explore the planet. In this project, a functional 3D printed replica of the "Perseverance" rover, which was launched by NASA in July 2020, is created.


Objective

The project is named OpenRover. The main objective of OpenRover is to develop an open-source robotic platform that can enable anyone who tries building it to learn more about both the software and hardware aspects of DIY robotic projects, specially learning about widely used development boards like Arduino, ESP32 and Raspberry Pi.

As rovers are extremely sophisticated machines, they provide the perfect excuse to incorporate into the robotic platform several complex functionalities that replicate, at a smaller scale, the functionalities that real Mars rovers have (e.g., robotic arm, environmental sensors, 6-wheel drive).


Key contributions

Although many open-source robotic projects already exist, even some also related to Mars rover robots, they usually only use a single type of development board. In the OpenRover project, several development boards are used among its main functional modules (e.g., RaspberryPi for web connectivity, ESP32 for embedded screen, Arduino for motor control) and there are interactions between these modules.

This adds more educational value to the project, allowing to see each development board optimal usecase, and differentiates the OpenRover from other open-source DIY robotic projects.


Tech stack

Programming languages and frameworks used in the project

HTML, CSS, JavaScript, Bootstrap, Flask, Python, C, C++

Other technologies

To program Arduino and ESP32 microcontrollers, the PlatformIO IDE with the Arduino Framework was used. To create the embedded UI design of the touchscreen, the SquareLine Studio platform and LVGL library were used.


Features

  1. 6-wheel drive platform with 4 steerable wheels
  2. 4-axis foldable robotic arm with gripper
  3. Tiltable and rotary head, with space for a development board and a camera
  4. Environmental sensors to measure temperature, humidity, pressure and altitude
  5. Custom remote control module with touchscreen, with a UI where status values are displayed and different operation modes can be selected
  6. Battery sensors for the rover and the custom remote control
  7. 4 main operation modes: conventional driving control, 360º turn control, robotic arm control, head control
  8. Web dashboard that displays status values and a video feed. This web dashboard is hosted in the rover


Project modules

The OpenRover's components are organized, both at a hardware and software level, in different modules:

  1. Central rover module: It has an Arduino Mega development board that is inside the main body of the rover and that manages all moving elements (e.g., motors, servomotors) as well as the rover's sensors and sending/receiving the radio signal
  2. Remote control and touchscreen module: It has an ESP32S3 development board that is responsible for the touchscreen, and an Arduino Nano that is responsible for reading the RC channel values, sending/receiving the radio signal and measuring battery levels
  3. Camera and webserver module: It has a RaspberryPi Zero 2W development board that is inside the head of the rover. This board connects to a camera, generates a WiFi network and hosts a web dashboard


GitHub repository

This is the original GitHub repository of the OpenRover project:

https://github.com/pol-valero/openrover-robotic-platform

The GitHub repository can be used to complement this Instructables project guide, since it contains designs, schematics, documentation and the most up-to-date source code.


Disclaimers

The rover's 3D design was originally made by a mechatronics engineer called Dejan, who owns an educational YouTube channel and website called "HowToMechatronics". This design was adapted and improved.

Link to the original project used for the rover's 3D design

The robotic arm's 3D design was extracted from a GitHub project made by Jakob Krantz, who also created a Mars rover replica. This design was adapted and improved.

Link to the original project used for the robotic arm's 3D design

All the OpenRover hardware and software was created from scratch, following a different approach from the one the creators of the original 3D designs followed.

Supplies

hardware_components.jpeg

List with the most important hardware components needed for the rover:

  1. NEMA17 stepper motor (x1)
  2. Toggle switch 20A (x1)
  3. SS-12D10 switch (x2)
  4. Arduino Mega (x1)
  5. MG996R/DS3225 servo (x10)
  6. XD-37GB555 motor (x6)
  7. NRF24L01 transceiver module (x2)
  8. NRF24L01 3.3V regulator (x2)
  9. XT60 connector female and male (x1)
  10. DRV8871 motor driver (x6)
  11. SZBK07 buck converter 20A (x1)
  12. 22AWG wire 20 meters red and 20 meters black (x1)
  13. 14AWG wire 1 meter red and 1 meter black (x1)
  14. Servo extension cable 22AWG 5 meters (x1)
  15. Dupont jumper wires (as needed)
  16. BME280 sensor (x1)
  17. 12V 4010 fan (x2)
  18. Arduino Nano (x1)
  19. A4988 stepper motor driver (x1)
  20. Matte Black vinyl wrap (as needed)
  21. Self closing braided sleeve for cables (as needed)
  22. JST-XH male and female connectors (as needed)
  23. Micro limit switch with roller (x1)
  24. Jack 3.5mm mono connector (x1)
  25. 6000mAh 11.1V 50C LiPo battery (x1)
  26. XL4015 buck converter 5A (x2)
  27. Mini buck converter 2A (x1)
  28. 4-channel logic level converter (x1)
  29. ESP32S3_8048S043 IPS touchscreen (x1)
  30. RaspberryPi Zero 2W (x1)
  31. RaspberryPi Cam V3 Wide (x1)
  32. FFC cable 15 centimeters for PiZero and PiCam (x1)
  33. Heatsink for PiZero (x1)
  34. CP2102 USB to TTL converter (x1)
  35. 4-USB HAT for PiZero (x1)
  36. 1N5817 Schottky diode (x3)
  37. Prototyping boards (as needed)
  38. Buzzer (x2)


List with some of the mechanical components needed for the rover:

  1. Metal servo horn/arm with round/disk shape - 12
  2. M3 threaded insert - 100 (approximate)
  3. M4 threaded insert - 30 (approximate)
  4. Neodymium magnets - 8x2mm - 10
  5. Aluminum 20mm tube - see rover 3D design for quantity and lengths
  6. Aluminum or PVC 25mm tube - see rover's robotic arm 3D design for quantity and lengths
  7. T-slot aluminum profile 20x20mm - see rover 3D design for quantity and lengths


A list with the rest of the mechanical components needed for the rover can be found in the website of the original project used for the rover's 3D design.

These hardware and mechanical components were purchased on Aliexpress, but most of them are also available on Amazon.

3D Print All the Parts

assembly5.jpeg
assembly6.jpeg

Open the designs in the Fusion360 app and export each of the components to a STL format so they can be send to the Slicer and printed.

The original design of the Mars rover model can be found in this Cults3D page. The original design of the robotic arm can be found in this GitHub page. Lots of modifications were made to these designs, which were originally created by Dejan (HowToMechatronics) and Jakob Krantz respectively.

Since the original design of the Mars rover is not free (it has to be purchased via the Cults3D page provided before) only the parts of the rover that were created from scratch are present in the rover_modified_and_new_parts.f3d design file. Since the original design of the robotic arm is open-source, the rover_modified_and_new_parts.f3d design file contains the parts of the robotic arm that were either created from scratch, modified or original.

The cases for the custom remote control PCB module and ESP32S3-8048 touchscreen are in this Fusion360 design file. These cases adapt to the shape of the Spektrum DX8 remote, allowing to place the custom RC module and touchscreen as add-ons.

The case for the ESP32S3-8048 touchscreen is a modified version of this case design found on Thingiverse.

Assemble the Mechanical Platform

assembly9.jpeg
assembly11.jpeg

Assemble the mechanical platform by joining the different 3D printed parts with the other mechanical parts (e.g., pvc tubes, aluminium profiles). A detailed guide for the mechanical assembly process is available in the original project used for the mechanical design.

Images showing how the OpenRover modified design was assembled are present in the README of the assembly folder of the OpenRover GitHub project.

Place Hardware Components and Create Wiring Connections

rover_schematic.png
assembly53.jpeg

Create the wiring connections for the hardware components (e.g., motors, servomotors) and between the hardware electronics (e.g., Arduino Mega, motor drivers).

To help with the wiring connections, one schematic is provided for each of the modules of the OpenRover project (central rover, remote control and touchscreen, and camera and webserver)

Images showing the soldering of various boards, the creation of electrical connections, and the placement of hardware components can be found in the README of the assembly folder.

Upload Code to Development Boards

vscode_platformio.png

For each of the OpenRover modules, set up and upload the code to the development boards.

To develop the code for the modules, PlatformIO IDE was used. This IDE is integrated into the versatile Visual Studio Code editor, and can be installed simply by searching "PlatformIO IDE" in the "Extensions" tab of Visual Studio Code.

Thanks to the use of PlatformIO, all the code, configuration files, and dependencies are in a single package. This makes it very easy to share the complete project, enabling other people to execute it right after they download it.

Since the code is modulated and quite long, no preview of the code will be shown here. Instead, links to the coding projects present in the OpenRover GitHub repository will be provided in this section.


Central rover module

Just by opening the project present in this folder with PlatformIO, connecting the Arduino Mega development board via USB, and clicking the "upload" button, the code will be uploaded to the Arduino Mega and will start executing.

The only thing that needs to be taken into account is making sure that the wiring connections to the Arduino Mega are exactly the same as the ones detailed in the wiring schematic of this module.


Remote control and touchscreen module

Remarks

The developed remote control and touchscreen module is currently an add-on to any generic RC that has a PPM output port (usually known as "Trainer Port"). The RC model that I have personally used is the Spektrum DX8.

This trainer port usually is a 3.5mm audio jack, but it is not a standard port and can also be a mini-USB, depending on the brand. The transmitters usually use PPM (Pulse Position Modulation) signals outputted from this “Trainer port” to transmit each of the RC channel values.

With the help of an Arduino Nano, these PPM signals are processed by the custom RC module of the OpenRover project. This way, the radio module of the generic RC is not used, and the only purpose of the generic RC is to send the values of its different channels (e.g., joysticks, switches…) via PPM, so that the custom RC module can receive them. In turn, this custom module uses an NRF24 radio transceiver to send the channel values to the rover using a custom communication protocol.

If instead of a generic RC, a custom RC with joysticks and switches wanted to be used, the Arduino Nano would directly read the values of these joysticks and switches instead of the PPM channel values. This adaptation would require very few modifications on the developed OpenRover hardware and software for this remote control and touchscreen module.

Code setup guide

This module is formed by two submodules, the "Arduino Nano" and the "ESP32S3 touchscreen" submodules.

Each of the two submodules is a standalone PlatformIO project. Therefore, just by opening each PlatformIO project present in this folder, connecting the ESP32S3 or Arduino Nano development board via USB, and clicking the "upload" button, the code will be uploaded to the ESP32S3 or Arduino Nano and will start executing.

The only thing that needs to be taken into account is making sure that the wiring connections of the ESP32S3 and the Arduino Nano are exactly the same as the ones detailed in the wiring schematics of this module.

Embedded UI design

To create the embedded UI design of the touchscreen, the SquareLine Studio platform and LVGL library were used. To edit the UI, these steps have to be followed:

  1. Step 1: Open the SquareLine Studio project and make the desired visual changes
  2. Step 2: Click on Export -> Export UI Files. The UI files export path must be previously specified in the "Project Settings"
  3. Step 3: Copy all the exported UI Files into the "squareLineFiles" folder of the ESP32S3 PlatformIO project, making sure to overwrite the previous files that were in this folder
  4. Step 4: Click the "upload" button in PlatformIO to upload the code to the ESP32S3. The modified UI should now appear on the touchscreen.

Three screens have been implemented in the embedded UI: Control, Monitor and Configuration.


Camera and webserver module

Before uploading this module's project code in the RaspberryPi Zero 2W, it is necessary to install and OS in the board. Specifically, the RaspberryPi OS Lite (headless version) has to be installed. This OS and an install guide can be found in the RaspberryPi website.

Once the Raspberry Pi OS is running and SSH connections can be made to be the board, it is possible to upload all the module's project code. Here is the module's project code that needs to be uploaded to the Raspberry Pi. To upload an edit the code, the best way is to install the SFTP plugin for the Visual Studio Code editor. This plugin allows to easily set up and modify the project’s file structure and file’s contents remotely from a standard PC.

Once the whole project is uploaded, you have to go inside the main project folder and execute the following command: python -m logic.main

If it is the first time you execute this command, several errors will displayed, detailing the dependencies used by the code that need to be installed. It is recommended to install this dependencies on a "virtual environment". Once these dependencies are installed, if we execute the previous command, this module's program will start running, stablishing serial communication with the Arduino Mega and generating the web dashboard.

The web dashboard will be available on the following URL: http://pizero.local:5000/monitor

If instead of the RaspberryPi connecting to an existing WiFi, you want the RaspberryPi to generate a WiFi network on its own, the following command needs to be used: sudo nmcli device wifi hotspot ssid RoverWiFi password marsRover

Optionally, the commands to generate the WiFi network and to execute the module's program can be written into a script. This script can then be called inside the /etc/rc.local file, which is executed at startup. This way, once the RaspberryPi Zero 2W is powered, it will generate the WiFi network and execute the module's program automatically. You can find and example startup script in the raspberrypi_code/scripts/ folder.

It is important to make sure that the wiring connections to the RaspberryPi Zero 2W are exactly the same as the ones detailed in the wiring schematic of this module.

Take It to the Next Level

rover_design_mars.png

Now it is your time to build upon the OpenRover platform. One of the cores ideas behind OpenRover is that people who replicate the project are able to modify and improve the platform, as it is designed to be very modular and extensible, specially on the software related side.

You can add your own upgrades to the robot, integrating new components and developing additional features.

Here are some ideas to spark inspiration for expanding OpenRover's functionalities:

  1. Rover control from the web dashboard (e.g., using draggable joysticks), which currently is only used for monitoring and displaying video feed
  2. Adding computer vision using the existing RaspberryPi camera and RaspberryPi Zero 2W board. Computer vision could be used to navigate autonomously or to track objects with the rover's tiltable and rotary head
  3. Ability to record movements for the robotic arm, allowing it to automatically fold and unfold or perform a certain procedure
  4. From the hardware schematic designs, design PCB boards that can be manufactured. These boards would be very useful to make the hardware connections more compact and to allow an easier replication of the project


Demos

demos.png

See some demos of the rover, custom remote control and monitoring web dashboard here: https://github.com/pol-valero/openrover-robotic-platform/tree/main?tab=readme-ov-file#demos