This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wired2coffee's profile picture

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

Started by Wired2coffee, 25 January 2013 - 01:08 PM
Wired2coffee #1
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?
Cranium #2
Posted 25 January 2013 - 05:02 PM
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.
dissy #3
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.
Wired2coffee #4
Posted 25 January 2013 - 05:39 PM
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.
dissy #5
Posted 25 January 2013 - 05:58 PM
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 ;}
Orwell #6
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.
NeverCast #7
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
Orwell #8
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/>
dissy #9
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/>
dissy #10
Posted 25 January 2013 - 06:25 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

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.
Orwell #11
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/>
Orwell #12
Posted 25 January 2013 - 06:28 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

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 .
Cranium #13
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.
Orwell #14
Posted 25 January 2013 - 06:31 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.
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/>
dissy #15
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 >:}
Orwell #16
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…
dissy #17
Posted 25 January 2013 - 06:54 PM
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 :{
Orwell #18
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/read_post/185-Installing-OpenCV-on-the-Raspberry-Pi
http://www.fanjita.org/serendipity/archives/57-Capturing-webcam-video-with-OpenCV-on-Raspberry-Pi-Arch-Linux.html
Alekso56 #19
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….
Orwell #20
Posted 26 January 2013 - 01:03 AM
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/>
ETHANATOR360 #21
Posted 27 January 2013 - 11:39 AM
I was actually thinking about doing this before you posted it :)/>
MudkipTheEpic #22
Posted 27 January 2013 - 01:35 PM
*turtle interface*
turtle.up()
*real life living room*
DADDY DADDY THE ROBOT IS FLYYYIIIINNNGGGG!!!!!!

XP: Turtle Reality.
Dlcruz129 #23
Posted 27 January 2013 - 02:34 PM
*turtle interface*
turtle.up()
*real life living room*
DADDY DADDY THE ROBOT IS FLYYYIIIINNNGGGG!!!!!!

XP: Turtle Reality.

Yeah, that probably wouldn't happen. Unless…rocket-thruster real-life turtles? >:D/>
Wired2coffee #24
Posted 27 January 2013 - 06:43 PM
*turtle interface*
turtle.up()
*real life living room*
DADDY DADDY THE ROBOT IS FLYYYIIIINNNGGGG!!!!!!

XP: Turtle Reality.

Actually, it might be possible. If I actually decide to do it, I would make sure to make a quadrocopter-style kind of thing at the bottom (where those four squares are) as well as some kind of gyro of course. But if I were to do that, the battery prices would go through the roof because you'd need the battery to be super-lightweight and long lasting.
Dlcruz129 #25
Posted 27 January 2013 - 07:17 PM
*turtle interface*
turtle.up()
*real life living room*
DADDY DADDY THE ROBOT IS FLYYYIIIINNNGGGG!!!!!!

XP: Turtle Reality.

Actually, it might be possible. If I actually decide to do it, I would make sure to make a quadrocopter-style kind of thing at the bottom (where those four squares are) as well as some kind of gyro of course. But if I were to do that, the battery prices would go through the roof because you'd need the battery to be super-lightweight and long lasting.

Lol good luck with that.
Mads #26
Posted 01 February 2013 - 03:02 AM
Don't do it with Java. Use C++ and the Lua libraries, and use OpenGL ES for the graphics… PROFIT?
Orwell #27
Posted 01 February 2013 - 05:08 AM
I would probably just use the lua binary as is (cross-compiled of course) and write the libraries for it in C/C++/(Java is you can't handle C :P/>). By far the easiest solution IMO. I wouldn't have a clue yet on how to handle input through the GUI like this though (I'm not familiar with the Lua API). The latter would probably be easier using Mad's method. But all other libraries would require significantly less work I think.
Mads #28
Posted 01 February 2013 - 08:22 AM
The Lua API is actually really easy to use, once you learn how to use the stack. You don't deal with variable names, you deal with the stack only, except for lua_getglobal and luaL_register etc.
Orwell #29
Posted 01 February 2013 - 08:28 AM
The Lua API is actually really easy to use, once you learn how to use the stack. You don't deal with variable names, you deal with the stack only, except for lua_getglobal and luaL_register etc.
Yeah, I read about it before. And I know how the Lua stack works. :P/> I'm just not familiar with what possibilities you have to create a proper GUI that can interpret Lua. My guess it would work just fine. I just didn't want to make false statements without knowing.

Edit: I just actually googled on it, should be quite easy to achieve actually. Minimum effort IMO.
nutcase84 #30
Posted 01 February 2013 - 12:45 PM
I had this idea… hope you get it working. I was wondering… can you use the arduino to control the motors?
Orwell #31
Posted 01 February 2013 - 02:18 PM
I had this idea… hope you get it working. I was wondering… can you use the arduino to control the motors?
You could easily. But it's possible to let a Raspberry Pi control the motors in exactly the same way as the arduino does (by using it GPIO pins and an appropiate H-bridge in the case of DC-motors). Thus circumventing the use of arduino. And as the Raspberry Pi has many more computational capabilities (it's a computer you know…) and has about the same price as an arduino + motor shield, I wouldn't bother using an arduino solely for the purpose of controlling the motors. The only reason I could think of to use an arduino for the motors is to take of some processing load from the Raspberry Pi by taking over the navigation part. But then again, as the Raspberry Pi is equally cheap, you could have 2 Raspberry Pi at the same price and have a much higher total of processing power.

Well, that's my opinion at least. :P/>
Zee #32
Posted 03 February 2013 - 07:04 AM
This has some potential, dammit! I would pay money for a real "real turtle" that actually moves. It would be epic if it climbed up trees and then cut them down. Well, I'm fantasizing, but still. This is in my thread follow list. Now I'm stealing the idea. Remember the Numb3rs episode with the train wreck and what's-his-name's robots? I want to build those.
Edited on 03 February 2013 - 05:01 PM
FuuuAInfiniteLoop(F.A.I.L) #33
Posted 06 February 2013 - 06:08 AM
The turtle api can be inplemented realy and with a couple of sensors and whells it can move really, that would be cool
dissy #34
Posted 06 February 2013 - 01:09 PM
So far, I've created a little "plug" that fits the bottom of the 3d printed turtles. The plug has a rare earth magnet in it.

I had an old magnetic chess board laying around that uses motors and pulleys to move a magnet around under the board, as well as a simple "up/down" movement to grab onto a piece and move it elsewhere as well as to let go and move under a different piece.
I'm just using it for prototyping, but plan on printing out some minecraft grass blocks to put down over the top and let it move the turtles around over.

Of course this only addresses 2d movement, no climbing of trees ;} But still, it basically works, and is controllable from my raspberry pi.

I figure some papercraft minecraft blocks with tiny weights inside (or even magnets?) would give the turtles something to play with.
Sadly I appear to be out of heavy paper stock at the moment, but just recently bought a new color printer which will work great for this.

The only bit left is to program the API to let it be controlled from a web page.
And the web cam of course, but at least that part will be pretty easy and straight forward.

I was even thinking about making a turtle chess set, but figure it will be around $600 in pieces to do properly. Not sure how badly I want that yet ;}
Mads #35
Posted 10 February 2013 - 09:33 AM
I am going to try and make CraftOS with C++.