in reply to Hardware Programming and Perl

Check out Inline::C. You can use it to write a Perl module that wraps the C API for your robot. As long as you can get Perl and Perl modules installed on the machine your program will execute on, you should be golden. My former roomate took a similar class while we were in University and all the processing was done offboard on a laptop. They were doing a lot of vision work, which, for some reason, is really easy to do in Matlab. They had no problem using Matlab's C interface to control the robot.

As to your question about resources: Perl typically uses more memory and runs slower than an equivalent C program, but this only typically matters if you are doing a lot of iteration or dealing with a massive amount of data. I've done a fair amount of AI-related development in Perl and have found the reduced development time was more than a fair trade-off for the slight speed deficit. That said, I'd be careful doing hard-core search in Perl. I ran into a lot of trouble doing heurisitic search in a program that played stratego. To milk any sort of performance in these problems you'll need to know a lot about subroutine calls, recursion, and parameter passing in Perl. I ended up forking off a C process to do the search, but I would have wrapped the code using Inline::C if I'd known how to do so at the time.

Check out XS Info for more information about calling C from Perl. The original question referenced XS, but there is a good deal of Inline::C info in the node as well.

Replies are listed 'Best First'.
Re: Re: Hardware Programming and Perl
by Willman023 (Scribe) on Oct 28, 2002 at 20:49 UTC
    Your probably right about the lego sensors and all, I don't think they use mindstorms. But alot of good suggestions, Inline::C is probably the way to go if I really want to develop in perl. If all the processing is done off board that really answers the gist of my question. I think when I take this class I'm gonna first do it in C, and then in perl to compare the speed difference. It should be interesting to program hardware in perl!
    Thanks dbp for all of your input!

    Where there's a Willman, there's a way!

      I'd be interested in the comparison, as I bet many fellow monks might. Also, if you get a working module put together, it might be a nice addition to CPAN, especially if the robotics kit your school uses is a common one.