Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compile C into firmware
#1
Ok I am at a point that I must learn how to add C functions into the firmware that can be called from MP.

I am building a robot to solve a 5x5x5 Rubik's Cube (in the past I have made 3x3x3 cube solving robots) see current physical robot that I designed https://youtu.be/cgVBv86AE0I

I have a friend that has been optimizing his algorithms for solving large cubes for a few years and competes in cube solving comps. To use his algorithm I need compile a few C functions into the firmware that his python solver calls. The first 1 that I need to get working is the generic kociemba 3x3x3 solver see https://github.com/dwalton76/kociemba/tr.../ckociemba

I am quite new to programming at 2 yrs now and only been writing in C on STM32 for a few months but have been progressing nicely. I do understand what a compiler and linker does but am not the best at getting them to do what I want.

Can someone help me to please to add the kociemba to the firmware
Reply
#2
It should be easy. I'll try to write a tutorial how to do it (using your example) later today.
Reply
#3
It will be great to still learn how to wrap up C functions inoot the firmware but for the moment we have found a better work around. Instead of running the solving algorithm on the ESP32 we will run it on a PC and send the solution to the ESP32 via WiFi.

We r looking at you hold up the cube in front of the PC camera and rotate it so that PC sees all sides then OpenCV will find the cube and read the faces (I have done this before with a 3x3x3) then once it knows the what coloured tiles r where on the faces it send the solution to the ESP32 cube solving robot and you place the cube into the robot then it solves it Smile
Reply
#4
Here are some examples showing C implementation of MicroPython functions and class methods.  The examples cover most of the variants you will need as a low-level uPy developer.  For example, how do you write C code to make a mandatory positional argument, versus optional? Or, how do you write C to raise a python exception when a wrong object type has been passed to a method?

https://github.com/MikeTeachman/MicroPyt...examples.c

The file can be compiled into a build and run by importing the "argex" module. 
commit:  https://github.com/MikeTeachman/MicroPyt...78d0b2cadf

Each example shows:
  • uPy interface to the function or method, showing all possible variants of positional and keyword arguments
  • C implementation
Reply
#5
Try these videos out.  They helped me!'

Nick's uPython Talk.
https://www.youtube.com/watch?v=-MrqCmq3Z5k&feature=youtu.be

Damien at MicroPython Meetup:
https://www.youtube.com/watch?v=tqvn_JFdLDY
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)