Recent Updates Page 2 RSS Hide threads | Keyboard Shortcuts

  • Useful Raspberry Pi commands

    Ellen 09:54 on September 12, 2013 | 0 Permalink | Reply
    Tags: commands,

    Autostart desktop

    1. Enter the following on the command line

    sudo raspi-config

    2. Select “3 Enable Boot to Desktop” with your arrow keys and press enter key
    3. Select and press enter key and your are back on the main menu
    4. Select with the tab key
    5. A dialogue saying “Would you like to reboot now?” Select with the tab key

    Autologin

    Enter the following on the command line

    sudo nano /etc/inittab

    Change the line:

    1:2345:respawn:/sbin/getty noclear 38400 tty1

    to this with {USER} as the name of the user you want to auto login with

    1:2345:respawn:/sbin/getty autologin pi  38400 tty1

    Hide mouse

    Install unclutter and it will hide when there is not activity.

    sudo apt-get install unclutter

    Then set a delay for how long it will take before hiding the mouse through the command line:

    unclutter -idle 1

    You can also set it for a specific user

    unclutter -idle 1 -user

    If you always want to hide the mouse, add the code into a shell script and make an auto start file like below:

    Autostart python script

    1. Create a desktop file that will run your python script

    cd /usr/share/applications/
    sudo nano app.desktop

    Add the following content to your desktop file:

    [Desktop Entry]
    Encoding=UTF-8
    Type=Application
    Name=app
    Comment=Start application
    Exec=sudo python path_to_your_script.py
    StartupNofitfy=false
    Terminal=false
    Hidden=false

    2. Save the file and exit the editor.

    3. Add the desktop file to your autostart directory with this command

    ln -s /usr/share/applications/app.desktop ~/.config/autostart/

    Make sure that you add this to the user you log in to. So if you log in as pi, stand in the directory pi and run the above command. If you use another user it would be /home/username/.config/autostart/

    To double check that your desktop file runs you can run it from /usr/share/applications/ directory.

    4. Reboot and see result

    Kill all processes for one service

    pkill omx

    From Python script:

    os.system(‘pkill omx’)

    Kill a certain process

    To kill a certain process you can pass it the entire command of the process to target just that process.

    pkill -9 -f "/bin/bash /usr/bin/omxplayer -s /home/pi/myfilm.mp4 -o local"

    This can be done directly from Python as well:

    os.system(‘pkill -9 -f "/bin/bash /usr/bin/omxplayer -s /home/pi/myfilm.mp4 -o local"’)

  • How to enable reverb in FMOD iOS

    Ellen 19:40 on May 5, 2013 | 0 Permalink | Reply
    Tags: , iOS

    To enable reverb settings in Fmod Designer click on “Window” > “Reverb Defs”. Select your reverb and click on the play button. The reverb is now active and the project can be built. Notice that for the time being Fmod Designer requires you to always activate this whenever you open your project. This is not done automatically. The name of your reverb, in this case “Reverb00″ is used later on in the code.

    Fmod_designer

    To activate the reverb in the code the follow code needs to be added:

    #import "SoundManager.h"
    #import "mySoundProject.h"
    @implementation SoundManager
    void ERRCHECK(FMOD_RESULT result)
    {
        if (result != FMOD_OK)
        {
            //fprintf(stderr, "FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
            exit(-1);
        }
    }
    - (id)initWithString:(NSString*)selectedProfile
    {
    system  = NULL;
        eventSystem = NULL;
     
        FMOD_RESULT result      = FMOD_OK;
        char        buffer[200] = {0};
        FMOD_REVERB_PROPERTIES reverb00;
       
        result = FMOD::EventSystem_Create(&eventSystem);
        ERRCHECK(result);
       
        result = eventSystem->init(32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE  | FMOD_INIT_DISTANCE_FILTERING, NULL, FMOD_EVENT_INIT_NORMAL);
        ERRCHECK(result);
        [[NSString stringWithFormat:@"%@/mySoundProject.fev", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
        result = eventSystem->load(buffer, NULL, NULL);
        ERRCHECK(result);
       
        result = eventSystem->getReverbPreset("REVERB00", &reverb00); // Same name as in Fmod Designer.
        ERRCHECK(result);
       
        result = eventSystem->setReverbProperties(&reverb00);
        ERRCHECK(result);
       
        result = eventSystem->getGroup("MySoundProject/MySoundProject", FMOD_EVENT_DEFAULT, &group);
        ERRCHECK(result);

  • Send OSC messages from Unity

    Ellen 11:30 on January 31, 2013 | 3 Permalink | Reply

    Many people wrote to me wondering how to send data from Unity through OSC back to Processing and other applications. Well the answer is simple, write the following code:

    oscListener.oscHandler.Send(Osc.StringToOscMessage(”/Your event name”));

  • Real time blend 2 textures in Unity

    Ellen 08:40 on September 6, 2012 | 11 Permalink | Reply
    Tags: , shaders,

    I had a hard time changing the texture of a game object in real-time where I tried out a movie fading between textures and using Lerp on the material. I wanted it to be dynamic and just be able to pass an argument to my script defining which texture to animate to. Many game objects had different shaders so it didn’t work just to Lerp the current material. So I create custom shaders for different objects that contained 2 textures “_MainTex” and “_Texture2″. I also added the blend option the the shader order to be able to control the blend of the texture from outside. Just adding the shader you can change the blend slider to see the result.

    See example of one diffuse shader with normal map.

    In my javascript I could then pass in which texture to change to and which one to change from.
    I set the textures I want to change between. These are set in the inspector of athouring environment of Unity and passed to the script.

    var firstTexture:Texture;
    var secondTexture:Texture;
    var thirdTexture:Texture;

    The script starts out with setting the default texture of the chosen game object. The game object could have been passed to the script as well. :-)

    function Start () {
        textureObject = gameObject.Find("myTextureObject");
        textureObject.renderer.material.SetFloat( "_Blend", 1 ); // Setting the current texture to be 100% visible
    }

    The public function changeTexture can be accessed from outside to recieve arguments for new textures. newTexture is used to store the new texture as soon as it is time to animate.

    public function changeTexture(myArg : float) {
      yield WaitForSeconds(0.3);

      if(myArg == 1) {
          newTexture = firstTexture;
      } else if (myArg == 2){
          newTexture = secondTexture;
      } else if (myArg == 3){
          newTexture = thirdTexture;
      }

      textureObject.renderer.material.mainTexture = newTexture;
      triggerChange = true;
    }

    In the update function the script always checks if it should change to a new texture. If changeTexture was called it starts blending to the new texture. At the end it sets the old texture to the new one and resets the blend:

    function Update () {
         if(triggerChange == true) {
              changeCount = changeCount - 0.05;

              textureObject.renderer.material.SetFloat( "_Blend", changeCount );
              if(changeCount <= 0) {
                   triggerChange = false;
                   changeCount = 1.0;
                   textureObject.renderer.material.SetTexture ("_Texture2", newTexture);
                   textureObject.renderer.material.SetFloat( "_Blend", 1);
              }

         }
    }

    BlendTextures.js is the entire javascript file of the script above.

    To implement this in Unity follow these steps:
    1. Add your script to the scene. Select the textures and normalmap you defined as public variables in BlendTextures.js.
    2. Create a material and choose your custom shader.
    3. Add the material to your game object.

    blend_textures_unity

    Read up on how to create your custom shaders in the Unity Documentation.

    • bloodair 06:30 on September 28, 2012 Permalink

      I love you Ellen :D

    • Aurorem 15:49 on November 6, 2012 Permalink

      Thanks! Great script! But how can I affect the material slider in the inspector with a GUI slider?

    • Marco Vidaurre 09:12 on December 23, 2012 Permalink

      Hi,

      Nice shader.

      Is there a shader for iOS or mobile that can do this efficiently?

      Thanks

      -Marco

    • omelchor 13:05 on May 29, 2013 Permalink

      Thanks!

    • Ellen 02:05 on November 14, 2013 Permalink

      @Aurorem You can pass the values of your GUI slider into your material script.

    • Ellen 02:05 on November 14, 2013 Permalink

      @Marco I have no idea. This was made with the standalone platform in mind.

    • ikhazen 11:53 on May 14, 2014 Permalink

      thanks!
      this saves my ass :)

    • Robert 23:35 on January 9, 2015 Permalink

      HI there I followed the directions and I’m getting a
      BlendTextures.js.js(36,3): BCE0005: Unknown identifier: ‘yieldWaitForSeconds’.
      and the script has no entry boxes below.
      Thanks
      Rob
      ob

    • Robert 23:41 on January 9, 2015 Permalink

      HI there I followed the directions and I’m getting a
      BlendTextures.js.js(36,3): BCE0005: Unknown identifier: ‘yieldWaitForSeconds’.
      and the script has no entry boxes below.
      Thanks
      Rob

    • cefaloide 12:02 on March 30, 2015 Permalink

      Thanks for your aportation!

      I get this error on BlendTextures.js:
      Assets/BlendTextures.js(42,3): BCE0005: Unknown identifier: ‘yieldWaitForSeconds’.

      If I comment the “yieldWaitForSeconds” and set “firstTexture”, “secondTexture” and “thirdTexture” to public it works perfectly.

      Thanks a lot!

    • eien 06:34 on June 16, 2015 Permalink

      @cefaloide

      I don’t know if you’re still looking into this, but there’s been a typo. It’s “yield WaitForSeconds” I’ve had that problem and a space solved it.

  • Unity + Processing Demo

    Ellen 10:11 on July 2, 2012 | 6 Permalink | Reply
    Tags: osc, , ,

    Test your Unity project with the Processing Osc Demo. Send your events through the Processing app and see them appear in the Unity project. There is also a timer in Processing sending events at all time changing the width of a cube in Unity. Download the Unity OSC example here.
    unity_processing_demo

    • Jeroen Boumans 20:35 on August 13, 2012 Permalink

      is it also possible to write towards a LED on the arduino board via Unity > Processing? For example if i press a GUI button in unity, a boole will be “true” and so a signal will be written towards processing, that activates the LED.

    • Ellen 07:44 on September 6, 2012 Permalink

      @Jeroen Boumans You can send osc events from Unity with the following code:
      oscListener.oscHandler.Send(Osc.StringToOscMessage(”/Your event name”));

    • Rufael 13:12 on February 11, 2013 Permalink

      Hello Ellen! We are a group of students who plan to use this example for a project. Your example works perfectly between Unity and Processing but we would like to use the Processing-sketch on Android.
      There are some things that are problematic, for example the Serial library for Processing that does not work on Android.
      Do you have any tips on how to go about doing that? To get the Processing Sketch to work on Android so that one can send messages to Unity wirelessly.
      Great work otherwise!
      Mvh Rufael

    • Rufael 00:34 on February 12, 2013 Permalink

      Actually, we figured it out. You just have to tweak the ip-adresses a bit! Thanks anyway!

    • Niels 10:01 on May 15, 2014 Permalink

      Thanks for this Ellen, helped me out a lot.
      For those wondering, the Osc.StringToOscMessage(”/Your event name”); makes typetags out of each chunk of data seperated by a spacing, except for the first (so in this case “event” and “name”).

    • perfectsugar 12:40 on July 6, 2014 Permalink

      Hi, I’m a high school student in Japan and I’m a beginner at programming.
      …I got a trouble now.
      I tried to run this example in Unity and Processing but I failed.
      There’s only error in Unity and it says that:
      Assets/Scripts/OSCController.cs(18,29): error CS1501: No overload for method `Init’ takes `3′ arguments
      How do I correct this error in Unity??
      Could you please tell me how it works ?

  • Heavy duty pull sensors

    Ellen 18:21 on June 25, 2012 | 0 Permalink | Reply
    Tags: , , ,

    Interacting with installations with a long life time we turn to heavy duty sensors that can handle a lot of cycles. The string and pull sensors below can handle more than a million cycles and are built for industrial use. They can also be connected to circuit board like Arduino.

    Check out all the pull sensors and string pots from Celesco. Novotechnik also offers a wide range of pull sensors.

    Check out this Processing and Arduino project by nhw3030 with Celesco string sensors.

  • Unity + Processing + Arduino

    Ellen 10:32 on May 31, 2012 | 18 Permalink | Reply
    Tags: , , , ,

    I did a test connecting Arduino and Unity with the help of Processing and a Open Sound Control library. When I am pushing the Flexi Force sensor the values affect a cube within Unity. To get this setup do the following:

    Arduino
    Load the Standard Firmdata on to your Arduino. Check out a full Arduino + Processing tutorial to get the setup.

    Processing
    Download the oscP5 processing library and put it in your Processing sketch folder in the folder libraries.

    Initialize oscP5 library and broadcast data to port 12000. The port Unity will listen to.
    Add the remote location to listen to on port 3200. If Unity would broadcast event in this example, the broadcast port would be set to 3200. Initialise Arduino to be used later on.

    oscP5 = new OscP5(this,12000);
      myRemoteLocation = new NetAddress("127.0.0.1",3200);
      arduino = new Arduino(this, Arduino.list()[0], 57600);

    In the draw function we read the analoge pin 0 to get sensor values from the Flexi Force sensor. Set the OSC message to flexiforce. Unity will listen to this label. Add the message of the sensor value into the osc message with add method. This method can take numbers, strings and byte data.

    float flexiforceSensor = arduino.analogRead(0);
    OscMessage oscMess = new OscMessage("/flexiforce");
    oscMess.add(flexiforceSensor);

    oscP5.send(oscMess, myRemoteLocation);

    The entire Processing sketch can be seen here.

    Unity
    In Unity you can import the Osc.cs and UDPPacketIO.cs to broadcast and listen to UDP data.

    Set up the corresponding host and ports in your Unity script.

    public var OSCHost : String = "127.0.0.1";
    public var SendToPort : int = 3200;
    public var ListenerPort : int = 12000;

    Import the UDPPacketIO and Osc components and feed in the host and ports. Add your specific label of your osc message and what method to call when receiving this event from Processing.

    var udp : UDPPacketIO = GetComponent("UDPPacketIO");
    udp.init(OSCHost, SendToPort, ListenerPort);
           
    handler = GetComponent("Osc");
    handler.init(udp);
    handler.SetAddressHandler("/flexiforce", AffectObject);

    In the receiving method you can print out the label and message values. In this case the sensor value from the Flexi Force. The cube will change width when getting a new value from Processing.

    public function AffectObject(oscMessage : OscMessage) : void
    {      
            Debug.Log("Event name: " + Osc.OscMessageToString(oscMessage));
            Debug.Log("Event data: " + oscMessage.Values[0]);
           
            var myCube = GameObject.Find("Cube");
            var boxWidth:int = 8 - ( oscMessage.Values[0]);
            myCube.transform.localScale = Vector3(boxWidth,5,5);
    }

    • Pablo 10:46 on June 5, 2012 Permalink

      great tutorial! do you have the entire source code available??

    • Juan 13:27 on June 16, 2012 Permalink

      Hi Ellen,
      As Pablo said: GREAT JOB!
      I’m trying to do the same, can you email me the sorce code?

      Thanks a lot

      Juan

    • Mikael 02:22 on June 22, 2012 Permalink

      How can I find the Osc.cs and UDPPacketIO.cs for the Unity?

      And yes I expect to have the source code also.

      Thank you,

      Mikael

    • Ellen 16:46 on June 25, 2012 Permalink

      The Osc.cs and UDPPacketIO.cs files are now available for download within the post. I will post the source code to the project shortly!

    • Ellen 18:00 on June 26, 2012 Permalink

      Source code and Processing example can be downloaded from here: https://github.com/ellensundh/Bocki_unity_processing/zipball/master

    • Ellen 10:13 on July 2, 2012 Permalink

      Test out the demo of Unity and Processing here: http://www.sundh.com/blog/2012/07/unity-processing-demo/

    • between0and1 19:58 on August 6, 2012 Permalink

      HI, I really like the tutorial and am excited to make it work full through. I’ve got all the processing / arduino bits working, but on moving into Unity I get a null reference exception on the line
      udp.init(-args-)

      I’m assuming it has to do with the way it is trying to access UDPPacketIO script, but I don’t yet have enough experience to know how to modify this to work properly.
      I’ve downloaded your processing demo and worked on it from there, but still can’t quite get it.

      Thanks for the demo! I’m excited to move forward wit this

    • Ellen 07:42 on September 6, 2012 Permalink

      @between0and1 Which platform are you on? If you run WIndows you need to change a line UDPPacketIO.cs. On Mac you import IO like this: “using System.IO;”. On Windows you need to add .Ports so you import ” System.IO.Ports;”

    • shanshan 23:01 on October 6, 2012 Permalink

      Hi Ellen
      Thank you so much for sharing resources and knowledge! this is amazing!

    • Matthias 10:46 on October 24, 2012 Permalink

      What is this error?

      Exception in thread “Animation Thread” java.lang.IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy

    • Oliver Jones 00:19 on January 27, 2013 Permalink

      Nice work Ellen! Is it possible to reverse this? So I can send variables from Unity, into Processing?

    • jim 20:52 on August 3, 2013 Permalink

      thanks for the tutorial! I run the processing and it works fine, it is printing the correct “flexiforceSensor” value . but when running Unity3D, the eventName and eventData are empty…..any idea what went wrong?

    • Ellen 02:11 on November 14, 2013 Permalink

      @Jim Please double check the ports you are listening in to. There are helpful applications for that to see what you input and output. When I find the link the the aswome app I used I will post it here!

    • Michael 04:29 on April 16, 2014 Permalink

      Ellen this is great but I’m stumped on the UDPPacketIO.cs issue. I’m on Windows, so
      even after changing adding .Ports to get ” System.IO.Ports;” I still get a NullReference error in Unity. I must have retried this and scoured the code for any issues for an hour. Everything looks fine but I can’t find a solution. I’ve checked all over the net and no answers. Any help is greatly appreciated.

  • Add app to Facebook page

    Ellen 16:46 on May 30, 2012 | 0 Permalink | Reply
    Tags: , Facebook app,

    If you want to add your app to a Facebook page, you will have to do the following.

    1. Prepare your app

    Make sure your have has valid URLs to point to from the little thumbnail in the Facebook page. Add an image that will be displayed. To fit the image into the area on the Facebook page it needs to be 111 x 74 px.

    add_app_facebook_page

    2. Add the app
    To add the app to the page you need to run the following link:

    https://www.facebook.com/dialog/pagetab?app_id=[APP_ID]&next=[PAGE_TAB_URL]

    The app id can be found https://developers.facebook.com/apps/
    facebook_app_your_app
    3. Add page tab dialog
    The page tab dialog will show all the pages you have admin permissions to.
    add_page_tab_facebook

  • Notes from Facebook Garage in Stockholm

    Ellen 13:40 on May 26, 2012 | 0 Permalink | Reply
    Tags: ,

    facebook_garage_stockholm

    Tagging users
    Application can tag people in updates. Permissions needed.
    The application can add a personal message to the update and also add it after the action was published.

    User generated photos
    It is now possible to post large photos in the news feed even without uploading it to a Facebook album.
    The difference is that the image is uploaded to your own server. The image URL is then passed to the Open Graph together with other optional values like:
    sources – Image URL
    large – If the image should be big (boolean)
    expires_in – How long the post should exist (seconds)
    tags – User ids in array to pass tagged users
    message – Your personal message
    place – Id of Facebook place
    your own actions – Verbs

    Post it to the graph with /me/[namespace_of_app]:your_action

    Download the example application here: https://bitbucket.org/brucehazan/ios-sample-og
    Example includes single sign in with Facebook iOS SDK.

    Add app from Timeline
    If friends are using a Facebook app and a post appears in your news feed and you don’t have the app, you can install the app in a click of a button. The button on the post says “Add app”.
    To enable it put a URL in Profile URL in application settings.

    Publish past on user timeline
    Post past things on the users timeline
    Button to fill out past timeline

    Map Stories
    Specify long and lat on a page can be added in meta tags. Your post can be associated with a location.

    New Feed Aggregations
    The more traffic a post gets it gets highlighted in the news feed.

    Action links on OG Stories
    Accept Diff – Authenticate the application to display application-functionality in the post:
    https://developers.facebook.com/docs/opengraph/actionlinks/

    Permissions
    offline_access – Depreciated
    Valid for 60 days is the only thing that can be used. As long as the user used your app you have 60 days to access the user.

    publish_stream includes publish_actions by default now.

    iOS Deep Linking
    It is possible to deep link into an iOS app from posts of the mobile Facebook app. If the user doesn’t have the app, the user will be directed to the App Store. After installing it the deep link is active.
    This is not new but it just launched for Android.
    To enabled it just check the box of iOS Native Deeplinking in your Application settings.

    Facebook requests
    Facebook requests from Facebook applications can be sent directly to the iOS device linking the user directly to your native iOS app with Facebook integration.

    App Center
    Facebook launched the App Center where all Facebook apps are shown in an App Store-like matter. The apps will show screenshots and rating from users.

  • Geek Girl Meetup in London

    Ellen 15:33 on April 29, 2012 | 0 Permalink | Reply
    Tags: , Geek Girl Meetup 2012, geekgirl,

    Spending the day at Geek Girl Meetup in London. Talked about The Sound of Football and my Arduino projects.

    In the Arduino session I presented my Depressed Shoe Shelf, the bend sensing belt Bad Posture, how to control electronics from the internet using Processing.

    google_campus_society46_680

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel