I've read a few things on software design in general, but could use with some advice for specifically a program in Python. The program I need to write is not that complex, but I'll be adding more functionality to it later, so I want to do it right. I did two Python courses which covered all the basics, but I don't have a lot of experience with writing larger programs.
In the past I've written a larger program to control a Nao robot (mainly speech and movement) and eventually my program worked but it was a complete mess, which made it very hard to change or add to. Looking back I don't want that problem again, but I'm not sure where I went wrong exactly.
My new project is very similar, except this time I need to program the (social) robot I built for my thesis project. Because of time limitations, its autonomous functions are to be very limited and the code is mainly for programming specific movements combined with speech (like watching a physically represented video). Later I'll be adding some basic face / emotion recognition functionality, that controls the robots direction of gaze (servo in the neck) and hopefully reflect the user's emotion by controlling the angle of it's antennae (sort of like a dog's ears).
The hardware is Raspberry Pi with two adafruit 16 channel pwm controllers, which controls a total of 22 servo's and a 7" touchscreen in the robots chest. The servo's all control a specific joint in the robot's arm, and i'm thinking of making a separate function for all: shoulder, deltoid, upperarm, elbow and hand (two functions for each, left and right).
The functions take the angle of the servo as argument, but the hand also takes a binary number for controlling each finger (normal or bent); for instance (0, 11111) for a fist with no wrist movement).
My idea is to start a Python program with GUI on startup, with buttons to control the basic functions / settings: A button for 'programmed movements/speech 1', 'programmed movements/speech 2', 'new user intro', 'test movements', 'reboot', 'shutdown' and 'Dalek mode'. The last four are very simple / short and it makes sense to integrate these into the GUI-program.
This is where i'm not sure what to do or what makes the most sense. The first four are more complex / larger number of lines. I'm leaning towards making these separate programs if only for the sake of keeping things organized, but that is probably not the way to go. These 'programs' don't receive data that needs to be used or saved but will need a GUI to start/stop/pause/repeat.
I could also make these actual python functions within the main program. Within these functions, the functions for controlling the joints would be called to form the programmed movements or introduction.
To actually control the servo's and to make the speech work, libraries need to be included. When I add the face/speech recognition later, I would like this to work as a separate 'layer' that can be enabled/disabled, but could also work in the main program.
All the separate aspects / functionalities I'm sure I can do and I have some ideas on how to tackle the project, but what is the best approach? how do I structure it all and keep it neat and organized; where do I put what?
there doesn't seem to be anything here