Augmented Reality Tutorial No. 5: Interaction using Arduino and Ultrasonic Sensor

posted in: Augmented Reality | 17

Little by little we’re moving to https://www.ourtechart.com/augmented-reality/augmented-reality-sensor-ultrasonic/

In this Augmented Reality tutorial the scale of the 3D cube is changed in Augmented Reality environment using data acquired from an ultrasonic sensor distance measurements. This is a basic interaction with virtual content.

Download # Arduino Code (*.ino file)

Download # Processing Code (*.pde file)

Download # Hiro Marker (*.pdf file)

(Processing software itself is available to download here)

Download # Newest nyar4psg 2.0.0 library for Augmented Reality (*.rar file)

NOTE: Extract library and put nyar4psg folder to Processing libraries location as you can see in example here: “C:\Users\EdgarasArt\Documents\Processing\libraries”. If there are no libraries folder in Processing folder (in My Documents) – create it!

Upload Arduino code directly to your Microcontroller from website
If you want to integrate Arduino IDE into your website (as above) sign up here: codebender

 

17 Responses

  1. Luis Abraham Paque Hernández

    Good night!

    You’ve done a great job. Well, I want to do this in a school project. If I have some doubts, could I ask you? Where could I send you my doubts?

    Thank you so much.

  2. sonia

    GLException: method “glclearDepthf” not available
    I am getting this exception. Please suggest how to resolve this problem. Thank you in advance.

    • admin

      Sorry, haven’t stumbled upon this error, but did you use Processing 2.2.1? If not, I would suggest to use this version, not the newest.

  3. Loc

    Hey man great work but I keep getting
    java.lang.AssetionError
    Used proccessing 3 and 2.2.1
    When I click “Run” I have a grey window and that error .

    • admin

      Full screenshot of the error would be great. Use 2.2.1 version.

      • Loc

        does this help man ?

        java.lang.RuntimeException: java.lang.AssertionError
        at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
        at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
        at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
        at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
        at javax.media.opengl.Threading.invoke(Threading.java:191)
        at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)
        at processing.opengl.PJOGL.requestDraw(PJOGL.java:688)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)
        at processing.core.PApplet.run(PApplet.java:2256)
        at java.lang.Thread.run(Unknown Source)
        Caused by: java.lang.AssertionError
        at jp.nyatla.nyar4psg.PImageRaster.wrapBuffer(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker$PImageSensor.update(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker.detectWithoutLoadPixels(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker.detect(Unknown Source)
        at AR5_CodeForProcessing.draw(AR5_CodeForProcessing.java:70)
        at processing.core.PApplet.handleDraw(PApplet.java:2386)
        at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:862)
        at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665)
        at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649)
        at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1289)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)
        at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1300)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

        • admin

          Actually, not much, have you tried previous tutorials with processing? Did everything worked smooth?

          • Loc

            no actually ok I will give it a go with random one and write you back.

          • Marcos

            cant that be because of missing jre or something like that ? i have the same problem here, i didnt touch the code except to put resolution 640×480 and it gives me the same error and it runs the window but no camera :/ any ideas ?

          • admin

            Did you put nyar4psg library in my docs/processing/libraries?

          • loc

            I made it work, in processing
            myPort = new Serial(this, Serial.list()[0], 9600); /
            I changed 1 with 0 and it worked

  4. Marcos

    yes, i have a runing AR app and it works just fine but then this example doesn’t work

  5. Marcos

    I’m using arduino uno, but i connected the same ports, 2,3 5v and ground and i can get reading on the arduino ide just fine so i think thats not the problem

    • admin

      How many ports do you have in the device manager? Which one from the top is arduino port (the first one, second one etc.)?

      • Marcos

        The arduino is not the problem because i can upload the program and get the readings from the sensor just ok …

        • loc

          myPort = new Serial(this, Serial.list()[0], 9600); /
          I changed 1 with 0 and it worked

Leave a Reply

Your email address will not be published. Required fields are marked *