Hexy with onboard Linux

Finally got my Hexy up and running with an onboard stick PC

youtu.be/fehculO_qo4

Here is the bill of materials:
[ul]
Hexy with upgraded Turnigy TGY-50090M hip servos
MK808 Android TV Stick
PoMoCo 2.3.6
Cheap USB hub
Hobbywing 8A UBEC
Turnigy 1500mah LiPo
Custom 3D printed bracket
Logitech F710 wireless controller
Lifecam HD-3000 720p webcam
[/ul]

TV Stick
Running Picuntu Linux with 3.0.8+ kernel (olegk0 kernel) with some additional modules to the standard available package. This configuration allows me to use the internal wifi modules as well as communication with the Servotor board. UVC drivers also work in this kernel so USB webcams supported by UVC should work. I have had some trouble getting my PS3 controller working with this setup Io I gave in and bought an F710 wireless controller.

To-Do
[ul]
DONE Modify PoMoCo 2.1 so it can run on boot of Linux (currently PoMoCo can only be run from the PoMoCo-master folder)
DONE Mount webcam
DONE Develop webcam streaming ability into PoMoCo so I can stream to my phone
Integrate shutdown button so I can power down from the controller
[/ul]

If anyone is interested in attempting to do the same I’d be happy to try and do some kind of write up.

Cheers.

This is the process from start to finish for an Official MK808 TV stick (not MK808B or MK808 clone)
[ul]

  1. Flash a custom ROM like BobFinless ROM. Ensure you follow the instructions carefully so as to not brick your deivce
  2. Download the olegk0 Linux kernel (only for MK808) from http://www.slatedroid.com/topic/55626-my-version-of-the-linux-kernel-for-mk808/page__p__618202__fromsearch__1#entry618202
    2.1 Put the kernel in the FinlessROM folder
    2.2 Uncheck everything but the “recovery” setting, then change the “Path” to reflect the name of the kernel you want to flash, then flash the kernel
  3. At this point you can either choose to download the Picuntu RC3 filesystem from here or download my version of the RC3 (not uploaded yet) which has all the modules and changes made to the filesystem to get it to work properly with minimal fuss
    3.1 Flash the filesystem to an SD card (I recommend 8GB). You can try this website for some help on how to do that. I’ve only ever been able to successfully do this in Linux.
  4. Once flashed insert the microSD card and boot the system
  5. Follow the instructions here and here for how to get the device boot into picuntu (command line)
    5.1 Edit the networking script by typing “sudo nano /etc/network/interfaces” and enter the details of your wireless network into the eth0 network device (this is the internal wifi device, the other device is the USB wifi module if present).
    5.2 Reboot the system and check the network state by typing ifconfig. If everything worked you should have been assigned an IP address
    5.3 Run the picuntu-da-server.sh script and follow the prompts to download a GUI and other bits and pieces. I recommend downloading the XFCE GUI. I haven’t really tried Gnome so I can’t comment on that.
  6. Once booted into Picuntu, follow the instructions at the Hexy getting started page to get your Hexy setup with Linux
    [/ul]

