[Tutor] Creating a Python module to drive a robot
kent37 at tds.net
Sat Mar 8 21:53:30 CET 2008
Shrutarshi Basu wrote:
> Hi all,
> I'd like to create a library of functions that would allow writing
> Python scripts that would control a Hemisson robots via a serial
Do you know about Pyro? It supports Hemisson robots:
I'll be using the pyserial module heavily, but I'm
> wondering what would be the best way to approach this . Should I
> create a "Robot" class and define everything as functions of the
> class, such as a function for setting wheel speed, turning, reading
> from sensors etc. Or is there some other way that would be easier for
> a user? The project is meant for students who would be using
> programming the robot as an Intro to programming, so it would be best
> if users don't need to understand the details of OOP (or similar
> concepts) to use the code quickly and reliably.
The simplest way to control a single robot is probably to use
module-level functions to control the robot.
You can still have a robot class; the module functions can delegate to a
single instance of Robot. The turtle module does this, too; it has a
global instance of Pen which is used by the global functions.
More information about the Tutor