torstai 27. toukokuuta 2021

Matrix tips they don't tell you

 

FAQ

 

1. Why is this in blogger.com? This is ugly

 

Migrated to fediverse! https://wordsmith.social/cos/matrix-tips-they-dont-tell-you


lauantai 15. helmikuuta 2020

Mitä vikaa Telegramissa?

Telegram-pikaviestimestä on tullut melko suosittu joissain piireissä. Siinä on kuitenkin joitain puolia jonka vuoksi sitä ei voi suositella ainoana viestimienä uusien yhteisöjen perustamiseen.

Tässä on avattuna muutamia Telegramiin liittyviä ongelmia ja lopussa ehdotus ongelmien ratkaisemiseksi tai ainakin kiertämiseksi. Artikkeli on kirjoitettu lähinnä harrasteyhteisöjen näkökulmasta, yritysmaailmassa on eri kuviot. Lukijan oletetaan tietävän pikaviestinten eroavaisuudet tai osaavan selvittää ne tarvittaessa.

3. Tekniikka

 

Käyttäjän kannalta Telegramin asiakasohjelmat ovat samalla viivalla muiden nykyaikaisten viestimien kuten Slackin, Riotin, Mattermostin jne kanssa. Kaikissa on jonkinlainen kanavalista josta kanavan valitsemalla näkee keskustelun sisällön jossa virtaa tekstiä ja kuvia. Telegramin virallinen asiakasohjelma on avointa lähdekoodia josta iso peukku.

Telegramista puuttuu muihin palveluihin siltaamisen kannalta olennainen ominaisuus eli kummituskäyttäjät. Kummituskäyttäjillä (ghost user) tarkoitetaan sillan loihtimia käyttäjiä, jotka edustavat sillan toisessa päässä olevia käyttäjiä. Esimerkiksi IRC, Slack ja Matrix tukevat kummituksia ja niissä sillan toisessa päässä olevat käyttäjät näkyvät "oikeina" käyttäjinä.

Telegram-kanavan siltauksessa Telegramin päässä siltabotti toistaa toisten käyttäjien viestit mikä hieman vaikeuttaa keskustelun seuraamista ja yksityisviestien lähettäminen sillatuille käyttäjille on mahdotonta.


2. Yksityisyys

 

Telegramissa käyttäjän identiteettinä toimii puhelinnumero. Tämä kuulostaa alkuun ihan hyvältä idealta, mutta aiheuttaa ongelmia.

Yhdellä laitteella ei voi olla kuin yksi Telegram-tunnus. Et voi tehdä toista tunnusta esim työkäyttöön hankkimatta toista puhelinliittymää. Käyttäjänä näkyvän bottikäyttäjän luominen ei onnistu (bottien luomiseen on oma rajapintansa).

Puhelinnumero on erinomainen tapa yksilöidä ihminen tietokannassa. Yhdistämällä puhelinnumeron sisältämiä tietokantoja saadaan käyttäjästä kerätä paljon luotettavampaa tietoa joten puhelinnumerolla yksilöity tieto voidaan myydä kalliimmalla.

Telegram väittää että se ei myy käyttäjiensä tietoja kolmansille osapuolille. Tähän voi uskoa ne, jotka haluavat mutta sitä on vaikea todistaa suuntaan tai toiseen, koska palvelinpää on täysin suljettu.

1. Hallinto

 

Telegramin omistaa venäläisen Pavel Durovin rahoittama yritys Telegram Messenger LLP. Telegram pyörii täysin Durovin lahjoitusvaroin ja Durovin mukaan ei pyri tuottamaan voittoa.

Kuulostaa hyvältä? Mutta vaikka tilanne on tämä nyt, Telegram on kuitenkin yksittäisen tahon hallinnoima ja infrastruktuuriltaan suljettu palvelu. Jos Durov kääntää rahahanat kiinni, Facebook ostaa koko firman tai tapahtuu muuta yllättävää, voi tilanne muuttua eikä käyttäjillä ole siihen mitään valtaa.

Telegramin käyttäjillä ei ole mitään sanomista siihen mihin suuntaan se kehittyy ja mitä ominaisuuksia siihen tulee. Telegram sallii kolmannen osapuolen asiakasohjelmat, mutta sekin voi muuttua yksipuoleisella päätöksellä koska tahansa (muistatteko Facebookin XMPP:n ja Slackin IRC:n?).

Telegramin omistajan luotettavuutta arvioidessa kannattaa muistaa myös 1.7 miljardia dollaria tienannut kryptovaluutta-huijaus.

Mitä sitten kannattaa käyttää?

 

Jokainen yhteisö päättää miten haluaa palvella jäseniään. Nämä ovat omaan kokemukseeni perustuvia suosituksia. Oletuksena on, että yhteisö piittaa sekä tekniikasta, yksityisyydestä että hallinnosta. Jos näillä ei ole väliä, voi käyttää vaikka WhatsAppia (Älkää nyt oikeasti käyttäkö silti).

(Kuva ei mittakaavassa)

Olemassaolevat yhteisöt


Hacklab-yhteisöissä lähtötilanne oli se, että labit ja labien jäsenet käyttivät sekaisin IRCiä (kahdessa verkossa), Telegramia ja Slackia.

