Jump to content




So these "real turtles" got me thinking....

computer lua utility

  • You cannot reply to this topic
34 replies to this topic

#1 Wired2coffee

  • Members
  • 46 posts
  • LocationThe Coffee Maker

Posted 25 January 2013 - 02:08 PM

I'm thinking it would it be possible to turn a Raspberry Pi (with some kind of screen, of course) into a real-life advanced computer. Raspberry Pi has a port for pretty much everything that CC does in-game. Ethernet port for HTTP API and all that. Some kind of bluetooth dongle could be used as wireless rednet module to other nearby computers. Also, it would be relatively cheap to do, considering R-PIs aren't that expensive, but I don't have a particular HDMI screen in mind if I do choose to go a long with it as a project. What are your thoughts?

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 25 January 2013 - 05:02 PM

View PostWired2coffee, on 25 January 2013 - 02:08 PM, said:

I'm thinking it would it be possible to turn a Raspberry Pi arduino (with some kind of screen, of course) into a real-life advanced computer. Raspberry Pi has a port for pretty much everything that CC does in-game. Ethernet port for HTTP API and all that. Some kind of bluetooth dongle could be used as wireless rednet module to other nearby computers. Also, it would be relatively cheap to do, considering R-PIs aren't that expensive, but I don't have a particular HDMI screen in mind if I do choose to go a long with it as a project. What are your thoughts?
Do it. 100% support for real life turtles.

#3 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 05:04 PM

I've already spent a few days trying a month or so ago.
The best you can get at the moment is just the Lua interpreter.

There is no Sun/Oracle Java for armfh yet, and neither minecraft nor most of the java programs that go with it will run under openjdk or java se.
Not even the computercraft emulator.

I have manged to get one dependency library to compile under openjdk, namely LWJGL, but it took literally four hours mucking with compiler flags and chasing down compile errors.

You can read my research results in this thread.

#4 Wired2coffee

  • Members
  • 46 posts
  • LocationThe Coffee Maker

Posted 25 January 2013 - 05:39 PM

View Postdissy, on 25 January 2013 - 05:04 PM, said:

You can read my research results in this thread.
Wow, I'm surprised I didn't see that thread. I wonder if it would be possible to make a completely new program in PYTHON to act like what you would see in advanced computers.

#5 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 05:58 PM

View PostWired2coffee, on 25 January 2013 - 05:39 PM, said:

Wow, I'm surprised I didn't see that thread. I wonder if it would be possible to make a completely new program in PYTHON to act like what you would see in advanced computers.

Yes that is very possible.

Lua is designed as an embeddable language. The Lua site itself talks about how to do this with C/C++ mainly, however there is a Python package called Lupa that lets you include a Lua interpreter into Python. Another is Lunatic Python.

The idea is that in Python, you declare Lua functions, and Python can read and control the Lua variables.
Basically you would implement all the CC specific commands in Python.

So for one example, you would create a python function and bind it to the Lua command "turtle.forward"
In this case it's easy, just have the python function return success. Now when the Lua program says "turtle.forward()", instead of an error that the command doesn't exist, the program will get "true" back and think the turtle moved.
Ideally the python program will have some x/y/z variables and actually track where it thinks the turtle is. So in the python call, have it increment that X var.
Later you can bind a python function to the "gps.getCords" and have it return where it thinks it is.

It would be a lot of work to implement all the functions needed to keep a Lua program happy, but it's more just tedious than hard to do.

I've done similar things using TCL and C before. Not only do you get a config file format that calls commands to set things up and has access to data in variables, but all the scripting abilities of TCL right in your config file! In that sense, TCL and Lua are very similar.

As a bonus, you'll get to add "Developed software language emulator" to your resume ;}

#6 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:01 PM

Wouldn't it be easier to simply use the standard C version of Lua and write some cc apis in C and pure Lua? That would be my first angle of going at it. You would have some differences of course, but I'm sure it's not hard to make it compatible with CC Lua.

Edit: wow, this post was in a reply to Wired2Coffee's one. I'm going to read dissy's huge wall of text now.

#7 NeverCast

  • Members
  • 400 posts
  • LocationChristchurch, New Zealand

Posted 25 January 2013 - 06:09 PM

LuaJ is Big Endian byte order, could run in to issues.. not sure of the endian on Raspberry Pi.
Other than that, shouldn't be a problem

#8 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:13 PM

