BeagleBoard/GSoC/2021 Proposal/DhruvaGole

From eLinux.org
< BeagleBoard‎ | GSoC
Revision as of 21:30, 1 April 2021 by DhruvaG2000 (talk | contribs) (Details of implementation)
Jump to: navigation, search


Proposal for Librobotcontrol Lib support for Beagleboard AI

About Student: Dhruva Gole
Mentors: Jason Kridner
Code: gsoc-application
Wiki: http://elinux.org/BeagleBoard/GSoC/ProposalTemplate
GSoC: GSoC entry

Status

This project is currently just a proposal.

Proposal

Completed all the requirements listed on the ideas page. The code for the cross-compilation task can be found here submitted through the pull request #149.


About you

IRC: dhruvag2000
Github: https://github.com/DhruvaG2000
School: Veermata Jijabai Technological Inst.
Country: India
Primary language : English, Marathi, Hindi
Typical work hours: 10AM - 7PM Indian Standard Time
Previous GSoC participation: I find embedded and IOT pretty interesting, given I have experience with ESP32, SIMCOM, ESP8266, Arduino UNO I think I will be able to excel in this project. This is the first time i am participating in GSoC.


About your project

Project name: librobotcontrol support for BeagleBone AI

Description

Introduction

BeagleBone gets used a lot in automation tasks, be they in industrial, building, home or otherwise. Software that helps enable individual hobbyists, but can bridge into professional automation tasks, is strongly desired.
The Robot Control Library package contains the C library and example/testing programs for the Robot Control project. This project began as a hardware interface for the Robotics Cape and later the BeagleBone Blue and was originally called Robotics_Cape_Installer. It grew to include an extensive math library for discrete time feedback control, as well as a plethora of POSIX-compliant functions for timing, threads, program flow, and lots more, all aimed at developing robot control software on embedded computers.

The Robotics Cape

The Robotics Cape (ref) brings the power of the BeagleBone Black to your robotics project with almost no setup time. Built by engineers for engineers, the Robotics Cape is loaded with innovative features and a library designed to effortlessly take your robotics concepts from design to reality. (source)
It has the following Technical Specifications :-

  1. 2 Cell Lipo Charging, Balancing, and Protection
  2. Battery Charge Inidcator LEDs
  3. 4 H-Bridge DC Motors Controllers 1.2A each
  4. 8-Channel Servo/ESC Output Enabled by PRU
  5. 6V 4A Regulated Power Supply to Protect Servos
  6. 9-Axis IMU: Invensense MPU-9250, and many more on-board peripherals that any robotic enthusiast or developer can want!
Why does incompatibility arise?

One may think that all BB Boards have the same form factor and run linux so where does the question of incompatibility arise right? To answer that question, let's take an example of (LED Pins. In the BBBWL/BBB, /sys/class/leds/led_P8_03 links to gpio1_6 whereas in the BBAI it is linked to gpio1_24. Pins gpio3_18,19,20 that are there in BBBWL/BBB are simply non existent in the BBAI.
As seen from the led library file let's say that user wants to control RC_LED_GREEN, which is say having the value of gpio1_0 in the BBBWL/BBB. But this same symlink is at gpio6_31 of BBAI. (refer here).
Similarly, ADC, PWM, eCAP, LCD, etc. have differences in the way that their Header Pins are linked in the system. This can cause massive issues while using the current version of Robot Control Library, as it takes into account only the BBBWL/BBB pins. Thus it is essential that we modify the libraries to support the BBAI without breaking support for the BBBWL/BBB.

Device tree overlays

Device tree overlays are a very important part of the main idea of this project which is to make the same user-space examples work with both BeagleBone Black and AI. the same references will be used in the drivers for peripherals assigned to the same pins between Black and AI. (ref)
Although this has already been done as part of GSoC2020, certain issues have occured that indicate some incompatibility issues. This project aims at resolving all such issues. The most recent issue has been raised here which says PWM, eQEP, and i2c still don't work.

Why to port it to the BeagleBone AI?

Built on the proven BeagleBoard.org® open source Linux approach, BeagleBone® AI fills the gap between small SBCs and more powerful industrial computers. Based on the Texas Instruments AM5729, developers have access to the powerful SoC with the ease of BeagleBone® Black header and mechanical compatibility. BeagleBone® AI makes it easy to explore how artificial intelligence (AI) can be used in everyday life via the TI C66x digital-signal-processor (DSP) cores and embedded-vision-engine (EVE) cores supported through an optimized TIDL machine learning OpenCL API with pre-installed tools. Focused on everyday automation in industrial, commercial and home applications.
It uses the Dual Arm® Cortex®-A15 microprocessor subsystem and further specs can be found on the official website

What I like most about librobotcontrol, is that it allows new users to get a very intuitive hardware interface for the board it is being used on. Currently it only supports Robotics Cape and the BeagleBone Blue and Black. But with the evolution of AI on the edge, porting this library to be used onboard the BeagleBone® AI will prove to be very useful to a lot of hardware enthusiasts, AI/ML developers and hobbyists to deploy edge computing solutions along with easy to program hardware.

Features to be implemented
  1. Implement the librobotcontrol package to support the BeagleBone® AI.
  2. Implement all the existing examples to run on BeagleBone® AI.
  3. Add the necessary docs on librobotcontrol website .

Details of implementation