Noin 2018 tuli huhu uudesta viestimestä nimeltään Matrix millä pystyisi siltaamaan eri palvelut. Matrix otettiin koekäyttöön ja alkuaikoja vaivanneiden teknisten ongelmien jälkeen se on toiminut varsin mukavasti. Uusille suositellaan Matrixin käyttöä jolloin sillä pääsee "kaikille" kanaville helposti, mutta vanhat voivat käyttää omia suosikkiviestimiään kuten ennenkin.

Käyttäjän kannalta tälläisessä järjestelyssä ei ole väliä mitä viestintä kukakin käyttää, eikä se näy mitenkään keskustelussa poislukien Telegramin päässä oleva siltabotti. Uusia viestimiä voidaan ottaa kanavalle mukaan ja turhia poistaa tarpeen mukaan keskeyttämättä keskustelua.

WhatsApp on mahdollista sillata, mutta se on aikamoinen säätö

Harrasteyhteisöissä monilla on valtava muutosvastarinta pikaviestimien suhteen. "Ylhäältä päin" annettu määräys siirtyä käyttämään tiettyä viestintä ei toimi. Pahimmassa tapauksessa yhteisö jakaantuu kahteen koulukuntaan pelkästään sen takia että toinen puoli haluaa käyttää eri pikaviestintä. Matrixin sillat ovat olleet valtava apu sovun säilyttämisessä.

Uudet yhteisöt


Uusille yhteisöille kannattaa suosia samantien Matrixin käyttöä. Se on ei-teknisten ihmisten helppo ottaa käyttöön ja täyttää tekniset, yksityisyydelliset ja hallinnolliset vaatimukset paremmin kuin mikään muu. Tämän jälkeen kannattaa selvittää mitä viestimiä jäsenet mieluiten käyttävät ja pystyttää Matrixiin sillat k.o palveluihin, mikäli mahdollista.

Jos yhteisö on isompi ja teknisesti orientoitunut, kannattaa harkita oman Matrix-palvelimen pystyttämistä. Sillä käyttö on nopeampaa kuin matrix.orgin välillä ruuhkaisella palvelimella ja pystyttäminen ei ole valtavan vaikeaa.



t: @cos:hacklab.fi

tiistai 25. kesäkuuta 2019

Matrix Synapse authentication from Unix user accounts

Problem: You have an organization (university, business, hackerspace, etc) with existing user accounts on a Unix server. You want to host Synapse homeserver for them so that they can use their existing accounts to log in. 

Here's how to do it quite easily.

We use three main components:


  • Synapse - the Matrix homeserver
  • Synapse REST Password provider - This is a plugin to Synapse that acts as a HTTP client asking "I have client with this username and password, is it valid?" 
  • pam-auth-rest-api - This is a HTTP server which receives the question, checks Unix PAM (Pluggable Authentication Modules) if the username / password pair is valid, and returns the information to the password provider.
You can run the homeserver on same or different server to where the accounts are. Security-wise it's probably better to have own server for Synapse.


Set up synapse

 

Read the installation instructions. I installed as Debian package. It doesn't matter how you install it. Remember to use postgresql database.

Use federation tester to make sure your homeserver is seen by the federation.

 

Set up REST Password provider

 

Read the instructions here. You just copy the plugin file to a specific directory. In homeserver.yaml you need to add the magic lines:


password_providers:
  - module: "rest_auth_provider.RestAuthProvider"
    config:
      endpoint: "http://server.with.accounts:3000"

 

Set up REST PAM API


This should be done on the computer with the Unix accounts, whether it is the homeserver or not.

Read instructions here.  You'll need to git clone the repository and do some setup. It is a node.js application so you'll need to install required nodejs packages as needed.

There is a systemd service file provided that can be used to automatically start the server.

After you have set up the server, test it with curl by running:

curl -X POST -d '{ "user": { "id": "@john.doe:example.org", "password": "passwordOfTheUser" } }' -H "Content-Type: application/json" http://localhost:3000/_matrix-internal/identity/v1/check_credentials  

This should return json with success: false (or true, if you provide real user credentials). 

You can also do the same test from Synapse server by replacing localhost with the hostname of the account server.


Test the setup



Now you can test the whole pipeline. Open a new private browser tab, load https://riot.im/app , Sign in, change homeserver to your homeserver and enter valid user account credentials. You should be logged in as a new Matrix user on the homeserver.

Note: homeserver name needs to be the real hostname of the server (https://matrix.example.org, not https://example.org).

If something fails, check the Synapse log and systemd log for the REST PAM API.

If you have questions or comment, I'm on #synapse:matrix.org and I'll try to help.


Good luck!

- @cosmo:modeemi.fi

End notes


  • The REST Password provider is no longer maintained by its author. I'm tempted to fork and continue work on it unless someone else wants to.
  • HTTP request between homeserver and account server is not encrypted. If these are different computers and there is possibility of a MITM attack, It's recommended to encrypt the traffic. I tried stunnel first (failed as the password provider doesn't like self-signed certs) and finally got it working with autossh ssh tunneling. You could also use reverse http proxy, vpn, or anything like that.

torstai 12. huhtikuuta 2018

Gemini PDA hacker's guide


 Gemini PDA hacker's guide

Here's a collection of hints on how to do stuff on your Gemini they don't tell in the official documentation.


Linux warning

 Just a warning for non-hacker users: The Debian Linux for Gemini is still early alpha (12. Apr 2018) and it's not usable for daily work yet. Xorg uses slow software rendering, keyboard mapping is not right, Fn-modifier doesn't work so you can't type some characters etc. The best way to use it is from another computer via SSH.  This is why it's called technology preview.

Anyway, make sure you have everything backed up and ready to reflash everything if something breaks.

Flashing the operating system

There is now official Linux version of the flasher tool provided by Planet. Use it.

Accessing Linux via USB networking

If you are in situation when you can't access Linux side of Gemini, you can get there by USB networking:
  1. Boot to Linux on Gemini
  2. Connect USB cable
  3. ssh gemini@10.15.19.82
 This works directly on Ubuntu.

If DHCP doesn't work, you can do sudo ip addr add 10.15.19.1/24 dev usb0; sudo ip link set usb0 up
(usb0 can be renamed into something else by udev, check dmesg)

Linux setup and general hints

I've created a shell script to help setting up Gemini's Debian:
https://github.com/gemian/gemini-scripts/blob/master/linuxsetup.sh

Usage is documented in the script itself, please read it.

NOTE:
  • GDM display manager from Gnome doesn't seem to work. Gray screen after logging in. Use the default display manager.
  • In Gnome the WiFi password dialog doesn't seem to work from top right corner menu. Open Settings / Network from menu, from there you can connect.
  • By default Debian uses connman for managing network connections. You might want to remove it and install NetworkManager which is more commonly used by desktops. 
  • Don't try to mount the android system partition from Linux, at least in rw  mode. Android won't boot after that and you'll need to reflash.
  • To get larger widgets for touch usage in Gnome run:
    gsettings set org.gnome.desktop.interface scaling-factor 2 
    
    

Booting TWRP

It's possible to boot TWRP to install other distributions such as Sailfish on the Gemini. But booting it can be tricky. TWRP for Gemini can be found here.

  1. Copy the files you want to flash with TWRP to Android Download folder, sd card or other place accessible from TRWP.
  2. Boot to Debian.
  3. Copy the TWRP .img file to Gemini from your pc:
    1. scp twrp-geminipda-3.2.1-0.img gemini@10.15.19.82:
  4. sudo dd if=twrp-geminipda-3.2.1-0.img of=/dev/disk/by-partlabel/recovery
  5. Power off the device.
  6. Power on the device by holding ESC for until screen turns on. TWRP should launch.
NOTE: Next time you boot Android, the recovery partition will be wiped and you need to repeat this!

Installing Sailfish