Oh dissy :( I would at least make the turtle move! :P The Raspberry Pi has GPIO pins for something :P

#9 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 06:20 PM

I was just reading over this webpage at lua-users
It's all about embedding Lua in other languages.

The top is mainly about C, but if you scroll down to "Other Languages", there are plenty to choose from. All I can suggest is use what ever host language you are most comfortable in and familiar with.

Orwell: What's funny/sad is, I was thinking the exact same thing.
Ever see those boards with roads/tracks drawn on the top, and magnets on motor controlled pulleys underneath, where you place a little car with a magnet in it on the board and it gets moved about?

I have 2 spare RaspPi's, a couple IO expanders, and some dead flat bed scanners for parts I was seriously considering wiring together ;}

Then all that's left is giving it a web interface for control, pointing a webcam at it, and put it all up on the Internet for heavy abuse :D

#10 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 06:25 PM

View PostNeverCast, on 25 January 2013 - 06:09 PM, said:

LuaJ is Big Endian byte order, could run in to issues.. not sure of the endian on Raspberry Pi.
Other than that, shouldn't be a problem

The ARM 1176jzfs chip in the Pi is actually bi-endian. It supports both big and little endian modes internally.
The ARMs CPU instructions are fixed as little-endian, but as for data it's just a matter of either declaring a block of memory to be big endian, or just setting a flag before doing the copy and it will auto convert.

This is the specific low level ARM docs that go over the details.

#11 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:27 PM

Dissy: I haven't seen those board yet but it sounds like a terrible solution. :D I would love to see that. :P Letting random people control a robot in your house sounds like a terrible idea as well. :P

I happen to have spend some time the last 2 days on researching the use of the Raspberry Pi in robotics. I plan on experimenting with stereo catadioptrics to navigate a robot. I'm also planning on requesting it as the subject for my bachelor thesis because it would demand a terrible amount of time. :P I had my eyes set on this thing as a mobile platform. It's quite expensive but almost immediately usable with the Raspberry Pi (I found a H-bridge that's compatible with both). I do hope to find a cheaper alternative though. :P

#12 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:28 PM

View Postdissy, on 25 January 2013 - 06:25 PM, said:

View PostNeverCast, on 25 January 2013 - 06:09 PM, said:

LuaJ is Big Endian byte order, could run in to issues.. not sure of the endian on Raspberry Pi.
Other than that, shouldn't be a problem

The ARM 1176jzfs chip in the Pi is actually bi-endian. It supports both big and little endian modes internally.
The ARMs CPU instructions are fixed as little-endian, but as for data it's just a matter of either declaring a block of memory to be big endian, or just setting a flag before doing the copy and it will auto convert.

This is the specific low level ARM docs that go over the details.
It hardly matters when you compiled Lua for it, does it? I can't find a use of endianess within Lua :s .

#13 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 25 January 2013 - 06:29 PM

Regardless the methods, I would pay handsomely for a working remote control turtle. With moving pickaxe and all. Bonus points if you can make the slot in front into a cd drive.

#14 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:31 PM

View PostCranium, on 25 January 2013 - 06:29 PM, said:

Regardless the methods, I would pay handsomely for a working remote control turtle. With moving pickaxe and all. Bonus points if you can make the slot in front into a cd drive.
You've got a lot of fantasy. :P That would definitely be crazy. My biggest concern is how to actually make it look like a turtle. :P

#15 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 06:36 PM

Nice little robotics platform! Actually the price is pretty good too for what it's capable of interfacing with.

One of my 4 Pi's is ear-tagged for a robotics platform of my own. I have a mount that was 3d printed to afix it to my AR drone. Using a wifi dongle it can join the drones wifi network and send it navigational commands. I've also got a usb gps working in debian to plot courses along way-points I can drop on a map and upload to it.

With the Open Computer Vision library, I'm hoping I can get it to parse the two cameras on the drone, and be able to recognize faces and movement, and then react navigationally on it.

Ever since I was a small child I've wanted a robot I could tell "get the kittie!" and it would obey >:}

#16 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:42 PM

Interesting, that's close to what I want to do. Except it would be omnivision. :P At the moment I got my goal set at the set up in figure 6 from this article . I already wrote a simulation for it in POV-RAY and the basis for a C++ program using OpenCV to project it to cartesian coordinates. :)

Edit: You were talking about depth calculation using the two camera's right?
Edit2: I've also given up on believing that the Raspberry Pi could do the image processing itself. I read people getting a 1.5 framerate using a resolution of 320x200 doing simple candy edge detection...

#17 dissy

  • Members
  • 181 posts

Posted 25 January 2013 - 06:54 PM

View PostOrwell, on 25 January 2013 - 06:42 PM, said:

Edit2: I've also given up on believing that the Raspberry Pi could do the image processing itself. I read people getting a 1.5 framerate using a resolution of 320x200 doing simple candy edge detection...

I haven't actually attempted it yet myself. But I know a lot of people use USB cameras when they should know the Pi's USB bus is very underpowered.
There is an SPI connector on the Pi that interfaces directly into the ARM cpu, and Broadcom claims they can do HD video at 28fps or 320x280 at almost 60.
Of course they make the thing, so possibly would say that either way. But yes over USB you won't get much bandwidth, especially shared with the network (The ethernet is on the USB bus internally, as would be any wifi dongle)

It took me almost 5 hours to compile OpenCV from source on the Pi thou. That was back before I had my cross compiler setup on my i7, I should try it again using distcc just to compare compile times heh

Unfortunately the AR drone's ARM is too busy running real time processes for flight stabilization, on top of streaming the video signals and relaying commands. If I can't offload it, it won't get done :{

#18 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 25 January 2013 - 06:57 PM

You can simple 'pacman' OpenCV on archlinux now ;) Interesting stuff you said there, I'm gonna look further into it. If you come to trying it out yourself, please share your results. :) I'd love to have everything in a small autonomous box. :P

Edit: My bookmarks on this:
http://eduardofv.com...he-Raspberry-Pi
http://www.fanjita.o...Arch-Linux.html

#19 Alekso56

  • Members
  • 62 posts

Posted 25 January 2013 - 11:24 PM

i would never program a PI with java, id use a transelator on the pc. (hook it up to ccemu?) then send raw programcode to a wifimodule or via cable to the PI but this can be done by a cheaper chip....

#20 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 26 January 2013 - 01:03 AM

View PostAlekso56, on 25 January 2013 - 11:24 PM, said:

i would never program a PI with java, id use a transelator on the pc. (hook it up to ccemu?) then send raw programcode to a wifimodule or via cable to the PI but this can be done by a cheaper chip....
Why using a remote connection if you can make it work standalone by using like any programming language as dissy mentioned? (I would definitely use C++). And how are you going to establish a connection between cc-emu and the Pi over http without a massive use of resources? Without custom programming that is, otherwise you could just do the custom programming on the Pi. :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users