The above cape needs the Robot Control Library (ref documentation) to function. Currently, this is only available for the BeagleBone Blue and Black.
However, the BeagleBone® Blue lacks TI C66x digital-signal-processor (DSP) cores and embedded-vision-engine (EVE) cores which the AI board has. This enables machine learning tools to be integrted with a device capable of programmable hardware IOs. However it still lacks a proper hardware interface which is where the need to provide librobotcontrol support comes in.
The beaglebone AI has many programmable PRU General-Purpose Output and Input pins as give on device docs page
Implement all libraries under Robot Control Library (repo here to simplify tasks like writing to a pin, reading from a pin, delay, motor control, etc.

Reimplement stock examples in librobotcontrol repository
  1. bare_minimum
  2. blink
  3. read and write operation of UART buses
  4. test_adc

I intend to port as many examples as the board can support using it's hardware to the examples directory.

The How

Inorder to accomplish the above tasks, I will go through the pins of the beagle AI and accordingly make changes in the header files. For this, I have familiarized myself with the device tree for BeagleBone® AI. Also, I will be using the SRM(System Ref. Manual) which is given on this page and the BeagleBone cape interface spec is here. This is a list of symlink interfaces based on BeagleBone Cape header pins.

  1. LEDs: The compatibility layer comes with simple reference nodes for attaching LEDs to any gpio pin. (see here. For example, in the BBBWL/BBB, /sys/class/leds/led_P8_03 links to gpio1_6 whereas in the BBAI it is linked to gpio1_24. Pins gpio3_18,19,20 that are there in BBBWL/BBB are simply non existent in the BBAI.
  2. I2C: Compatibility layer provides simple I2C bone bus nodes for creating compatible overlays for BBBWL, BBB, & BBAI.
  3. SPI: SPI bone bus nodes allow creating compatible overlays for BBBWl, BBB, & BBAI.
  4. UART: UART bone bus nodes allow creating compatible overlays for BBBWl, BBB, & BBAI.

and many more like ADC, PWM, eCAP, LCD, etc. have differences in the way that their Header Pins are linked in the system. The current Device Tree Overlay implemented here seems to be causing issues with the PWM, eQEP, and i2c. Thus I will be working on adding more stability to the cape compatibility and then once the interfaces (links) are stable, update the library. One can find the template for the Device tree overleays here. Only Pins are being actively used are to be commented out.

Syntax of DT Overlay

It can be seen below from the syntax

bone_i2c_1: &i2c5 {
symlink = "bone/i2c/1";
};

This essentially indicates that at location bone/i2c/1 is the symbolic link pointing to i2c5 port. However, upon searching the entire BBAI overlays, nowhere has i2c5 been defined, which might be what is causing issues here

Timeline

May 17 Proposal accepted or rejected
  • Community Bonding Period and discussion on the project and resources available.
  • Setting up beaglebone-ai i.e flashing up to date Linux image and connect to local area network (LAN) via either Ethernet or WiFi and try to run bare_minimum code from this repository to test basic stuff is working.
Jun 07 Pre-work complete Coding officially begins!
June 17 Milestone #1
  • Introductory YouTube video
  • Making the button.h and led.h libraries compatible with the AI board.
June 24 Milestone #2
  • Implementing rc_led_set, rc_led_cleanup, rc_button_cleanup and the rc_set_state functions specific to beagle AI.
  • Testing the above functions
  • Writing documentation for same
June 30 Milestone #3
  • Implementing rc/time.h library and it's functions rc_nanos_since_epoch(), rc_nanos_since_boot, rc_nanos_thread_time.
  • Testing the above functions
  • Writing documentation for same
July 12 -July 16 18:00 UTC Milestone #4 (Phase 1 evaluations)
  • Demonstrating use of implemented functions by creating and executing an example program to demonstrate use of LEDs and button handlers.
  • Finalizing and documenting everything done till now, submitting first report for evaluation.
July 23 Milestone #5
  • Porting the uart library
  • Testing the functions like rc_uart_write, rc_uart_read_bytes , etc.
  • Writing documentation
July 30 Milestone #6
Aug 06 Milestone #7
  • Implement rest of the examples including servo motors, motors, Accelerometer, gyroscope, etc.
  • Writing examples and documentation for above implemented protocols
August 10 Milestone #8 (Phase 2 evaluations)
  • Testing and demonstrating all other librobotcontrol examples on the BBAI to prove complete compatibility.
  • Finalizing and documenting everything done till now, submitting second report for evaluation
August 16 - 26 18:00 UTC Final week: Students submit their final work product and their final mentor evaluation
August 23 - 30 18:00 UTC Mentors submit final student evaluations

Experience and approach

I have used C++, C and Python programming languages over the past 3 years in a variety of projects involving embedded systems using the ESP32, Arduino UNO, ESP8266 and am also well-versed with freeRTOS.
I have an aptitude for writing good reports and blogs, and have written a small blog on how to use a debugger.
I recently did a project using ESP32, in which I used the DHT11 sensor to display humidity and temperature on a local HTML server . Other than that I have developed firmware for a 3 DOF arm based on an ESP32 custom board. I also interned at an embedded device startup where I

  1. Interfaced ADS1115 ADC with the ESP32 and used it to read battery voltage.
  2. Used UART for ESP32 and SIMCOM SIM 7600IE communication to gain LTE support.
  3. Published local sensor data to the cloud via LTE.


I actively contribute to open source and do a lot of mini projects throughout the year, you can find my several more interesting projects at my github page

Contingency

I believe that if I get stuck on my project and my mentor isn’t around, I will use the resources that are available to me. this includes looking on online forums for support, trying approaches that have worked from previous experience and also getting in touch with professionals via IRC/other media for support.

Benefit

librobotcontrol uses specific GPIO, I2C, SPI ports and the indexes all need to be updated to use the Cape Compatibility layer in a way that causes old BeagleBone Black + RC and BeagleBone Blue without the Cape Compatibility layer not to break.

-Jason Kridner