[Python] coding a specific pattern in python [closed]

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am just trying to build a logical prototype to represent tractor implement automation for headland turning. In this effort I have connected a rotary encoder with ESP32 which connects to Raspberry Pi via WiFi with MQTT protocol (would change this in future but for now, it works). The raspberry pi then connects to a stepper motor via driver. Chose Raspberry Pi because it is easier to code the logic in python.

    Now the way this works is that the rotary encoder continues to measure the angle of rotation. When it breaches a threshold angle the Raspberry Pi directs the stepper motor to rotate a certain steps in a certain direction.

    For different pattern this works differently. For "casting pattern" with which I am struggling, The tractor is supposed to start from the side of the field and continues towards the centre via headland turning. Usually it follows the "continuous pattern" where the tractor basically follows a rectangular pattern (with two of the horizontal sides being the path tractor traverses on headland with its implement lifted up throughout before lowering them to plough the field in straight lines) except the last turn where it follows "quick-turn-method" I am theorising that for two different pattern, "continuous pattern" and "quick-turn-method" (aka side-by-side) the pattern of angle change is different (for the latter it is steeper) and based on that I have written the python code. It seems the patterns isn't working correctly. Especially the last pattern "casting". You can see the code from here It is quite lengthy but you need to read from about 399 to 512 line number, where, under "headland management" the main logic is given.

    Give me some suggestion on how to improve it.

    It seems the patterns isn't working correctly.

    Continue reading...

Compartilhe esta Página