Flashing kernel on an Official MK808 TV Stick

  1. Download the BobFinless ROM and follow all the instructions about installing drivers and checking if your device is set up, and flash the custom ROM.
  2. Download the olegk0 Linux kernel (only for MK808) and put it in the “FinlessROM” folder (http://www.slatedroid.com/topic/55626-my-version-of-the-linux-kernel-for-mk808/page__p__618202__fromsearch__1#entry618202).
  3. If you want to be able to run both Android and Linux you only want to only have the recovery option checked. Otherwise you want the boot and recovery option checked ONLY.
  4. Double click in the Path setting and change the parameter from “FinlessROM\boot720.img” to “FinlessROM\olegk0.kernel.img” or whatever the kernel is called that you put into that folder and want to flash.
  5. Hit the Flash ROM button and watch the status window to make sure your kernel was flashed without any errors.

Creating Picuntu RFS
*Will work on 2GB SD card, but at least 4GB is best

  1. Format the stick as ext4 filesystem and name it "linuxroot"
    Windows: MiniTool Partition Wizard does the trick
    Linux: from the command line type the following commands and note the drive name (eg: /dev/sdb)

sudo fdisk -l sudo mkfs.ext4 /dev/your_drive_name
2. From the command line type the following command to extract the RFS to the SD card

Picuntu First Boot
Username:root
Password:12qwaszx

  1. Change the wireless network settings by typing “nano /etc/network/interfaces” into the command line and change the SSID and Password to match your network
  2. Type the following command to reload the kernel modules
  1. Type “reboot”
  2. Ensure you have a network location by typing the command “ifconfig” into the command line and check for an IP address
  3. Once logged in, navigate to the /usr/local/picuntu/ directory by typing “cd /usr/local/picuntu/”
  4. To configure the system, type “./picuntu-da-server.sh” into the command line.
    This will run the configuration script and guide you through the setup. Some of the packages don’t seem to be available, but I install the following packages: Samba, Xfce4, Flash, Java, GCC, Editors

Picuntu XFCE4 First Boot
The user picuntu has been created, but you can use the root username if you like

  1. Login to the GUI using the picuntu username and password you entered during the setup.
  2. Add the picuntu user to the sudo group by logging in to the GUI as root and entering the following command

Installing OpenCV Python
It is possible to type sudo-apt-get install libopencv-dev python-opencv and you will have OpenCv 2.3.1 installed. However the latest available from the OpenCv website is 2.4.8 so if you want something newer than 2.4.3 you will need to follow these instructions to install it.

It seems some of the packages it says to install in the instructions aren´t completely necessary to compile OpenCv. For example the texlive-latex-extra package wanted to take up approximately 900mb of space so I didn’t install it.

Auto Login to XFCE
Run the following command to auto login the picuntu user:

Running x11 on Startup
Download X11VNC Server from the Ubuntu Software Center or type the follwing into the command line

The following is the command that runs x11vnc from the command line with no password:

In order to run this command each time the device starts we need to add it to the startup script.
Select “Applications Menu” -> “Settings Manager” -> “Session and Startup”, then select the “Application Autostart” tab.
Now click the Add button, fill in the fields and insert the command above to auto start the remote desktop application on boot.

Shutdown Button
I’m making a shutdown button based on the arduino HID library that allows an arduino to act as a keyboard.
We need to assign a key that is not often used to act as the shutdown key, for me this is f4.

Select “Applications Menu” -> “Settings Manager” -> “Keyboard” and switch to the applications shortcut tab.
Create a new keyboard with the following command: “xfce4-session-logout --halt” and then press the f4 button to bind the key to the new shortcut

Running PoMoCo on Startup
Select “Applications Menu” -> “Settings Manager” -> “Session and Startup”, then select the “Application Autostart” tab.
Now click the Add button, fill in the fields and insert the command:

The -j argument puts PoMoCo straight into joystick mode (Kinematic control)

Tweaking CPU Speed
Install cpufrequtils:

Check the available clock speeds:

Check current settings:

Set max cpu speed:

Set min CPU speed

Cloning Your SD Card
Linux:

  1. Check the disk we are about to copy:
  1. Make sure the disk is not mounted before we clone it:
  1. Clone the disk using dd:

Restoring Your SD Card
Restore the clone using dd:

You can find more instructions for installing Picuntu here but I have never had and luck using the pre-picuntu script.

Add one more thing to your list.

Make pomoco boot on start and change to kinematic control so you can move hexy with joystick without needing to pick kinematic control in pomoco gui.

And a few questions:

  1. Are you running the stick and hexy from the same ubec?
  2. How much run time do you get out of that LiPo

Hey klims, nice work on the onboard controller for Hexy!

[quote=“TooManySecrets”]Add one more thing to your list.
Make pomoco boot on start and change to kinematic control so you can move hexy with joystick without needing to pick kinematic control in pomoco gui.
[/quote]
Good call. I’ve been trying to collect my notes on getting Hexy set up for when I inevitably forget how I did it in the next few months. Maybe I will use this thread to collect those notes.

[quote=“TooManySecrets”]
And a few questions:

  1. Are you running the stick and hexy from the same ubec?
  2. How much run time do you get out of that LiPo[/quote]
  3. Yep, both PC and Servos are running off the same UBEC. I haven’t seen any problems with this, but I’m thinking I might want to get a second UBEC so I can run the servos higher than 5v.
  4. I haven’t really ever run it from full to flat, but my guess would be around 10 minutes.

I’ve just posted a link to my version of PoMoCo (2.3.5)

Some of the features:
[ul]
View a webcam in an OpenCV highgui window (also does face detection by default)
View webcam through a web browser (HEXY_IP_ADDRESS:8080/index.html)
Accepts command line arguments
[list]
-j Immediately launch into Kinematic Control mode (enable joystick)
-n Run PoMoCo headless (No GUI)
-f=FPS Specify an FPS for PoMoCo to run at (only works when running PoMoCo headless)
-c Launch the camera viewer on start
-v Launch camera server on start
[/ul]
Can run headless (not fully implemented)

[/list:u]

Notes:

  1. My Logitech F710 Joystick doesn’t have an axis 4, so I had to change the way the original code by Michael worked with the controller. It’s a bad hack but I didn’t see any problems
  2. The camera server poorly written, but it works. I will be looking at a different implementation in future versions

… I forgot to enable the ability to start the webserver from a directory other than the PoMoCo folder…

Here is PoMoCo 2.3.6

Pls make a tutorial of this from start to finnish, this is amazing.
Step by step with linux commands if possible.

edit:
i get this while trying to run your pomoco on windows

Traceback (most recent call last): File "C:\Users\Carlstadt\Desktop\PoMoCo 2.3.6\PoMoCo-master\PoMoCo.py", line 12, in <module> sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/Moves') NameError: name '__file__' is not defined

[quote=“TooManySecrets”]Pls make a tutorial of this from start to finnish, this is amazing.
Step by step with linux commands if possible.
[/quote]
I’ll do my best, but I think a pseudocode style outline would be best as it will probably vary from system to system

[quote=“TooManySecrets”]
edit:
i get this while trying to run your pomoco on windows

Traceback (most recent call last): File "C:\Users\Carlstadt\Desktop\PoMoCo 2.3.6\PoMoCo-master\PoMoCo.py", line 12, in <module> sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/Moves') NameError: name '__file__' is not defined[/quote]

Weird. I do my development on windows 8.1 64 bit with python 32 bit and have never seen this problem. Are you somehow using the interactive interpreter? Or are you executing the module from command line with “python \PoMoCo 2.3.6\PoMoCo-master\PoMoCo.py”?

What python did you use?

Using Python 2.7.6 on both Linux and Windows.

The only stuff I found online about the error was related to using the python interactive shell
stackoverflow.com/questions/1677 … ot-defined

Im using python 2.7.3
What are the dependencies for your pomoco?

[quote=“TooManySecrets”]Im using python 2.7.3
What are the dependencies for your pomoco?[/quote]

I have no idea, and I don’t know how to check.
From memory I needed to include os to get the file attribute to work.

Ok scrap that i got it mostly working on my raspberry pi but i got this now.

i ran it with -n and -j

[code] File “PoMoCo.py”, line 73, in
GUI.noGUI(controller)
File “/home/pi/PoMoCo 2.3.6/PoMoCo-master/PoMoCo/GUI.py”, line 1447, in noGUI
app.estop
NameError: global name ‘app’ is not defined

[/code]

[quote=“TooManySecrets”]Ok scrap that i got it mostly working on my raspberry pi but i got this now.
i ran it with -n and -j
[/code][/quote]

I probably didn’t make it clear, but the NoGUI version (-n) doesn’t work with any of the other options apart from -f=FPS.
If you want to use the -j you must have a GUI

does the -n go directly into kinematic mode also?

If so then i did not understand it.

edit:
just tried only with -n and the same thing happened.

Command line arguments:
When using the -n argument the only other allowed argument is -f
-n Run PoMoCo headless (No GUI)
-f=FPS Specify an FPS for PoMoCo to run at (only works when running PoMoCo headless)

When not using the -n argument (No GUI) you can use the following arguments:
-j Immediately launch into Kinematic Control mode (enable joystick)
-c Launch the camera viewer on start
-v Launch camera server on start

[quote=“TooManySecrets”]does the -n go directly into kinematic mode also?

If so then i did not understand it.

edit:
just tried only with -n and the same thing happened.
[/quote]

like i said. Anyway to tired to mess around with it anymore.

You’re right, I seem to have broken the ability to run without the GUI at some stage of development

I thought it was going to be a very handy feature at one stage, but the more work I do on hexy the more I realise I need the GUI. I think I’ll just remove it in future versions.

Hello,
Could you please post your version of picuntu RC3, so I can download it?
I would be so grateful.