A Basic WiFi Controlled Mobile Robot With Pan & Tilt Camera

Arduino RP2040 or Raspberry Pi Pico W or ESP32 based mobile robot with on-board pan & tilt camera can be controlled remotely from host PC.

Mobile robot in action

Components Used

  • Arduino Nano RP2040 Connect or Raspberry Pi Pico W or ESP32S Micro-controller board
  • ESP32 Camera Module
  • DC-DC 3A 5V-12V to 5V Step-down Power, Supply Module
  • ESP32 CAM
  • SG90 Micro-servo motor x 2
  • Pan & Tilt Camera Assembly
  • 12V Geared DC Motors and Wheels x 4
  • Robot base frame chassis
  • 9V to 12V 2200mAH battery
  • Jumper Wires, DC Power Jack etc.

Introduction

This project demonstrates how to quickly make a simple WiFi remote controlled 4 wheeled mobile robot that has an on-board WiFi camera mounted on a servos powered pan & tilt assembly. It is manually controlled by the user from host PC through WiFi. Because of the live video from the the on-board camera, the rover need not be in line of sight from the user.

The project uses CASP for complete software implementation. It also uses a custom CASP block (where the source code is available to the user) in the native model. The custom block generates required control signals when user presses certain keys for controlling the movements of the robot. User can take a look at the configuration and source code of the block and learn how to integrate the block in a CASP model along with other blocks. User can go through our video tutorial on how to create a custom block at these links: https://aadhuniklabs.com/casp_res_videos#custom_block, https://aadhuniklabs.com/casp/casp_web_examples/general/01_custom_logic/doc/index.htm

Quick Start

Step 1. Build the hardware as described in ‘Hardware Development’ section below.

Step 2: Install latest version of CASP from this link: https://aadhuniklabs.com/?page_id=550. Please go through this link: https://aadhuniklabs.com/?page_id=554 for video tutorials on CASP. Please note that CASP version 0.9.5.1 and above is recommended for this project.

Step 3: Download the project on ‘Basic Remote Controlled Mobile Robot with on-board camera’ from the link https://aadhuniklabs.com/casp/casp_web_projects/robotics/01_rc_robot.zip and follow the steps mentioned in the ‘Software Development’ section.

Step 4: Some adjustments as described in ‘Adjustments’ section may be required for tuning the software to match your developed hardware.

Step 5: Finally, keyboard and mouse controls to control the mobile rover are described in Control Methodology section. You may change the code in the ‘rc_control’ custom block in the native model to modify the control keys as per your taste. Please write to us at https://aadhuniklabs.com/contact for any queries & suggestions related to this project.

Hardware Development

Four DC motors are fitted to a suitable metal base frame along with the wheels. Pan & tilt assembly (fitted with two micro servos) is mounted at suitable location of the base frame (preferably towards rare end of the robot base frame). A 12V battery is mounted below the base frame. Required electronic modules are suitably placed on the base frame and are connected as per the connection diagram shown in ‘Schematics’ section. Typical arrangement is shown in below figure.

Mobile robot setup

The electronics part consists of Arduino Nano RP2040 Connect micro-controller board used as the main controller on the robot that communicates with the host PC through on-board WiFi. The micro-controller generates required PWM signals to control the four wheels through suitable driver circuit. It also controls two servo motors of the camera pan & tilt assembly.

An ESP32 Camera module is mounted on the pan & tilt assembly for capturing live video and stream to the host PC.

Flash light present on the ESP32-CAM module is controlled manually from the host PC via the Arduino Nano RP2040 micro-controller during low light conditions.

A 6V to 12V battery is used to power the entire circuitry on the robot. A 6V/12V to 5V DC step down converter is used to provide required 5V supply to power the micro-controller, servos and ESP32 camera module.

Schematics

Software Development

A) Configuring ESP32 Camera

