Hexy with onboard Linux

Post all your hardware and software upgrades/projects here.

Hexy with onboard Linux

Postby klims » Mon Dec 30, 2013 1:38 pm

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

http://youtu.be/fehculO_qo4

Here is the bill of materials:
    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

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
    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

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



Cheers.
Last edited by klims on Thu Jan 09, 2014 8:56 am, edited 8 times in total.
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby klims » Tue Dec 31, 2013 1:07 am

TooManySecrets wrote:Im doing the same thing with a raspberry pi right now. I would love if you put down a tutorial for doing this on picuntu. I have the same stick you have at home.


This is the process from start to finish for an Official MK808 TV stick (not MK808B or MK808 clone)
    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


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)
Code: Select all
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
Code: Select all
sudo tar zxf /picuntu/filesystem/location -C /media/location/of/linuxroot



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
Code: Select all
depmod -a

3. Type "reboot"
4. Ensure you have a network location by typing the command "ifconfig" into the command line and check for an IP address
5. Once logged in, navigate to the /usr/local/picuntu/ directory by typing "cd /usr/local/picuntu/"
6. 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
Code: Select all
usermod -a -G sudo picuntu



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:
Code: Select all
sudo /usr/lib/lightdm/lightdm-set-defaults --autologin picuntu



Running x11 on Startup
Download X11VNC Server from the Ubuntu Software Center or type the follwing into the command line
Code: Select all
sudo apt-get install x11vnc

The following is the command that runs x11vnc from the command line with no password:
Code: Select all
x11vnc -forever -rfbport 5900

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:
Code: Select all
python /home/picuntu/PoMoCo\ 2.3.5/pomoco-master/PoMoCo.py -j

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


Tweaking CPU Speed
Install cpufrequtils:
Code: Select all
sudo apt-get install cpufrequtils

Check the available clock speeds:
Code: Select all
cpufreq-info -s

Check current settings:
Code: Select all
cpufreq-info -o

Set max cpu speed:
Code: Select all
cpufreq-set -u <freq>

Set min CPU speed
Code: Select all
cpufreq-set -d <freq>



Cloning Your SD Card
Linux:
1. Check the disk we are about to copy:
Code: Select all
sudo fdisk -l

2. Make sure the disk is not mounted before we clone it:
Code: Select all
umount /media/user/linuxroot

3. Clone the disk using dd:
Code: Select all
sudo dd if=/dev/sdb of=/image/location/sdimage.img bs=4M



Restoring Your SD Card
Restore the clone using dd:
Code: Select all
sudo dd if=/image/location/sdimage.img of=/dev/sdb bs=4M



You can find more instructions for installing Picuntu here but I have never had and luck using the pre-picuntu script.
Last edited by klims on Sun Dec 20, 2015 4:26 am, edited 20 times in total.
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby TooManySecrets » Tue Dec 31, 2013 5:53 am

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
Image
TooManySecrets
 
Posts: 79
Joined: Mon Jan 14, 2013 5:02 pm

Re: Hexy with onboard Linux

Postby rpcook » Tue Dec 31, 2013 2:07 pm

Hey klims, nice work on the onboard controller for Hexy!
Rob
A record of my exploits and musings with Hexy and Sparki: http://robcook.eu, content available under a Creative Commons license.
rpcook
 
Posts: 121
Joined: Tue Sep 04, 2012 6:42 pm
Location: Luton, UK

Re: Hexy with onboard Linux

Postby klims » Wed Jan 01, 2014 10:36 pm

TooManySecrets wrote: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.

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.

TooManySecrets wrote: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

1. 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.
2. I haven't really ever run it from full to flat, but my guess would be around 10 minutes.
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby klims » Thu Jan 09, 2014 6:28 am

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

Some of the features:
    View a webcam in an OpenCV highgui window (also does face detection by default)
    View webcam through a web browser (http://HEXY_IP_ADDRESS:8080/index.html)
    Accepts command line arguments
      -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
    Can run headless (not fully implemented)



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
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby klims » Thu Jan 09, 2014 8:55 am

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

Here is PoMoCo 2.3.6
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby TooManySecrets » Tue Jan 14, 2014 5:36 pm

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

Code: Select all
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
Image
TooManySecrets
 
Posts: 79
Joined: Mon Jan 14, 2013 5:02 pm

Re: Hexy with onboard Linux

Postby klims » Wed Jan 15, 2014 2:53 am

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

I'll do my best, but I think a pseudocode style outline would be best as it will probably vary from system to system

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

Code: Select all
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


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"?
klims
 
Posts: 31
Joined: Thu Aug 01, 2013 1:31 am

Re: Hexy with onboard Linux

Postby TooManySecrets » Wed Jan 15, 2014 11:56 am

What python did you use?
Image
TooManySecrets
 
Posts: 79
Joined: Mon Jan 14, 2013 5:02 pm

Next

Return to Projects and Upgrades

Who is online

Users browsing this forum: No registered users and 2 guests

cron