Roomba Progress, 3/30/09

This week I did some work behind the scenes, but there’s nothing I can show off in terms of video or pictures.  I have essentially wrapped up my C++ class with some glue code to make it useable from within CMUCL.  The Roomba class itself is useful for controlling the Roomba in a C++ program (as demonstrated by my wiimote example), but it also conveniently organizes the Roomba functionality for Lisp programs.  The C++ class declaration is as summarized below:

class Roomba
{
private:
    ...
public:
    int connect(char *serialDevice);
    int disconnect();
    int launchThread();    // Thread for microcontroller comms
    int killThread();
    
    // Movement style 1 (Direct movement)
    int turnAndForward(float angle, float dist);
    // Movement style 2 (Car)
    int setVelocity(float vel);
    int setSteeringAngle(float angle);
    // Movement style 3 (Independent wheels, velocity-based)
    int setMotorVelocities(float velLeft, float velRight);
    // Movement style 4 (Independent wheels, distance-based)
    int moveMotors(float distLeft, float distRight);
    
    void getStatus(RoombaStatus *rs);
    float getApproxX();
    float getApproxY();
    float getApproxHeading();
};

I’ve used CMUCL’s Alien interface to enable foreign function calls to the C++ code.  C++ name mangling is a nuissance that prevents clean interfacing with Alien, so I elected to write a C++ wrapper that defines un-mangled functions (extern “C”)  that act on a single static Roomba object.  This wrapper compiles into a shared object (a.k.a. dynamic-link library or DLL) that can be manipulated in CMUCL.  Roomba object functions can be called from Lisp like this:

(turnAndForward 9.0 2.5) ;; Rotate 9 units, forward 2.5
(setf vL -1.0)
(setf vR 1.0)
(setMotorVelocities vL vR) ;; Rotate left, full speed

Unfortunately, I have nothing to show in this update because I haven’t written any Lisp programs that to take advantage of the new interface.  In addition to writing this interface, I’ve begun writing a final paper about my work.  My goals for next week are to write some interesting Lisp code based on a competitive Cognitive Robotics scenario I’m writing up in my paper, to try out some SNePS reasoning on top of Lisp, and possibly some additional hardware work (integrating the new battery, adding a webcam, and making a PCB for the microcontroller circuit).

Advertisement
Explore posts in the same categories: Roomba

3 Comments on “Roomba Progress, 3/30/09”

  1. matt Says:

    This blog’s great!! Thanks :) .

  2. Nick Says:

    I wish you every success!
    I watch your progress :-)

  3. sp Says:

    Thanks =]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.