ESP32 Camera shall be properly programmed with valid IP address before using it in the project. Please refer to our ESP32-CAM example for details on how to program the module. User may also refer to abundant material available on the internet regarding this subject.

CASP software is used to quickly develop models for Arduino micro-controller target and host PC. As such two models are developed to achieve desired objective.

B) Target Model that runs on Arduino Nano RP2040 Connect consists of

1. Blink logic that indicates the system is running.

2. WiFi101 block that receives required control signals from host PC.

3. PWM and servo blocks that are mapped to the pins of the micro-controller.

4. Time delay block to reset the outputs of the PWM blocks during a communication error or when the host is not connected.

Following are the steps to properly program the target board.

1. Connect the target to the host PC via a USB cable.

2. Note the serial port number to which the board that is connected to the host PC, from the host operating system.

3. Run CASP and load the ‘rc_target’ project.

4. The WiFi101 block WiFi is set to Station mode. User may need to enter SSID and password of the network to which the device should be connected. The Local IP address parameter shall be configured as assigned by the network DHCP client of the network.

5. From CASP, open Home->Simulation->Setup Simulation Parameters menu item. Under Target HW->General tabs set ‘Target Hardware Programmer Port’ parameter to the serial port to which the board is connected.

6. Build the model and program the board by clicking on Run button.

C) Native Model that runs on Host PC consists of

1. Camera block that receives live video from the ESP32 Camera. IP address of the ESP32 Camera shall be entered in block parameters of this block.

2. Image display block to display the live video received from the camera. It is also configured to output keyboard and mouse signals.

3. RC control block: It is a custom block that receives keyboard and mouse signals from the image display block and generates suitable control signals for controlling the robot motion and its head (pan & tilt) movements.

4. GPIO blocks that maps to the target model via the WiFi communication channel.

Native model that runs on host PC

Following are the steps to run the native model on the host PC

1. Before continuing, the host PC shall be connected to the same network as the device is connected.

2. Load the ‘rc_native’ project.

3. Click on Home->Simulation->Configure Simulation IO menu item.

4. ‘Configure Simulation Hardware’ window will open. Under Native Nodes and GPIO Device Nodes, change the IP addresses marked in the below figure (by double clicking on the item) to respective local and device IP addresses.

Configure Simulation Hardware window to change IP addresses of native node (host PC) and GPIO device (Arduino RP2040)

5. Click on ‘Connect Device’ button and check the ‘Online Data’ check box. The program should now communicate with the target with cycle time around 30msecs. Target board is now available as endpoint ‘EP0’ to the native model. Native model can use this end point to connect to respective IOs on the target.

6. Click on ‘Save’ button to save the configuration and close the window.

7. Run the model by clicking on the Run button. A simulation panel window should open and communicate with the board.

8. Screen shot of the output simulation panel running on host PC and display the camera live video is shown below.

Simulation Panel Window with on-board camera live video

Adjustments

1. Wheel motor connections may be reversed to get forward or backward movement when W and S are pressed.

2. Logics for generating forward and reverse motor rotation are developed to match with the motor driver IC i.e.TA6586 used in the project. User may modify the logics suitably if other driver IC is used.

3. Servo motors may require some alignments to face towards robot forward direction for the default angle specified in the rc_control block parameters.

4. Base speed, speed limits and other parameters related to the navigation are adjustable from the rc_control block parameters.

Control Methodology

1. The simulation panel window shown above accepts keyboard & mouse inputs when it is active.

2. User can use the keyboard keys W – to move forward, S – to move backward, A – to rotate left on center and D – to rotate right on center.

3. Combination of keys W/S & A/D can be used to take left and right turns while moving forward or backward.

4. Speed can be adjusted by using Page Up & Page Down keys.

5. Vertical and horizontal servo angles (from -90 to +90 deg) for head position control can be controlled by mouse movements.

6. Key ‘G’ is used to position both servos at default angle.

7. Key ‘L’ is used to ON/OFF the flash LED light of the ESP32 camera.