Difference between revisions of "BeagleBoard/GSoC/2021 Proposal/DhruvaGole"

From eLinux.org
Jump to: navigation, search
(Details of implementation)
(Details of implementation)
 
(82 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
[[Category: GSoCProposal2021]]
 
[[Category: GSoCProposal2021]]
  
=[https://elinux.org/BeagleBoard/GSoC/2020Proposal/VedantParanjape Proposal for Librobotcontrol Lib support for Beagleboard AI] =
+
=[https://elinux.org/BeagleBoard/GSoC/2021_Proposal/DhruvaGole#Proposal_for_librobotcontrol_support_and_Robotics_Cape_Compatibility_for_Beagleboard_AI Proposal] for librobotcontrol support and Robotics Cape Compatibility for Beagleboard AI =
  
 
<!--   
 
<!--   
{{#ev:youtube|Jl3sUq2WwcY||right|BeagleLogic}}latest video will go here  
+
{{#ev:https://www.youtube.com/watch?v=neaFAZHc8F0}}latest video will go here  
A short summary of the idea will go here.
+
BBAI has seen rising popularity for being a very powerful industrial computer, and the persence of embedded-vision-engine cores, that enable many AI applications. However, due to the different AM5729 processor than the older BB blue and black AM335x, the librobotcontrol package currently lacks compatibility with the Robotics Cape on BBAI. This project aims at providing that compatibility.  
 
-->
 
-->
 
About
 
About
 
''Student'': [https://elinux.org/User:DhruvaG2000 Dhruva Gole]<br>
 
''Student'': [https://elinux.org/User:DhruvaG2000 Dhruva Gole]<br>
 
''Mentors'': [http://elinux.org/User:Jkridner Jason Kridner]<br>
 
''Mentors'': [http://elinux.org/User:Jkridner Jason Kridner]<br>
''Code'': [https://github.com/DhruvaG2000/gsoc-application gsoc-application]<br>
+
''Code'': [https://github.com/beagleboard/librobotcontrol librobotcontrol]<br>
 
''Wiki'': http://elinux.org/BeagleBoard/GSoC/ProposalTemplate<br>
 
''Wiki'': http://elinux.org/BeagleBoard/GSoC/ProposalTemplate<br>
 
''GSoC'': [https://elinux.org/BeagleBoard/GSoC/Ideas-2021#librobotcontrol_support_for_BeagleBone_AI_and_Robotics_Cape GSoC entry]<br>
 
''GSoC'': [https://elinux.org/BeagleBoard/GSoC/Ideas-2021#librobotcontrol_support_for_BeagleBone_AI_and_Robotics_Cape GSoC entry]<br>
Line 26: Line 26:
 
==About you==
 
==About you==
 
''IRC'': dhruvag2000<br>
 
''IRC'': dhruvag2000<br>
''Github'': https://github.com/DhruvaG2000<br>
+
''Github'': [https://github.com/DhruvaG2000 DhruvaG2000]<br>
''School'': Veermata Jijabai Technological Inst.<br>
+
''School'': [http://vjti.ac.in/ Veermata Jijabai Technological Inst.]<br>
 
''Country'': India<br>
 
''Country'': India<br>
 
''Primary language'' : English, Marathi, Hindi<br>
 
''Primary language'' : English, Marathi, Hindi<br>
 
''Typical work hours'': 10AM - 7PM Indian Standard Time<br>
 
''Typical work hours'': 10AM - 7PM Indian Standard Time<br>
''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.  
+
''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==
 
==About your project==
''Project name'': librobotcontrol support for BeagleBone AI<br>
+
''Project name'': librobotcontrol support for the Robotics Cape with the BeagleBone AI<br>
  
 
==Description==
 
==Description==
  
 
;Introduction
 
;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. <br>
+
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. This is where the Robot Control Library comes into the picture. <br>
 +
;Robot Control Library
 
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 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.
:This project will enable the control of the Beaglebone's PRUs using remoteproc and rpmsg driver rather than using uio drivers. The PRU is a dual core micro-controller system present on the AM335x SoC which powers the BeagleBone. It is meant to be used for high speed jitter free IO control. Being independent from the linux scheduler and having direct access to the IO pins of the BeagleBone Black, the PRU is ideal for offloading IO intensive tasks. <br>  
+
<br>
The library and example programs are primarily written in C, and has been well tested on the BeagleBone Blue.
+
; The Robotics Cape
 +
The Robotics Cape ([http://strawsondesign.com/ ref]) brings the power of the BeagleBone Boards to your robotics projects 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. ([http://strawsondesign.com/#!board-default source])
 +
<br>
 +
It has the following [http://strawsondesign.com/#!board-specs Technical Specifications] :-
 +
#2 Cell Lipo Charging, Balancing, and Protection
 +
#Battery Charge Inidcator LEDs
 +
#4 H-Bridge DC Motors Controllers 1.2A each
 +
#8-Channel Servo/ESC Output Enabled by PRU
 +
#6V 4A Regulated Power Supply to Protect Servos
 +
#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 just have a look at both their processors, the BB AI has ''am572x''
 +
and the beagleboard Black/Blue have ''am372x'', and these two being different processor altogether, don't exactly have the same pin-configurations(although somewhat similar). <br>
 +
Let's have a look at [https://github.com/jadonk/librobotcontrol/blob/bbai/library/include/rc/led.h the led library file] and line 54 of [https://github.com/jadonk/librobotcontrol/blob/bbai/library/src/led.c led.c file] that help control the LEDs on BeagleBone Blue+Robotics Cape. <br>
 +
 
 +
We initialize a single led file descriptor. like this,
 +
SYSFS_LED_DIR "%s" BRIGHTNESS_FILE, paths[(int)led]
 +
where
 +
SYSFS_LED_DIR
 +
is ''/sys/class/leds/''
 +
and
 +
BRIGHTNESS_FILE
 +
is "/brightness"
 +
and
 +
paths[(int)led]
 +
appends the LED number (eg. 0 for green) to the overall path string('''Note''' That we have all of BB IO's accessible in the form of sysfs entries). Let's say that user wants to control RC_LED_GREEN, which is at suppose gpio1_0 in the BBBWL/BBB + Robotics Cape. But this may not be the case, as  the green LED maybe at a different GPIO in the BBAI+Robotics Cape. ([https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec#LEDs refer here]). <br>
 +
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 pin configs.  Thus it is essential that we modify the libraries and it also maybe necessary to write some DT overlays to support the BBAI+RC without breaking support for the BBBWL/BBB.
 +
<br>
 +
The main idea of this project which is to make the same user-space examples work with both BeagleBone Black and AI. '''Device tree overlays''' play a very important role to achieve this. The same references will be used in the drivers for peripherals assigned to the same pins between Black and AI. ([https://elinux.org/BeagleBoard/GSoC/2020_Projects/Cape_Compatibility ref]) <br>  
 +
Although this has partially been done as part of GSoC2020([https://summerofcode.withgoogle.com/archive/2020/projects/6248850903269376/ by lorforlinux], [https://elinux.org/BeagleBoard/GSoC/2020_Projects/Cape_Compatibility project proposal] ), DT Overlays for the Robotics Cape were yet to be written. This project aims at resolving all such issues and providing DT Overlays for the Robotic Cape on the BBAI.
 +
The most recent issue has been raised [https://github.com/beagleboard/librobotcontrol/issues/173 here] which indicated the need of BBAI users to use the librobotcontrol package on the BBAI, for which it will be necessary to make few changes in the libraries and probably add a few more DT overlays to expand cape compatibility to the Robotics cape<br>
  
 
;Why to port it to the BeagleBone AI?
 
;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. <br>  
+
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. <br>  
:It uses the Dual Arm® Cortex®-A15 microprocessor subsystem and further specs can be found on [https://beagleboard.org/ai the official website]  <br>  
+
It uses the Dual Arm® Cortex®-A15 microprocessor subsystem and further specs can be found on [https://beagleboard.org/ai the official website]  <br>  
  
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.  
+
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. Robots that use Computer Vision/ speech recognition or other AI alongside performing Real-time tasks like self balancing will be in most benefit from this project.
  
 
;Features to be implemented:
 
;Features to be implemented:
# [https://github.com/jadonk/librobotcontrol/tree/bbai Port this] package to support the BeagleBone® AI.
+
#Implement [https://github.com/jadonk/librobotcontrol/tree/bbai the librobotcontrol] package to support the BeagleBone® AI.
# Port all the existing examples to run on BeagleBone® AI.
+
#Implement all the existing examples to run on BeagleBone® AI.
# Fill out the [https://github.com/beagleboard/beaglebone-ai/wiki/System-Reference-Manual#87-spi TODO]s on the official System Reference Manual of the beaglebone AI
+
#Add the necessary docs on [http://www.strawsondesign.com/docs/librobotcontrol/index.html librobotcontrol website ].
# Add the necessary docs on [http://www.strawsondesign.com/docs/librobotcontrol/index.html librobotcontrol website ].
 
  
 
==Details of implementation==
 
==Details of implementation==
; The Robotics Cape
+
The above cape needs the [http://strawsondesign.com/docs/librobotcontrol/index.html Robot Control Library (ref documentation)] to function. Currently, this is only available for the BeagleBone Blue and Black. 
The Robotics Cape 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. ([http://strawsondesign.com/#!board-default source])
 
 
<br>
 
<br>
It has the following [http://strawsondesign.com/#!board-specs Technical Specifications] :-
+
However, the [https://beagleboard.org/blue 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 integrated 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.
# 2 Cell Lipo Charging, Balancing, and Protection
 
# Battery Charge Inidcator LEDs
 
# 4 H-Bridge DC Motors Controllers 1.2A each
 
# 8-Channel Servo/ESC Output Enabled by PRU
 
# 6V 4A Regulated Power Supply to Protect Servos
 
# 9-Axis IMU: Invensense MPU-9250, and many more on-board peripherals that any robotic enthusiast or developer can want!
 
 
<br>  
 
<br>  
:The above cape needs the [http://strawsondesign.com/docs/librobotcontrol/index.html Robot Control Library (ref documentation)] to function. Currently, this is only available for the BeagleBone Blue and Black.
+
The beaglebone AI has many programmable PRU General-Purpose Output and Input pins as give on [https://github.com/beagleboard/beaglebone-ai/wiki/System-Reference-Manual#detailed-hardware-design device docs page]
:However, the [https://beagleboard.org/blue 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.
+
<br>
:The beaglebone AI has many programmable PRU General-Purpose Output and Input pins as give on [https://github.com/beagleboard/beaglebone-ai/wiki/System-Reference-Manual#detailed-hardware-design device docs page]
+
Implement all libraries under Robot Control Library ([https://github.com/beagleboard/librobotcontrol repo here] to simplify tasks like writing to a pin, reading from a pin, delay, motor control, etc. Most recent [https://github.com/beagleboard/librobotcontrol/pull/183 PR#183] that was merged to the official librobotcontrol repository has done addition of BeagleBone AI model in the makefile and model.h header files. Other than that it has been able to get adc, LEDs, and servos working under the version 1.1. This project aims to continue on those lines to support the rest of the cape support for BBAI. 
 +
<br>
 +
;Reimplement stock examples in librobotcontrol repository
 +
# [https://github.com/jadonk/librobotcontrol/tree/master/examples/bare_minimum bare_minimum]
 +
# [https://github.com/jadonk/librobotcontrol/tree/master/examples/blink blink]
 +
# [http://strawsondesign.com/docs/librobotcontrol/rc_uart_loopback_8c-example.html read and write operation of UART buses]
 +
# [https://github.com/jadonk/librobotcontrol/tree/master/examples calibrate IMU]
 +
# [https://github.com/jadonk/librobotcontrol/tree/master/examples/balance Self Balancing].
 +
I intend to port as many examples as the board can support using it's hardware to the examples directory.
  
:Implement all libraries under Robot Control Library ([https://github.com/beagleboard/librobotcontrol repo here] to simplify tasks like writing to a pin, reading from a pin, delay, motor control, etc.
+
;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 [https://github.com/beagleboard/beaglebone-ai/wiki/System-Reference-Manual on this page] and the BeagleBone cape interface spec is [https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec here].
 +
This is a [https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec list] of symlink interfaces based on BeagleBone Cape header pins.
 +
#LEDs: The compatibility layer helps in connecting an LED driver to any GPIO pin and using the LED driver instance name to map to the same header pin, despite whatever GPIO it is on. ([https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec#LEDs 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. It is to be noted that pins gpio3_18,19,20 that are there in BBBWL/BBB are simply non existent in the BBAI.   
 +
#I2C, SPI, UART: Compatibility layer provides simple I2C,SPI,UART bone bus nodes for creating compatible overlays for BBBWL, BBB, & BBAI.
 +
#PWM: The link ''/dev/bone/pwm/1'' points to ''PWM1'' in the BBB but to ''PWM3'' in the BBAI (ref [https://github.com/lorforlinux/BeagleBoard-DeviceTrees/blob/97a6f0daa9eab09633a2064f68a53b107d6e3968/src/arm/bbai-bone-buses.dtsi#L415 here])
 +
 +
and many more like timer PWM, ADC, eCAP, etc. have differences in the way that their Header Pins are linked in the system due to the difference in onboard processor. The current librobotcontrol version running with the Device Tree Overlay in place [https://deepaklorkhatri.me/GSoC2020_BeagleBoard.org/ here] seems to be causing [https://github.com/beagleboard/librobotcontrol/issues/173 issues] with the PWM, eQEP, and i2c. Thus I will be working on adding more stability to the robotics cape compatibility and then once the interfaces (links) are stable, update the library. One can find the template for the [https://github.com/lorforlinux/bb.org-overlays/blob/master/src/arm/BBAI_TEMPLATE.dts Device tree overleays here]. Only Pins that are being actively used are to be commented out.
 +
;DT Overlays level
 +
Instead of altering the kernel source and rebuilding, it is possible for users to simply specify the driver to instantiate and provide all of the information needed to configure the driver in the device tree overlay fragement, as long as the driver or driver module is already built and included. (ref. from [https://github.com/jadonk/validation-scripts/blob/master/test-capemgr/README.md here])
  
;Port all the existing examples to work on beagle AI.
+
It can be seen below from the device tree syntax <br>
 
+
bone_i2c_1: &i2c5 {
:Reimplement stock examples in librobotcontrol repository
+
symlink = "bone/i2c/1";
:# [https://github.com/jadonk/librobotcontrol/tree/master/examples/bare_minimum bare_minimum]
+
};
:# [https://github.com/jadonk/librobotcontrol/tree/master/examples/blink blink]
+
that at location(AKA bone-bus) bone/i2c/1 is the symbolic link pointing to i2c5 port. If you [https://github.com/lorforlinux/bb.org-overlays/blob/bone_i2c/src/arm/BONE-I2C1.dts look this up]
:# [http://strawsondesign.com/docs/librobotcontrol/rc_uart_loopback_8c-example.html read and write operation of UART buses]
+
Code:
:# [https://github.com/jadonk/librobotcontrol/tree/master/examples/test_adc test_adc]
+
&ocp {
:I intend to port as many examples as the board can support using it's hardware to the examples directory.
+
    P9_18_pinmux { pinctrl-0 = <&P9_18_i2c_pin>; }; /* i2c sda */
 +
    P9_17_pinmux { pinctrl-0 = <&P9_17_i2c_pin>; }; /* i2c scl */
 +
};
 +
In the BBB /dev/bone/i2c/1 points to I2C1, but in the BBAI to I2C5. The above overlay fixes that by using the DT Overlay mentioned above and this has already been done as part of last year's GSoC (2020).
 +
However, due to unavailability of the Robotics Cape, Overlays for it could not be written. Thus, the above mentioned [https://github.com/beagleboard/librobotcontrol/issues/173 issue#173] contains the following errors:
 +
ERROR: i2c1 driver not loaded
 +
ERROR: i2c2 driver not loaded
 +
Upon further investigation, I was unable to find the proper code in the librobotcontrol repo that enables BBAI driver support. Also,
 +
ERROR: ti-pwm driver not loaded for hrpwm0
 +
ERROR: ti-pwm driver not loaded for hrpwm1
 +
ERROR: ti-pwm driver not loaded for hrpwm2
 +
ERROR: ti-eqep driver not loaded for eqep0
 +
ERROR: ti-eqep driver not loaded for eqep1
 +
ERROR: ti-eqep driver not loaded for eqep2
 +
All these errors indicate that even though cape compatibility at the Device Tree Level has been brought to the BBAI to somewhat make it look like a BB Blue, there are still many changes lacking in the user space code that constrict the full usage of librobotcontrol package. Thus my work will aim at first creating the overlay for Robotics cape! and adding user space code in librobotcontrol,that will make drivers compatible with the BBAI. I will also  be testing everything to ensure that no bugs are encountered after the period of my project gets over.
 +
Referring to the example devicetree overlay [https://github.com/jadonk/validation-scripts/blob/master/test-capemgr/README.md here] and also referring to [https://www.youtube.com/watch?v=wui_wU1AeQc&t=1735s this instruction video], I will be writing the device tree overlay for Robotics Cape as follows.
 +
<br>
 +
;;Specifying compatibility:
 +
compatible = "ti,beaglebone", "ti,beaglebone-black","ti,beaglebone-AI";
 +
<br>
 +
;;Target Processor
 +
target = <&am5xx_pinmux>;  //as the BBAI has the new am5X series processor
 +
<br>
 +
;;The overlay
 +
<Offset address for the pins>, <PINMODE (GPIO/PWM/ADC/PULL UP/DOWN/etc.)> as follows: (just an example for a LED attached to P9_12) 
 +
  0x078 0x07
 +
Here, <br>
 +
''0x078'' is the ''offset'' from base address, and it points to ''P9_12''. <br>
 +
and ''0x07'' is the PINMODE corresponding to OUTPUT.
 +
<br>
 +
;user space level
 +
For example, if the code is built on a BBAI, [https://github.com/beagleboard/librobotcontrol/blob/999cbe22fa5cc3f5fed7143aa5ddd8269bdacb69/examples/src/rc_model.c the function]
 +
rc_model()
 +
which prints the current BealgleBoard model the software is running on. I will add if conditions like
 +
if(rc_model()==MODEL_BB_AI || rc_model()==MODEL_BB_AI_RC)
 +
inside which will be code written specific for the BBAI keeping it's pins in mind. In the else condition will be the code for the regular Blue and Black, so that while adding BBAI support, the blue and black boards are not made incompatible.
 +
Let's have a look at the table describing Index, Header pin and the corresponding variable in BBB and BBAI:
 +
([https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec#ADC taken from here])
 +
{| class="wikitable" style="text-align: center;"
 +
|-
 +
! Index !! Header pin !! BBBWL/BBB !! BBAI
 +
|-
 +
! 0
 +
| P9_39 || in_voltage0_raw || in_voltage0_raw
 +
|-
 +
! 1
 +
| P9_40 || in_voltage1_raw || in_voltage1_raw
 +
|-
 +
! 2
 +
| P9_37 || in_voltage2_raw || in_voltage3_raw
 +
|-
 +
! 3
 +
| P9_38 || in_voltage3_raw || in_voltage2_raw
 +
|-
 +
! 4
 +
| P9_33 || in_voltage4_raw || in_voltage7_raw
 +
|-
 +
! 5
 +
| P9_36 || in_voltage5_raw || in_voltage6_raw
 +
|-
 +
! 6
 +
| P9_35 || in_voltage6_raw || in_voltage4_raw
 +
|-
 +
|}
 +
As we can see, for example ''P9_35'' of the BBB is accessed as ''in_voltage6_raw'', but in BBAI is accessible as ''in_voltage4_raw''. Inorder to take into account this mismatch, a macro like
 +
ADC2AI(x) (x==0?4:(x==1?6:(x==2?7:(x==3?5:(x==4?3:(x==5?2:(x==6?0:-1)))))))
 +
/*(Inorder to understand the above syntax, one can refer https://www.geeksforgeeks.org/conditional-or-ternary-operator-in-c-c/) */
 +
is already in place, in this case the ''ADC2AI'' macro helps to match the BBAI pins.
 +
<br>
 +
However, I will be trying to make librobotcontrol a good example for how programs can be written in a binary-compatible format to run on both AM3358 and AM5729
 +
;Software required and Programming Languages:
 +
The project requires the use of the device tree compiler (dtc) for compiling the device tree source (ex. *.dts, *.dtsi) files.
 +
It also uses the C programming language for re-programming the headers and source files and the gcc compiler along with other build tools will be used for compiling the C source code (*.c).
  
; The How
+
;Hardware Level (testing and assembly)
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 [https://github.com/beagleboard/beaglebone-ai/wiki/System-Reference-Manual on this page] and the BeagleBone cape interface spec is [https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec here]  
+
For verifying ''rc_balance'' example, I am planning to use the Balboa 32U4 Balancing Robot Kit from pololu. This kit is however not directly compatible with the Beagle AI, hence certain makeshifts will have to be made inorder to mount the Robotics Cape+BBAI onto it's chassis. This means I will be completely bypassing the ATmega32U4 MCU, motor drivers, quadrature encoders, and a full IMU already onboard the Balboa control board, and instead use the robotics cape's on-board IMU and motor drivers. 
 +
==== Hardware required: ====
 +
The hardware listed below will be necessary for testing that my code implementation work correctly on the hardware.
 +
# [https://www.digikey.com/product-detail/en/seeed-technology-co-ltd/102110362/1597-102110362-ND/10492208 BeagleBone AI].
 +
# BeagleBone Robotics cape: [https://beagleboard.org/static/images/capes/600px/roboticscape-top-angle3.jpg Robotics Cape], and [https://www.element14.com/community/docs/DOC-94942/l/beaglebone-ai-fan-cape fan cape] as many users reported heating issues in the BBAI without it.
 +
# [https://www.pololu.com/product/3575 Balboa 32U4 Balancing Robot Kit], additional hardware for using it:
 +
## JST SH Jumper [https://www.sparkfun.com/products/10359 4 Wire] and [https://www.sparkfun.com/products/10361 6 Wire].
 +
## [https://www.seeedstudio.com/Grove-Universal-4-Pin-to-Beagleboner-Blue-6-Pin-Female-JST-SH-Conversion-Cable-10-pcs-pack.html Grove Universal 4 Pin to Beaglebone® 6 Pin Female].
 +
## [https://www.seeedstudio.com/Grove-Universal-4-Pin-to-Beagleboner-Blue-4-Pin-Female-JST-SH-Conversion-Cable-10-pcs-pack.html Grove Universal 4 Pin to Beaglebone® Blue 4 Pin Female]. 
 +
## [https://www.pololu.com/product/3074 6V Gearmotor with Extended Motor Shaft].
 +
## [https://www.pololu.com/product/1430 Pololu Wheel 80×10mm Pair - Black].
 +
## Six qty. of [https://www.pololu.com/product/1003 - Rechargeable NiMH AA Battery: 1.2 V, 2200 mAh, 1 cell].
 +
# [https://www.sparkfun.com/products/13302 DC Motor] (for testing basic motor driver code).
 +
# [https://www.digikey.com/product-detail/en/900-00005/900-00005-ND/361277?WT.mc_id=IQ_7595_G_pla361277&wt.srch=1&wt.medium=cpc&WT.srch=1&gclid=CJz-qdC9n9ICFRO4wAodOjYLuQ Servo motor].
 +
# [https://www.pololu.com/product/2072 USB A to Micro-B cable]
 +
# [https://www.adafruit.com/product/70 FTDI Serial TTL-232 USB Cable].
 +
# [https://www.amazon.in/ESnipe-Reader-Memory-Adapter-Portable/dp/B08QZLJQ9Q/ref=sr_1_3?dchild=1&keywords=SD+Card+with+USB+adapter&qid=1617689683&sr=8-3 SD Card Reader].
 +
# [https://www.amazon.in/SanDisk-Ultra-microSD-UHS-I-120MB/dp/B08L5FM4JC/ref=sr_1_3?dchild=1&keywords=64gb+sd+card&qid=1617689846&sr=8-3 SD Card]
 +
# [https://www.amazon.in/REES52-Adapter-Switch-Charger-Raspberry/dp/B07WJ34VJL 5V 3A USB type-C power supply ]
 +
# Must have lab tools like:
 +
## Solder, flux, and soldering iron.
 +
## Screwdriver set.
 +
## Tweezers and pliers.
  
 
===Timeline===
 
===Timeline===
Line 92: Line 226:
 
* Community Bonding Period and discussion on the project and resources available.  
 
* Community Bonding Period and discussion on the project and resources available.  
 
* Setting up beaglebone-ai i.e flashing [https://beagleboard.org/latest-images 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 [https://github.com/jadonk/librobotcontrol/tree/master/examples repository] to test basic stuff is working.
 
* Setting up beaglebone-ai i.e flashing [https://beagleboard.org/latest-images 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 [https://github.com/jadonk/librobotcontrol/tree/master/examples repository] to test basic stuff is working.
 
 
|-
 
|-
 
| Jun 07 || Pre-work complete || Coding officially begins!
 
| Jun 07 || Pre-work complete || Coding officially begins!
 +
* All the boards and additional hardware will be available to me at this period of time and I should have set up my BeagleBone Black and Ai boards i.e flashing up to date Linux image and Testing user-led blink code :)
 +
* Initial checks for hardware like motors and other peripheral devices will be completed and all the soldering related work will be done.
 +
* A detailed spreadsheet will be created if not already available for cape pin mapping and referencing for further use during BeagleBone AI software development ease.
 +
(above ref. from [https://elinux.org/index.php?title=BeagleBoard/GSoC/2020_Projects/Cape_Compatibility here] )
 
|-
 
|-
 
| June 17 || Milestone #1 ||  
 
| June 17 || Milestone #1 ||  
 
* Introductory YouTube video  
 
* Introductory YouTube video  
* Making the [http://strawsondesign.com/docs/librobotcontrol/button_8h.html button.h] and [http://strawsondesign.com/docs/librobotcontrol/led_8h.html led.h] libraries compatible with the AI board.
+
* Testing and debugging the [http://strawsondesign.com/docs/librobotcontrol/button_8h.html button.h] and [http://strawsondesign.com/docs/librobotcontrol/led_8h.html led.h] libraries.
 +
* Implement and debug [https://github.com/beagleboard/librobotcontrol/pull/183/commits/89d227cff70f6b287edaaea0d484771f313df650 servo] example that has been said to be working. 
 
|-
 
|-
 
| June 24 || Milestone #2 ||
 
| June 24 || Milestone #2 ||
 
* Implementing rc_led_set, rc_led_cleanup, rc_button_cleanup and the rc_set_state functions specific to beagle AI.  
 
* Implementing rc_led_set, rc_led_cleanup, rc_button_cleanup and the rc_set_state functions specific to beagle AI.  
 
* Testing the above functions
 
* Testing the above functions
* Writing documentation for same
+
* Writing documentation describing the overall structure for the same in the form of videos/ slides/flowcharts/ pseudo-codes.
 
|-
 
|-
 
| June 30 || Milestone #3 ||
 
| 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.
 
* Implementing rc/time.h library and it's functions rc_nanos_since_epoch(), rc_nanos_since_boot, rc_nanos_thread_time.
 +
* Porting the [http://strawsondesign.com/docs/librobotcontrol/uart_8h.html uart library]
 +
and implementing ''rc_uart_write'', ''rc_uart_read_bytes''
 
* Testing the above functions
 
* Testing the above functions
 
* Writing documentation for same
 
* Writing documentation for same
Line 112: Line 252:
 
| July 12  -July 16 18:00 UTC || Milestone #4 (Phase 1 evaluations) ||  
 
| 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.
 
* Demonstrating use of implemented functions by creating and executing an example program to demonstrate use of LEDs and button handlers.
 +
* Demonstrating UART application by serially communicating with an external device (Can be a simple FTDI programmer attached to my PC).
 
* Finalizing and documenting everything done till now, submitting first report for evaluation.
 
* Finalizing and documenting everything done till now, submitting first report for evaluation.
 
|-
 
|-
 
| July 23 || Milestone #5 ||
 
| July 23 || Milestone #5 ||
* Porting the [http://strawsondesign.com/docs/librobotcontrol/uart_8h.html uart library]  
+
* Adding [http://strawsondesign.com/docs/librobotcontrol/i2c_8h.html Linux I2C driver support] on the Beagle AI
* Testing the functions like rc_uart_write, rc_uart_read_bytes , etc.
+
* Add [http://strawsondesign.com/docs/librobotcontrol/group___s_p_i.html spi] support
 +
* Testing examples that use above protocols with the Robotics Cape.
 
* Writing documentation  
 
* Writing documentation  
 
|-
 
|-
 
| July 30 || Milestone #6 ||
 
| July 30 || Milestone #6 ||
* Adding [http://strawsondesign.com/docs/librobotcontrol/i2c_8h.html Linux I2C driver support] on the Beagle AI
+
* Start assembling the Balancing Robot kit for testing the self balancing codes.
* Adding examples for using I2C protocol to pair with external devices like an ADS1115.
+
* Also debug and test the robotics cape on-board sensors, ADCs and motor drivers by running examples like ''rc_test_mpu'',''rc_test_adc'', ''rc_check_battery'', ''rc_test_motors''etc.
 
|-
 
|-
 
| Aug 06 || Milestone #7 ||
 
| Aug 06 || Milestone #7 ||
* Add [http://strawsondesign.com/docs/librobotcontrol/group___s_p_i.html spi] support.
+
* Get the BBAI+Robotics Cape properly mounted on the chassis of the Balancing Robot Kit, and also try to power the Cape using batteries. (if batteries do not deliver enough current/provide enough voltage, then an external 12V adapter can be used instead).
* Writing examples and documentation for above implemented protocols
+
* Calibrate the IMU by running and debugging the ''rc_calibrate_gyro'', ''accel'' examples.    
 +
* Making Videos and documentation for above implemented examples.
 
|-
 
|-
| August 10 August 16 - 26 18:00 UTC || Milestone #8 (Phase 2 evaluations) ||  
+
| August 10 || Milestone #8 (Phase 2 evaluations) ||  
* Demonstrating use of UART, I2c and SPI to communicate with an external MCU.
+
* Testing and debugging the ''rc_balance'' librobotcontrol example on the BBAI+Robo Cape on Balancing Robot Kit to prove implementation done so far.  
 
* Finalizing and documenting everything done till now, submitting second report for evaluation
 
* Finalizing and documenting everything done till now, submitting second report for evaluation
 
|-
 
|-
| August 23 - 30 18:00 UTC || Mentors submit final student evaluations  
+
| 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===
 
===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.  <br>
+
#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 [https://dhruvag2000.github.io/gdb-for-noobs/ how to use a debugger].
+
#I have an aptitude for writing good reports and blogs, and have written a small blog on [https://dhruvag2000.github.io/gdb-for-noobs/ how to use a debugger].
<br>
+
#I recently did a [https://github.com/DhruvaG2000/ESP32_wifiDHT11 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 worked on developing hardware and making documentation for [https://github.com/SRA-VJTI/ROS-Workshop-2.1 a 3 DOF arm] based on an ESP32 custom board.  
I recently did a [https://github.com/DhruvaG2000/ESP32_wifiDHT11 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
+
#As a part of my college Robotics' Club ([https://www.sravjti.in/ SRA VJTI])Contributed to a [https://github.com/SRA-VJTI/Wall-E_v2.2 Self Balancing and Line following Robot] Workshop in 2020 where I have taught juniors the C implementation of Self Balancing and Line following algorithm using PID control. This experience will greatly benefit me in this project, since a major part of testing my work involves making/hacking a self balancing robot using the BBAI+RC and a non-custom chassis. 
# Interfaced ADS1115 ADC with the ESP32 and used it to read battery voltage.
+
#I also interned at an embedded device startup where I
# Used UART for ESP32 and SIMCOM SIM 7600IE communication to gain LTE support.
+
## Interfaced ADS1115 ADC with the ESP32 and used it to read battery voltage.
# Published local sensor data to the cloud via LTE.  
+
## Used UART for ESP32 and SIMCOM SIM 7600IE communication to gain LTE support.
<br>
+
## 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 [https://github.com/DhruvaG2000 my github page]
+
#I actively contribute to open source (most recently, I contributed to the ADS1115 library for ESP32 on the unclerus repo and can be seen [https://github.com/UncleRus/esp-idf-lib/pull/163 here]).
 +
#Currently I am working on [https://github.com/DhruvaG2000/RP2040_Dev_Board designing a Development board] for the Raspberry Pico (RP2040) using KiCAD.
 +
#I also do a lot of mini projects throughout the year, you can find my several more interesting projects at [https://github.com/DhruvaG2000 my github page]
  
 
===Contingency===
 
===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.
+
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. Some of those information portals are listed below.
 +
 
 +
# Derek Molly's [http://derekmolloy.ie/beaglebone beagle bone guide] provides all the information needed for getting up and running with my beagle.
 +
# Content on [https://e-ale.org/ e-ALE.org] is very useful for information that ranges from tutorials and walkthroughs to the level of very advanced stuff.
 +
# [https://electrovolt.ir/wp-content/uploads/2018/03/Beagle-Bone-CookBook-ElectroVolt.ir_.pdf BeagleBone cookbook] from Mark A. Yoder & Jason Kridner is the best source for test projects during the prototyping period.
 +
# The technical reference manuals provided by TI on [https://www.ti.com/lit/ds/symlink/am3358.pdf am3358] and [https://www.ti.com/lit/ds/symlink/am5729.pdf am5729] are the best source for getting the insights on the SoC used in Black and Ai. (above sourced are referred from [https://elinux.org/BeagleBoard/GSoC/2020_Projects/Cape_Compatibility here] )
 +
# [https://www.youtube.com/watch?v=wui_wU1AeQc&t=822s Beaglebone: Introduction to GPIOs - Using Device Tree Overlays]
 +
# [https://github.com/jadonk/validation-scripts/blob/master/test-capemgr/README.md example of using capemgr and devicetree overlays to configure a pinmux on the BeagleBone]
  
 
===Benefit===
 
===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.
+
The most advanced robots are those controlled by AI that can learn from their environment and experience and then build on their capabilities based on that knowledge. The BBAI enables the AI aspect of such applications as other competing boards don't have as powerful cores. The Robotics Cape on top of it, gives scope to seamless motor control and sensor integration, thus enabling the hardware and electronics part of the Robot. Thus to encourage more developers and students to take advantage of this, comes the need of the librobotcontrol that allows developers to focus more on their robotics applications in a higher level language like C with very intuitively named and well documented functions.
 +
 
 +
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
 
:-Jason Kridner

Latest revision as of 01:14, 15 April 2021


Proposal for librobotcontrol support and Robotics Cape Compatibility for Beagleboard AI

About Student: Dhruva Gole
Mentors: Jason Kridner
Code: librobotcontrol
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: 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 the Robotics Cape with the 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. This is where the Robot Control Library comes into the picture.

Robot Control Library

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 Boards to your robotics projects 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 just have a look at both their processors, the BB AI has am572x and the beagleboard Black/Blue have am372x, and these two being different processor altogether, don't exactly have the same pin-configurations(although somewhat similar).
Let's have a look at the led library file and line 54 of led.c file that help control the LEDs on BeagleBone Blue+Robotics Cape.

We initialize a single led file descriptor. like this,

SYSFS_LED_DIR "%s" BRIGHTNESS_FILE, paths[(int)led]

where

SYSFS_LED_DIR 

is /sys/class/leds/ and

BRIGHTNESS_FILE	

is "/brightness" and

paths[(int)led] 

appends the LED number (eg. 0 for green) to the overall path string(Note That we have all of BB IO's accessible in the form of sysfs entries). Let's say that user wants to control RC_LED_GREEN, which is at suppose gpio1_0 in the BBBWL/BBB + Robotics Cape. But this may not be the case, as the green LED maybe at a different GPIO in the BBAI+Robotics Cape. (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 pin configs. Thus it is essential that we modify the libraries and it also maybe necessary to write some DT overlays to support the BBAI+RC without breaking support for the BBBWL/BBB.
The main idea of this project which is to make the same user-space examples work with both BeagleBone Black and AI. Device tree overlays play a very important role to achieve this. The same references will be used in the drivers for peripherals assigned to the same pins between Black and AI. (ref)
Although this has partially been done as part of GSoC2020(by lorforlinux, project proposal ), DT Overlays for the Robotics Cape were yet to be written. This project aims at resolving all such issues and providing DT Overlays for the Robotic Cape on the BBAI. The most recent issue has been raised here which indicated the need of BBAI users to use the librobotcontrol package on the BBAI, for which it will be necessary to make few changes in the libraries and probably add a few more DT overlays to expand cape compatibility to the Robotics cape

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. Robots that use Computer Vision/ speech recognition or other AI alongside performing Real-time tasks like self balancing will be in most benefit from this project.

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 integrated 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. Most recent PR#183 that was merged to the official librobotcontrol repository has done addition of BeagleBone AI model in the makefile and model.h header files. Other than that it has been able to get adc, LEDs, and servos working under the version 1.1. This project aims to continue on those lines to support the rest of the cape support for BBAI.

Reimplement stock examples in librobotcontrol repository
  1. bare_minimum
  2. blink
  3. read and write operation of UART buses
  4. calibrate IMU
  5. Self Balancing.

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 helps in connecting an LED driver to any GPIO pin and using the LED driver instance name to map to the same header pin, despite whatever GPIO it is on. (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. It is to be noted that pins gpio3_18,19,20 that are there in BBBWL/BBB are simply non existent in the BBAI.
  2. I2C, SPI, UART: Compatibility layer provides simple I2C,SPI,UART bone bus nodes for creating compatible overlays for BBBWL, BBB, & BBAI.
  3. PWM: The link /dev/bone/pwm/1 points to PWM1 in the BBB but to PWM3 in the BBAI (ref here)

and many more like timer PWM, ADC, eCAP, etc. have differences in the way that their Header Pins are linked in the system due to the difference in onboard processor. The current librobotcontrol version running with the Device Tree Overlay in place here seems to be causing issues with the PWM, eQEP, and i2c. Thus I will be working on adding more stability to the robotics 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 that are being actively used are to be commented out.

DT Overlays level

Instead of altering the kernel source and rebuilding, it is possible for users to simply specify the driver to instantiate and provide all of the information needed to configure the driver in the device tree overlay fragement, as long as the driver or driver module is already built and included. (ref. from here)

It can be seen below from the device tree syntax

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

that at location(AKA bone-bus) bone/i2c/1 is the symbolic link pointing to i2c5 port. If you look this up Code:

&ocp {
    P9_18_pinmux { pinctrl-0 = <&P9_18_i2c_pin>; }; /* i2c sda */
    P9_17_pinmux { pinctrl-0 = <&P9_17_i2c_pin>; }; /* i2c scl */
}; 

In the BBB /dev/bone/i2c/1 points to I2C1, but in the BBAI to I2C5. The above overlay fixes that by using the DT Overlay mentioned above and this has already been done as part of last year's GSoC (2020). However, due to unavailability of the Robotics Cape, Overlays for it could not be written. Thus, the above mentioned issue#173 contains the following errors:

ERROR: i2c1 driver not loaded
ERROR: i2c2 driver not loaded

Upon further investigation, I was unable to find the proper code in the librobotcontrol repo that enables BBAI driver support. Also,

ERROR: ti-pwm driver not loaded for hrpwm0
ERROR: ti-pwm driver not loaded for hrpwm1
ERROR: ti-pwm driver not loaded for hrpwm2
ERROR: ti-eqep driver not loaded for eqep0
ERROR: ti-eqep driver not loaded for eqep1
ERROR: ti-eqep driver not loaded for eqep2

All these errors indicate that even though cape compatibility at the Device Tree Level has been brought to the BBAI to somewhat make it look like a BB Blue, there are still many changes lacking in the user space code that constrict the full usage of librobotcontrol package. Thus my work will aim at first creating the overlay for Robotics cape! and adding user space code in librobotcontrol,that will make drivers compatible with the BBAI. I will also be testing everything to ensure that no bugs are encountered after the period of my project gets over. Referring to the example devicetree overlay here and also referring to this instruction video, I will be writing the device tree overlay for Robotics Cape as follows.

Specifying compatibility
compatible = "ti,beaglebone", "ti,beaglebone-black","ti,beaglebone-AI";


Target Processor
target = <&am5xx_pinmux>;   //as the BBAI has the new am5X series processor


The overlay

<Offset address for the pins>, <PINMODE (GPIO/PWM/ADC/PULL UP/DOWN/etc.)> as follows: (just an example for a LED attached to P9_12)

 0x078 0x07

Here,
0x078 is the offset from base address, and it points to P9_12.
and 0x07 is the PINMODE corresponding to OUTPUT.

user space level

For example, if the code is built on a BBAI, the function

rc_model() 

which prints the current BealgleBoard model the software is running on. I will add if conditions like

if(rc_model()==MODEL_BB_AI || rc_model()==MODEL_BB_AI_RC) 

inside which will be code written specific for the BBAI keeping it's pins in mind. In the else condition will be the code for the regular Blue and Black, so that while adding BBAI support, the blue and black boards are not made incompatible. Let's have a look at the table describing Index, Header pin and the corresponding variable in BBB and BBAI: (taken from here)

Index Header pin BBBWL/BBB BBAI
0 P9_39 in_voltage0_raw in_voltage0_raw
1 P9_40 in_voltage1_raw in_voltage1_raw
2 P9_37 in_voltage2_raw in_voltage3_raw
3 P9_38 in_voltage3_raw in_voltage2_raw
4 P9_33 in_voltage4_raw in_voltage7_raw
5 P9_36 in_voltage5_raw in_voltage6_raw
6 P9_35 in_voltage6_raw in_voltage4_raw

As we can see, for example P9_35 of the BBB is accessed as in_voltage6_raw, but in BBAI is accessible as in_voltage4_raw. Inorder to take into account this mismatch, a macro like

ADC2AI(x) (x==0?4:(x==1?6:(x==2?7:(x==3?5:(x==4?3:(x==5?2:(x==6?0:-1)))))))
/*(Inorder to understand the above syntax, one can refer https://www.geeksforgeeks.org/conditional-or-ternary-operator-in-c-c/) */

is already in place, in this case the ADC2AI macro helps to match the BBAI pins.
However, I will be trying to make librobotcontrol a good example for how programs can be written in a binary-compatible format to run on both AM3358 and AM5729

Software required and Programming Languages

The project requires the use of the device tree compiler (dtc) for compiling the device tree source (ex. *.dts, *.dtsi) files. It also uses the C programming language for re-programming the headers and source files and the gcc compiler along with other build tools will be used for compiling the C source code (*.c).

Hardware Level (testing and assembly)

For verifying rc_balance example, I am planning to use the Balboa 32U4 Balancing Robot Kit from pololu. This kit is however not directly compatible with the Beagle AI, hence certain makeshifts will have to be made inorder to mount the Robotics Cape+BBAI onto it's chassis. This means I will be completely bypassing the ATmega32U4 MCU, motor drivers, quadrature encoders, and a full IMU already onboard the Balboa control board, and instead use the robotics cape's on-board IMU and motor drivers.

Hardware required:

The hardware listed below will be necessary for testing that my code implementation work correctly on the hardware.

  1. BeagleBone AI.
  2. BeagleBone Robotics cape: Robotics Cape, and fan cape as many users reported heating issues in the BBAI without it.
  3. Balboa 32U4 Balancing Robot Kit, additional hardware for using it:
    1. JST SH Jumper 4 Wire and 6 Wire.
    2. Grove Universal 4 Pin to Beaglebone® 6 Pin Female.
    3. Grove Universal 4 Pin to Beaglebone® Blue 4 Pin Female.
    4. 6V Gearmotor with Extended Motor Shaft.
    5. Pololu Wheel 80×10mm Pair - Black.
    6. Six qty. of - Rechargeable NiMH AA Battery: 1.2 V, 2200 mAh, 1 cell.
  4. DC Motor (for testing basic motor driver code).
  5. Servo motor.
  6. USB A to Micro-B cable
  7. FTDI Serial TTL-232 USB Cable.
  8. SD Card Reader.
  9. SD Card
  10. 5V 3A USB type-C power supply
  11. Must have lab tools like:
    1. Solder, flux, and soldering iron.
    2. Screwdriver set.
    3. Tweezers and pliers.

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!
  • All the boards and additional hardware will be available to me at this period of time and I should have set up my BeagleBone Black and Ai boards i.e flashing up to date Linux image and Testing user-led blink code :)
  • Initial checks for hardware like motors and other peripheral devices will be completed and all the soldering related work will be done.
  • A detailed spreadsheet will be created if not already available for cape pin mapping and referencing for further use during BeagleBone AI software development ease.

(above ref. from here )

June 17 Milestone #1
  • Introductory YouTube video
  • Testing and debugging the button.h and led.h libraries.
  • Implement and debug servo example that has been said to be working.
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 describing the overall structure for the same in the form of videos/ slides/flowcharts/ pseudo-codes.
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.
  • Porting the uart library
and implementing rc_uart_write, rc_uart_read_bytes
  • 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.
  • Demonstrating UART application by serially communicating with an external device (Can be a simple FTDI programmer attached to my PC).
  • Finalizing and documenting everything done till now, submitting first report for evaluation.
July 23 Milestone #5
  • Adding Linux I2C driver support on the Beagle AI
  • Add spi support
  • Testing examples that use above protocols with the Robotics Cape.
  • Writing documentation
July 30 Milestone #6
  • Start assembling the Balancing Robot kit for testing the self balancing codes.
  • Also debug and test the robotics cape on-board sensors, ADCs and motor drivers by running examples like rc_test_mpu,rc_test_adc, rc_check_battery, rc_test_motorsetc.
Aug 06 Milestone #7
  • Get the BBAI+Robotics Cape properly mounted on the chassis of the Balancing Robot Kit, and also try to power the Cape using batteries. (if batteries do not deliver enough current/provide enough voltage, then an external 12V adapter can be used instead).
  • Calibrate the IMU by running and debugging the rc_calibrate_gyro, accel examples.
  • Making Videos and documentation for above implemented examples.
August 10 Milestone #8 (Phase 2 evaluations)
  • Testing and debugging the rc_balance librobotcontrol example on the BBAI+Robo Cape on Balancing Robot Kit to prove implementation done so far.
  • 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

  1. 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.
  2. I have an aptitude for writing good reports and blogs, and have written a small blog on how to use a debugger.
  3. 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 worked on developing hardware and making documentation for a 3 DOF arm based on an ESP32 custom board.
  4. As a part of my college Robotics' Club (SRA VJTI)Contributed to a Self Balancing and Line following Robot Workshop in 2020 where I have taught juniors the C implementation of Self Balancing and Line following algorithm using PID control. This experience will greatly benefit me in this project, since a major part of testing my work involves making/hacking a self balancing robot using the BBAI+RC and a non-custom chassis.
  5. 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.
  6. I actively contribute to open source (most recently, I contributed to the ADS1115 library for ESP32 on the unclerus repo and can be seen here).
  7. Currently I am working on designing a Development board for the Raspberry Pico (RP2040) using KiCAD.
  8. I also 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. Some of those information portals are listed below.

  1. Derek Molly's beagle bone guide provides all the information needed for getting up and running with my beagle.
  2. Content on e-ALE.org is very useful for information that ranges from tutorials and walkthroughs to the level of very advanced stuff.
  3. BeagleBone cookbook from Mark A. Yoder & Jason Kridner is the best source for test projects during the prototyping period.
  4. The technical reference manuals provided by TI on am3358 and am5729 are the best source for getting the insights on the SoC used in Black and Ai. (above sourced are referred from here )
  5. Beaglebone: Introduction to GPIOs - Using Device Tree Overlays
  6. example of using capemgr and devicetree overlays to configure a pinmux on the BeagleBone

Benefit

The most advanced robots are those controlled by AI that can learn from their environment and experience and then build on their capabilities based on that knowledge. The BBAI enables the AI aspect of such applications as other competing boards don't have as powerful cores. The Robotics Cape on top of it, gives scope to seamless motor control and sensor integration, thus enabling the hardware and electronics part of the Robot. Thus to encourage more developers and students to take advantage of this, comes the need of the librobotcontrol that allows developers to focus more on their robotics applications in a higher level language like C with very intuitively named and well documented functions.

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