It's now in "closed beta". Don't ask me where to download it from. Hopefully it will be public soon. Here are the steps to install it in it's current form:

  1. Install Android + Linux image, set up Debian (at least run resize2fs if you don't run the full script)
  2. Make a backup of linux_boot: sudo dd of=linux-boot.img if=/dev/disk/by-partlabel/linux_boot
  3. Download the sailfish .zip file to Android's Download directory. For some reason TWRP didn't find it if i just copied it to Android filesystem via Debian. MicroSD card should also work.
  4. Boot TWRP.
  5. Select the .zip from Downloads and install.
  6. Power off and boot to Linux. Sailfish should start. The tutorial is a bit broken but you should get past it.
  7. In Sailfish make a backup of linux_boot: dd of=sailfish-boot.img if=/dev/disk/by-partlabel/linux_boot

Switching between Sailfish and Debian

Overwrite the linux_boot partition with image you made earlier. For example to get from Sailfish to Debian, use dd if=linux-boot.img of=/dev/disk/by-partlabel/linux_boot

GUI for this would be nice.

NOTE: You can access Sailfish sysroot from Debian at /.stowaways/sailfishos and Linux sysroot from Sailfish by mounting /dev/mmcblk0p29 in any directory.

tiistai 8. maaliskuuta 2016

Why icons are needed in combat flight simulators


By cos / VLeLv Icebreakers

UPDATE 22.2.2017: Found 2 more sources for eye angular resolution, updated calculations based on it. 0.3 -> 0.6 arc-minutes.

In recent years it’s become a trend to force icons off in many multiplayer flight simulator arenas. The icons are said to be unrealistic and not needed for realistic simulation. As a real life pilot I have noticed that in real life you can see an aircraft several kilometers away and see it’s color, attitude and larger details. In flight simulators the same is not possible - you just see a pixel or few.

Seeing your opponent as soon as possible is paramount in air to air combat. I decided to study the issue and found out that icons must be used if you want to fly realistic air combat. Icons are a compromise caused by limitations in current display technology. You can fly without icons, but then the visual detection and identification ranges are much shorter than in real life.

Resolution comparison

Human eye is not a digital camera. It is analog device and has various smart features. The eyes move constantly and paint the image in our brain. Regardless of this, we can calculate a resolution for eyes for comparison.

According to [1], human eyes have FOV of about 200 degrees horizontal and 130-135 vertical.

There are several different values for the visual angle or one “pixel” in human eye.
According to [2] it's 0.3 arc-minutes. According to  [7] it's 0.6 arc-minutes.
According to [8] (page 16 table) it's 0.63.

Let's assume the correct value is 0.6 arc-minutes which is 0.01 degrees. If we limit our study to a more moderate usable FOV of 120 degrees in both directions, the human eye resolution is 144 megapixels [3].

A average modern monitor has resolution of 2560*1200 pixels. This is about 3 megapixels. The FOV is usually about 75 degrees in a flight simulator.

We can calculate how many pixels we would need in a monitor to match the eye angular resolution for 75 degree image: 7500*7500. That would be 56 megapixels.

One more geometry exercise: How many “pixels” wide is an aircraft with wingspan of 15m at 10km distance?

On a 2560*1200 monitor with 75 degrees horizontal FOV one pixel represents 0.0293 degrees [4].

The aircraft is 0.0859 degrees wide. This gives 8.6 “pixels” with human eye [5]. You should be able to see its orientation and larger details quite well.

With a monitor, this would give about 2.9 pixels [6]. You might be able to see aircraft color, but not orientation or other details. Even noticing the aircraft against terrain would be difficult.

In summary:


Human eye
Typical monitor
Horizontal FOV (degrees)
200 (120 used in calculations)
75
Resolution (pixels)
7500*7500
2560*1200
Megapixels
144
3
Angle of one pixel (degrees)
0.01
0.0293
Size of 15m object at 10km (pixels)
8.6
2.9

With first generation VR headsets (OR CV1, HTC Vive, etc) the resolution issue is even worse - they typically have resolutions of about 1200*1200 which is less than half of the typical monitor used here. FOV is luckily better (110 degrees on both).

Peripheral motion detection

In addition to resolution one important factor is the peripheral motion detection. Eyes and brain are able to detect targets moving against background outside the high-resolution central vision area. When flying, this is very important as it allows noticing other aircraft  when looking elsewhere.

It's difficult to measure any significant numbers on the motion detection so it's excluded in this study. I also didn't find any data on if or how well this works on monitor compared to real life. At least the FOV is significantly smaller on monitor which naturally has an effect on target detection.

Suggestions for simulator developers


As the chapters above explains, icons are mandatory for realistic air combat in visual range. Many simulators implement icons in sub-standard way, and they often either unrealistic (too long range / visible through cockpit) and ugly (line of text).

Here’s my suggestion:

Use these ranges as baseline. Make sure that in multiplayer situation all players have the same settings forced. Players should have option to turn off icons, if they want.
Range
Icon
5km
Detect small aircraft
3km
Show aircraft type and friend or foe
1km
Show any other details as needed (weapon loadout, etc)


    • Make the icons look good. Use alpha blending to gradually display them.
    • Darkness, clouds, fog and sun glare should decrease the distances.
    • Icon must not be shown if the target is behind obstacle (mountain) or in other way not visible from cockpit.
    • Use visual means to display distance (a bar or arc instead of text). Distance is difficult to judge visually so this doesn’t have to be very accurate.
    • Keeping the target in view for longer period can increase the distances. For example you might be able to detect a target or identify it's type if you look at it for several seconds.
    • It is more difficult to notice targets against ground than against sky. Reduce the distances, if the target background is ground.
    • Large aircraft should be detected and identified from longer distance.
      For an example of well working icons, take a look at World War 2 Online. See videos of the simulator to see how the icons work.

      Thanks for reading!






      [4] 75 / 2560

      [5] 0.0859 / 0.01

      tiistai 12. helmikuuta 2013

      Running Qt applications in Android

      Digia (owner of Qt) is working on official Android and iOS ports of Qt, but meanwhile Qt applications can be built and run in Android using Necessitas, an open source project which forks official Qt SDK. Currently it is still in beta phase but is already usable. This document has been written in early February 2013 so it may not be valid with later Necessitas versions.

      Setting up

       Necessitas SDK

      Download and install Necessitas SDK from http://necessitas.kde.org/necessitas/necessitas_sdk_installer.php

      Launch SDKMaintenanceTool from Necessitas. Select the desired API level from Miscellaneous/Android NDK. You could here also install Android SDK under Necessitas if you don't already have it installed.
      Note: While testing API level 10 seemed to work the best. Later versions launched always in AVD even when a device was connected.




      Android SDK

      Download and install Android SDK from http://developer.android.com/sdk/index.html
      Load the Android SDK version you want to support using android_sdk/tools/android tool.



      Building

      Launch Qt Creator from Necessitas installation using QtCreator/bin/necessitas (not bin/qtcreator!)

      Open a project (existing one or create a new). A "Configure Project" dialog is shown.

      Set the project as "Necessitas Qt 4.8.2 for Android armv7a" project. You can also select other platforms you might want to build to.

      Select from menu Tools | Options and Android page. Set "Android SDK location" to the path you installed Android SDK. If you need to create a Android Virtual Device (emulator) create it now.

      Some items were not autoconfigured in my install, so:

      Set x86 GDB to android-ndk/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-linux-android-gdb
      Set x86 gdbserver to android-ndk/prebuilt/android-x86/gdbserver/gdbserver
      Set OpenJDK location to /usr/bin/java

       Click "Ok" to close dialog.
      Click on build configuration icon in bottom left corner, above "Run" button. Select the Necessitas build and Debug or Release, which one you prefer.
      Click Projects (on the left side bar) -> Run Settings -> Deployment -> Package configurations -> Android target SDK. Change it to the android version you plan to use.
      In "Deploy configurations" you can select wheter to include Qt libraries in your package or use Ministro to download libraries on demand. Ministro seemed to work on device but not in AVD. Ministro is a "library downloader" which will install the required Qt libraries to Android so that they can be shared between Qt applications.

      Press Ctrl-b to build the application.

      Running

      Press Ctrl-r to run the application. Application should start in device (if connected) or in AVD.
      Sometimes i got error "Found some build errors in current task. Do you want to ignore them?" but ignoring errors worked and the application would run nicely.

      Conclusion

      The Necessitas SDK is clearly still beta quality, but already can be used to port existing Qt applications to Android or create Android apps from scratch. Source changes are normally not needed at all. Naturally UI's may need adjustment for touch interface if they have been implemented on desktop. Applications built
      using Necessitas can be and have been published in Google Play store.

      sunnuntai 29. tammikuuta 2012

      State of Linux video editors

      I need to edit some videos randomly. Nothing professional, mostly some clips from a GoPro or cell phone video camera. I need to cut & paste clips and add music soundtrack. This should be the basic feature set of any video editor, but unfortunately most of them fail one way or another.

      See also State of Linux audio players

      Here is a comparison of few free video editors available. They are tested on Ubuntu.

      Kdenlive (tested march 2014)

      Current winner. Does all I need without issues. UI could use some polishing, but good enough.

      OpenShot (tested summer 2013)


      Decent video player. Crashes randomly but is still usable. Ui misses some features, such as moving a clip to end of previous clip which makes editing long videos painful. Also there's still no way to select multiple clips.

      PiTiVi 0.15 (tested jan 2012)


      Mediocre but not bad UI. Preview becomes so slow that it's practically a slideshow with multiple 720p videos. Crashes frequently. Development is active but work is done for next version based on gstreamer editing services. I had a problem with rendered files having zero size, but this was fixed by removing gaps from the project. Many thanks to thiblahute on #pitivi.

      Cinelerra (tested spring 2011)

      Crashes so often that it's useless. UI looks like it's from 90's.

      VLMC (checked summer 2013)


      Spawned from VLC media player. Looks promising but i suppose develoment is dead as the official repository doesn't have packages for current or previous Ubuntu release.

      torstai 26. tammikuuta 2012

      Saving all channels in irssi

      Normally it's only possible to save channels one by one in irssi. This is quite annoying. Here's a small script to save 'em all (thanks pulk!):

      /alias channelsaveall script exec foreach my \$channel (Irssi::channels()) { Irssi::command("channel add -auto \$channel->{name} \$channel->{server}->{tag} \$channel->{key}")\;}

      Copy-paste that on a single line and then just /channelsaveall.

      lauantai 8. tammikuuta 2011

      How NOT to add force feedback to your flight stick

      I want to add force feedback support to my CH fighterstick. Currently no one makes consumer-priced force feedback flight sticks, so I can't buy one.

      This project started a few years ago and has lasted over several iterations.

      First fail

      The first version had a large RC car servo connected to the stick. For prototyping i implemented force feedback only on elevator axis of the stick. I bought a serial servo controller and a usb serial dongle to control the servo and wrote a plugin for X-Plane to control it. It worked well and caused good force, but the stick could not be "relaxed" at all. In slow flight i needed to push or pull the stick quite hard to move it (and the servo). High-speed aerobatics felt really good though, so i knew i was up to something. Unfortunately this was not realistic enough so i ditched this prototype.

      Second fail

      I found a few old printers from electronic waste bin at work and looted them for parts. They contained many usable parts such as motors, axles, gears and belts.


      I set up one motor (don't know the specs, maybe 300 size) with a belt to a larger gear to get a sensible gear ratio. To control it i bought a Phidgets USB motor controller board.


      Unfortunately this time controlling the force was difficult - with low power it just made noise and with large it suddenly started moving rapidly. Also the maximum force was not large enough. The belt slipped sometimes, no matter how i adjusted it. It wouldn't work so i ditched this one too.

      Third fail

      This time i decided to make a more powerful version of the last prototype. I got some stuff meant for RC planes: a gearbox and a Speed 400 motor. They fit perfectly together and felt mechanically strong.


      This time there was plenty of power. I hooked up a multimeter to monitor current use and the largest current measured in beginning of tests was 19A. I decided to not to monitor current longer as the multimeter was meant for currents only up to 15A. After a little tuning the thing seemed to work! I removed the centering spring from fighterstick and did some additional testing until smoke started pouring out of the motor. Third fail.

      Clearly electric motor is not the way to go. If i used a larger motor, the current would go even higher and over the limitations of the controller board. Using larger gear ratio would cause the same problem as with servo - it would be impossible to cause small or no force.

      Next fail

      Pneumatics? Hydraulics? Stay tuned!

      perjantai 10. joulukuuta 2010

      ExtPlane Panel for X-Plane

      I bought a touchscreen monitor to use in my simpit a while ago. Unfortunately after that I noticed that X-Plane's external cockpits don't support any input - I can't press buttons and turn knobs using finger.

      I almost got dismotivated by that but decided to do what any of us would do: write a plugin for X-Plane to support input from external apps and software to run my panel.

      The plugin part lives inside X-Plane and starts a TCP server to get commands from. Currently it supports only reading and writing of datarefs (simulation variables) but button support is coming soon. The plugin's source code can be found at:

      https://github.com/vranki/ExtPlane

      The panel, called ExtPlane panel is a "client" for ExtPlane plugin. It displays a 2D panel showing various instruments. It can read and write X-Plane's datarefs via ExtPlane and display any information on screen. Currently it's aimed for making sharp, antialiased scalable vector graphic displays (as opposed to X-Plane's bitmap based) but in future "anything" can be done. Instruments can be added, moved and removed using mouse just like in X-Plane's Plane Maker.

      The panel is written in Qt, so naturally i wanted to see if it would run on my Nokia N900 cell phone. As you can see, it runs without any modifications. Also there are no wires - The N900 communicates with X-Plane over WLAN connection. On the left is a airspeed gauge and on the right a compass. Currently they are the only instruments available, but it's very fast to write new ones using the framework provided. The airspeed indicator is 40 lines of code and compass is 37. The instruments can have configuration UI so that for example you can set the units used in airspeed indicator. I'll probably soon write some "generic" instruments that can show value of any dataref, just like in X-Plane.

      All instrument graphics are vector graphics so they can be freely scaled and rotated while keeping graphics crystal clear. You can run the panel in portrait or landscape mode, or even with any angle.
      Sources for ExtPlane-Panel can be found at:

      https://github.com/vranki/ExtPlane-Panel

      If you're not a developer and don't know how to build from sources, ExtPlane is not ready for you just yet. I'll need to add more instruments and do some more finishing until I'll start making binary releases for general public.

      perjantai 3. joulukuuta 2010

      Streaming live DVB using VLC

      The problem: i needed to stream live DVB broadcast from home to the outside world. Limiting factors are bandwidth (1Mbps up) and CPU (Core 2 Duo @ 1.8Ghz). I found out a lot of guides on how to do it using VLC, but only a few worked. Source for the video in this case is a USB DVB-C tuner, but any DVB tuner which VLC sees should work.

      After a lot of tuning, the best result was obtained with the following command line:

      cvlc -v channels.conf \
      --sout \
      '#transcode{vcodec=theora,venc=theora,acodec=null,deinterlace,vb=700,fps=16,threads=2,scale=0.7}:standard{access=http,mux=ogg,dst=:8081}'

      This will give a average of 700kbps ogg theora stream scaled a bit down and with 16fps
      frame rate. This stream doesn't include audio, so you'll probably want to set acodec=vorbis
      and audio bitrate (ab=) something sensible.

      Stream is served at port 8081 and can be viewed locally at url http://localhost:8081/ using VLC or other video player. You'll need the channels.conf file (google how to obtain it). You can also use vlc instead of cvlc to get GUI. You can change channel from playlist window. This can probably also be done on command line somehow.
      Set threads= to number of cores in your CPU. On Core 2 Duo it's naturally 2.



      The quality can be described as "youtube-like". You don't want to watch Avatar on this but for some basic stuff such as sports, talkshows and news it's way better than no stream at all. Naturally if you have more bandwidth, increase the vb parameter. With 1M uplink 800kbps resulted in jerky video, so 700 is pretty close to optimum.

      Notes on some other codecs: x264 encoder didn't obey the bitrate parameter at all and was unusable. ffmpeg created corrup video (random bright colors et all) so i decided to use ogg theora which worked really well.

      perjantai 5. marraskuuta 2010

      State of Linux audio players

      (Last updated: 2.8.2012)

      I've been looking for a good music player for advanced users. I have a large music collection (hundreds of gigs) on a server which is mounted over sshfs. My requirements are

      - iTunes like UI based on tags - NOT file names and directories.
      - Ability to scan the large connection over and sshfs share in reasonable time.
      - Must not forget the whole database if the network share is  down temporarily.
      - Stay responsive. All programmers know that you shouldn't do any potentially long operations in UI thread, but most players seem to do so.
      - Ability to edit tags. A large part of collection is either untagged or wrongly tagged.

      Wishlist:
      - Allow multiple locations to be selected for library.
      - Some kind of indicator about what the scanner is doing. Ability to force re-scan of collection.

      And now to the players:

      Rhythmbox (Updated 30.7.2012)

      The Gnome's default music player. UI is pretty slick and nice. Works pretty well, except tagging files doesn't work at all (Unable to save song information - Timeout was reached). And sometimes grays out a little bit.
      If the network gets congested, Rhythmbox's UI gets totally confused and grays out. Looks like file operations are done in UI thread. This is the player i use the most, as on good day it can scan the full collection and be usable.

      Amarok 2.5.0

      Started scanning the library nicely and UI stays responsive. After 6 hours the
      scanner progress bar hasn't moved at all and there are 0 tracks in collection.

      Quod Libet

      I selected the library directory and hit "Reload Library". 0 files found. Maybe it doesn't understand symlinks?
      Ok, let's try playing from file system. I enter the library directory and.. The player grays out for a couple of minutes. The UI is very slow.. maybe it's scanning after all? I'll never know as i kill it.

      Exaile

      I add the library directory. Ui grays out just a little bit but says "Scanning collection..".
      After a while it still is scanning and has found 0 songs. The Radio tab seems to work and i can play a Shoutcast radio while waiting. UI is slow, so looks like some processing is done in the UI thread.
      I left exaile scanning for the weekend. On monday morning it was still scanning at 0%.

      Banshee (Tested 23.11.2011, Ubuntu Oneiric)

      UI seems very nice and possibly even better than Rhythmbox so this player gives a lot of hope. I added the collection directory and the app started scanning very nicely. Now, after almost 24 hours it displays 78%, uses 3.3 gigabytes of memory and is very unresponsive.

      Nightingale (Tested 30.7.2012)

      Download link and the ppa advertised do not work, so unable to test.

      Clementine (Tested 2.8.2012)

      UI looks nice and might be a good player if it works. Unfortunately it doesn't. It starts updating library and gets to 99% soon.. but the percentage drops to 85% and then back up.. until it repeadetly drops down. During scanning it doesn't add anything to library to be playable so it's impossible to see if it is really progressing.  To give it a chance i left it running overnight. After over 24 hours of scanning it is "Updating library 98%" and i decide to quit it.

      Conclusion

      They all suck, more or less. Let me know if you find any good player to be added here. I'll try to update this post whenever i test new players.

      sunnuntai 8. elokuuta 2010

      Cross-compiling Qt applications for Windows, the easy way

      For a while I've been looking for a way to cross-compile my Qt app for Windows on Linux. I don't have any Windows PC's at home or at office, so native build is out of question. There are several instructions how to do this, but they involve cross-compiling the whole Qt from source and a lot of other manual work.

      I found and easier way using Wine.

      1. Install Nokia Qt SDK for Windows using Wine. It should install fine.

      2. Create a build script that does something like this:

      export QTDIR=$HOME/.wine/drive_c/Qt/2010.04
      export Path=C:\\windows\\system32\\\;C:\\windows\\\;C:\\windows\\system32\\wbem\;C:\\Qt\\2010.04\\mingw\\bin\\\;C:\\Qt\\2010.04\\qt\\bin\\\;\
      C:\\Program\ Files\\NSIS\\
      cd app_directory
      wineconsole --backend=curses qmake.exe
      wineconsole --backend=curses mingw32-make.exe

      3. That's it! You should now have a working .exe in yout project directory. You can run it using wine.

      When shipping your application, you need to include the required mingw and Qt DLL's with it. For example:

      $QTDIR/qt/bin/mingwm10.dll
      $QTDIR/qt/bin/libgcc_s_dw2-1.dll
      $QTDIR/qt/bin/QtCore4.dll
      $QTDIR/qt/bin/QtGui4.dll
      .. and any other DLL's your app needs. Remember to use the d-versions if you build your app in debug mode.

      For SQL drivers install them into directory named sqldrivers in the directory where your .exe is installed. For SQLITE the DLL is $QTDIR/qt/plugins/sqldrivers/qsqlited4.dll.

      If you want to create an installer, I can recommend the open source Nullsoft installer (NSIS).

      maanantai 31. toukokuuta 2010

      RC Hornet first flight

      Recently I bought a F-18 Hornet model from Bananahobby.com. It's a ARF foamie which is pre-painted and looks pretty good. It has a brushless electric ducted fan motor and a 4 cell LiPo battery pack. The model took a few hours to build, most time taken by gluing wings and stabilizers and installing servo wires. The kit had a 2.4Ghz radio included and installed, but i opted to use my own DX7 with it's 7 channel receiver. If you or your friends need a cheap 4 channel RC radio set at Tampere area, let me know. I haven't tested if the receiver works with DX7 yet.

      I also decided to connect left and right ailerons to different channels in receiver and thus making them flaperons with DX7's mixing functions.

      Yesterday was the first flight day. First i flew with a full size sailplane (LS-8) and then made some preparations and waited for a rain shower to go away. When the rain stopped, weather was semi ok for first flight - there was some light wind but no strong gusts.



      Pre-flight photo.

      The flights went fine. I flew 3 flights, totalling maybe 15 minutes. I was alone at the airfield so there are no in-flight photos, sorry. The model has plenty of power - maybe close to 1:1 power to weight ratio. Cruising can be done at half throttle. It's also surprisingly stable - center of gravity is so low that it tends to correct any bank by itself. It's also pretty agile and looks great in flight. It's not easy to fly though - for example stalling can cost 10 meters of altitude easily. Landings must be done pretty carefully and at low angle to avoid hitting ground tail first.

      I tried using flaps (both up and down) but they caused huge trim change and almost losing control so i didn't use them during landings yet.

      The ESC that came with the kit doesn't warn about low battery by cutting power like ESC's usually do. This one just outputs less power which came as a surprise to me and caused unscheduled landing. I guess I'll have to have a stopwatch to estimate flight time left.



      Construction pic. Electronics are behind the plastic door which is glued into the fuselage.



      Looks like I'll have to buy a larger car if I want to get larger models than this.


      Link to the model (it's on sale now!):

      http://www.bananahobby.com/1940.html

      perjantai 26. helmikuuta 2010

      Converting music to mp3 in place

      I bought a new car stereo a while ago. I'm not going to specifics about it as this is not a car hifi blog. What's interesting is that the player can play mp3's from CD, USB memory and SD card.

      My digital audio collection is mostly in ogg and flac format for better quality/file size and the player can't handle them. I tried to find a nice solution to mass convert files from ogg/flac to mp3 but none of them were satisfactory so i wrote my own script:


      #!/bin/bash
      # Convert flac & ogg audio to low quality mp3 for mobile playing.
      # By Ville Ranki

      find -type f -name "*.flac" -o -name "*.ogg" | while read file
      do
      outfile=`echo $file | sed 's/\.[^\.]*$/.mp3/'`
      echo "Converting $file to $outfile"
      gst-launch-1.0 filesrc location="$file" ! decodebin ! audioconvert ! lamemp3enc target=quality quality=4 ! id3v2mux ! filesink location="$outfile"

      if [ -f "$outfile" ];
      then
         echo "Removing original $file"
         rm "$file"
      else
         echo "Error: File $outfile was not created."
      fi

      done



      This script will find recursively all files in current directory, convert them to mp3's (while preserving id3 tags) and delete the original files. It preserves directories as they are - my car player should be able to browse by directory although i haven't figured out how to do so.

      I use it by copying wanted music to a temporary directory, run the script in the directory and copy the results to usb stick or other media.

      Make sure you have all the commands installed before running the script, such as gst-launch-0.10. Also don't run the script where the original collection is or you'll lose it. Copy files somewhere else first.

      I hope this is helpful for others with the same problem.

      (Updated 23.7.2015 for gst-launch-1.0 and simplified the script at the same time)

      sunnuntai 13. joulukuuta 2009

      Sergei gunsight without the cover

      I'd like to add a couple more photos about the gunsight and how it looks without the cover. The cover reduces some glare and is good for anti-aircraft guns but for aircraft it may block visibility too much so most ww2 aircraft have the gunsight without any cover.

      Well, here are the photos:


      Side view. The reflector glass is in 45 degree angle.

      Another view

      Looking through the gunsight.

      Looking through, from longer distance


      This is what it looks like from top of the gunsight. It shows the reticle through the glass and inverted reflection.

      For the simpit i'll naturally remove the cover. This way the gunsight looks just like any WW2 fighter's gunsight. At least il2 supports removing any on-screen sights so maybe i'll even get to play some games with hardware gunsight. Otherwise it'll just look cool :-)

      Btw notice how the size of reticle is always the same regardless of the distance. That's how the reflection gunsight (and modern HUDs) are supposed to work.

      Next step is to mount the thing to the simpit. Let's see when that happens, as i have some other projects (hacks) to do such as the RC 109 used as practice target in photos above.

      perjantai 11. joulukuuta 2009

      Sergei gunsight illuminated

      Long time no post.

      Today i built a light for the sergei gunsight i've had for some time. It illuminates the reticle so it's more visible in various lighting conditions. Here's the photos:

      Lamp assembly is mounted on the bottom of the gunsight. The assembly is actually a plastic cap from a Pisang Ambon liquer bottle.


      This is the lamp holder, looking inside. Inside i put a piece of paper to spread the light evenly. Without the paper reticle was uneven as the light bulb could be seen through the reticle.


      This shows the whole reticle. Pretty nice!


      Comparison: Light turned off


      Light turned on!

      Photos taken with my new Nokia N900 phone. Less bad than the previous ones.

      lauantai 25. huhtikuuta 2009

      F-18 simulator on TV

      They showed Finnish Air Force's WTSAT F-18 simulator on tv in "Äijät" tv show. It's in Finnish, but i think everyone understands what's the idea. See the whole episode at:

      http://www.sub.fi/netti-tv/index.shtml/ohjelmat/aijat?12856

      Also getting to fly a Hawk is quite cool.

      torstai 23. huhtikuuta 2009

      Velocity EP second flight

      Today i got Velocity EP finally repaired and ready to fly. I installed the new electronics -

      * CC Phoenix 45 ESC
      * Ultrafly A/30/24 brushless motor
      * AR6200 2.4GgHz receiver

      - to the plane. My new shiny transmitter is Spektrum DX 7, which i got for discount as the shop didn't get DX6 in time. DX 7 is maybe a bit too high end for my use, but now i got it and it's really cool. Motor was compatible with Speed 400 and the mount didn't need modifications.

      The flights went good. This time i didn't crash the plane and flew very carefully (no high speed passes or low level aerobatics). Performance is AWESOME. 5 seconds with full throttle and the plane is so high i don't want to get it higher. Normal aerobatics such as loops and rolls are possible with 50% throttle. Level flight requires about 30% throttle. Thrust/Weight ratio is about 1. And this is not a lightweight depron model. I flew about 30 minutes and didn't get the battery to run out. I had to quit, because it became dark and cold.

      Velocity glides surprisingly well. I needed a few passes every time i tried to land it. Almost like Zagi 400. I don't think it can thermal though as it loses altitude rapidly when turning.

      Sorry, no photos this time as i was flying alone.

      Next time i'll try how fast it goes. My fear is that it might disintegrate mid-air. Let's see what happens.

      sunnuntai 12. huhtikuuta 2009

      More simpit details, updated web page

      I updated my personal web page about some details of the simpit. If you're intrested, you might want to check out http://www.modeemi.fi/~cosmo/projects/simpit/