Wolfram Mathematica

the new Raspberry Pi’s come with Wolfram Mathematica loaded. (I got a B+ with my GoPiGo). Is there a convenient way to access the GoPiGo from the Wolfram language? wolfram can access the pins on the Raspeberry. I suppose I could read the Dexter python and reproduce that code in Wolfram. Is ther an easier way?

Thanks

Hey Beingkailo,

We haven’t worked iwth Wolfram Mathematica yet with the GoPiGo. Really interesting idea though!

One way to get started would be to port the python library. You could also use our socket-client code here: https://github.com/DexterInd/GoPiGo/tree/master/Software/Client_Server

We haven’t heard of anyone using Wolfram with this project before, so please let us know how it goes! We would love to share it with everyone!

Came across this thread when trying to do the same thing as op. Turns out it is not too tricky. I’ve included an example to control the GoPiGo with some basic buttons for anyone else who happens to find their way here.

If you are running Raspbian for Robots and don’t have Mathematica or the Wolfram Language on your GoPiGo you can get it using

sudo apt-get install wolfram-engine

After connecting to your GoPiGo via VNC (wolfram can be run via command line too, just doesn’t have nice graphical interface for buttons etc), open a new Mathematica notebook and paste the following:

Run["!command", 
  "python /home/pi/Desktop/GoPiGo/Software/Client_Server/serv.py"];
goPiGoSocket = SocketConnect[{"127.0.0.1", 5005}];

Grid[{
  {"", Button["fwd", WriteString[goPiGoSocket, "f"]], ""},
  {Button["left", WriteString[goPiGoSocket, "l"]], 
   Button["bwd", WriteString[goPiGoSocket, "b"]], 
   Button["right", WriteString[goPiGoSocket, "r"]]}, {
   Button["stop", WriteString[goPiGoSocket, "s"]], SpanFromLeft}}]

Evaluate the cells and control the GoPiGo with some basic buttons. In its simplest form all you need to do is use SocketConnect and WriteString. I presume more functionality can be added by modifying the serv.py file using Python.

Hey Hans_S,
That’s actually a pretty clever use of the socket examples. Do let us know if you have documented this on a blog or have a video for this. It would be great if we could add this as a tutorial so that others can try this too.

-Karan

No video or blog yet, maybe as the project progresses I’ll put something together. By editing the serv.py file I’ve got more functionality too, motor speed change, LED flash etc.

I have noticed that occasionally the Run command…

Run["!command",“python /home/pi/Desktop/GoPiGo/Software/Client_Server/serv.py”];

… doesn’t run as it should and I have had to run the “python /home/pi/Desktop/GoPiGo/Software/Client_Server/serv.py” command in a terminal window directly before evaluating the SocketConnect command in Mathematica.