loading...
Cover image for I'm programming a sumobot with the world's safest programming language

I'm programming a sumobot with the world's safest programming language

bosepchuk profile image Blaine Osepchuk Originally published at smallbusinessprogramming.com ・3 min read

The Make with Ada contest is offering $8,000+ in prizes for "cool embedded applications programmed in the Ada and SPARK programming languages."

I've always wanted to build a robot and I've been looking for excuses to play around with Ada so I thought this would be a great time to kill two birds with one stone.

Project overview

I'm building a robot that can compete in the mini-sumo class. I bought a Zumo 32U4 robot online because it's packed with sensors, has a great software library, and I didn't want to build a robot from scratch. It's meant to be programmed entirely as an arduino microcontroller but I'm going a different route.

I'm collecting all the sensor data from the zumo and sending it to my microbit microcontroller over I2C. I'm using the Ada drivers library to program the microbit in Ada (and I'll add some SPARK too if I have time). The microbit will receive the I2C sensor data, decide what to do, and directly command the robot motors from the GPIO lines on the microbit. All of the critical code will be written in Ada/SPARK on the microbit, which I hope will impress the judges.

My robot should be quite a capable sumobot when I'm done.

Current status

I have a working proof of concept. I'm collecting sensor data from the front proximity sensors, transferring it to the microbit over I2C, validating and processing it, and commanding the motors to turn the robot towards the detected object. My next task is to get all the electronics securely mounted on the zumo. Then I'll continue adding capabilities to my sumobot.

Any ideas for features with "buzz effect" I should add to the project?

One of the judging criteria is buzz effect:

one of the main goals of the Competition is to give more exposure to Ada, SPARK and related technologies. Projects will be judged in part with regards to how we think the project can have an impact in that regard: Will the project give more exposure to Ada? Does it have a “wow effect” that will appeal to the technology community in general? Will it show the benefits of Ada and related technologies?

I imagine a sumobot like mine would have more "buzz effect" than a lithium ion battery charger written in Ada. But, beyond that, I'm not entirely sure what they are looking for. I'd welcome any suggestions for improving my project's "buzz effect."

More about the make with Ada contest

If you have any interest in embedded software development or Ada you should definitely consider entering the make with Ada contest. The number of serious entries in previous years has been quite low. So you have a good chance of winning one of the top ten finalist prizes of $600, if not the 1st place prize of $2000 if you put a decent amount of effort into your entry.

The final day of the contest is January 31, 2020. So you have lots of time.

Wrapping up

I welcome any feedback on my project. If you have a way to make it better I'd love to hear from you. And I hope I can inspire at least one other person to join the contest. So let me know if you plan to enter the contest in the comments.

Discussion

pic
Editor guide
Collapse
nilutpolkashyap profile image
Nilutpol Kashyap

hello,
I am facing some issues in programming my microbit using the GNAT programming studio. I am using a Windows 10 machine.
I have installed the below two packages in my windows 10. But i am still not able to get it working.

1) GNAT native --- gnat-community-2019-20190517-x86_64-windows-bin.exe which is of 380 mb

2) GNAT arm-elf --- gnat-community-2019-20190517-arm-elf-windows64-bin.exe which is of 142 mb

Are these the correct packages?
Once i connect the microbit and go for Build->Bareboard->pyocd gdbserver, the leds in the microbit stop flashing and the yellow led continuously starts blinking. I get the ouotput as

INFO:root:[0]
INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471
INFO:root:[0]
INFO:root:[1]
INFO:root:[2]
INFO:root:[1]
INFO:root:CPU core is Cortex-M0
INFO:root:4 hardware breakpoints, 0 literal comparators
INFO:root:2 hardware watchpoints
INFO:root:Telnet: server started on port 4444
INFO:root:GDB server started at port:1234

After that when i go for Flash to board option for the main.adb file I get an error.

gprbuild --target=arm-eabi -d -PD:\GNAT\2019\bin\microbit_example.gpr D:\GNAT\2019\bin\src\main.adb -largs -Wl,-Map=map.txt
gprbuild: "main" up to date
[2019-12-31 14:19:47] process terminated successfully, elapsed time: 00.39s
Retrieving the load address.
arm-eabi-objdump D:\GNAT\2019\bin\obj\main -h
Load address is: 0x00000000
Creating the binary (flashable) image.
arm-eabi-objcopy -O binary D:\GNAT\2019\bin\obj\main D:\GNAT\2019\bin\obj\main.bin
Flashing image to board...
pyocd-flashtool -a 0x00000000 D:\GNAT\2019\bin\obj\main.bin
No connected boards
Error: There is no board connected.
Could not flash the executable.
[workflow stopped]

Please help me out.
Thank You

Collapse
bosepchuk profile image
Blaine Osepchuk Author

I had one more idea about your problem.

I had a similar issue connecting to the microbit and it turned out the USB cable I was using was designed for charging one of those portable lithium ion battery packs and it didn't have the signal wires connected.

Could you have a defective cable?

Collapse
bosepchuk profile image
Blaine Osepchuk Author

Those are the correct packages. I'm on windows 10 too. I installed them in the opposite order though. I don't know if it matters but you might want to uninstall and reinstall if nothing else works. I followed the directions here: blog.adacore.com/ada-on-the-microbit.

I use the 'build all' button in the GUI to build and the 'flash to board' button to flash the microbit. The commands looks similar to what you did but you might want to try that if my next suggestion doesn't work.

You need to manually edit a file to make flashing work. The directions are here. The error isn't the same as I got but it might be the same cause.

Finally, make sure you allow all drivers to install when you install the AdaCore software and plug in the microbit to your usb system. It's possible that your antivirus or something similar blocked them from showing up.

That's all the suggestions I have. Good luck!

Collapse
opensussex profile image
gholden

wow, some Ada love!

Collapse
awwsmm profile image
Andrew (he/him)

This sounds really cool, Blaine. I've read about SPARK in Ada, but I've never worked with it. Is there a verifying compiler for SPARK?

Collapse
bosepchuk profile image
Blaine Osepchuk Author

Thanks. The community version of spark had 3 levels of analysis beyond the already insanely capable Ada compiler:

  1. Confirm the code is valid spark (the safe subset of Ada)
  2. Data and flow dependencies (all variables are used, all calculations are effective, etc.)
  3. Provers that demonstrate the spark code will never throw a runtime exception or overflow for any inputs (this is what people usually call "formal verification") -- very cool stuff!

More information here: learn.adacore.com/courses/intro-to...

Collapse
awwsmm profile image
Andrew (he/him)

Yeah formal verification is really neat. Like type-checking on steroids.

Thread Thread
bosepchuk profile image
Blaine Osepchuk Author

At the risk of being argumentative, it's that and so much more.