BUG Community

Welcome! Log In

Forums BUGmodules BugMotion Configuration

Subscribe to BugMotion Configuration  8 posts, 2 voices

Log in to reply to this topic
Dec 23, 2010 6:43am
User_img_not_found_05_med Edrae 25 posts



have got a problem with the BugMotion : everytime I make a call
it takes about one second.

API documentation says that default delay is 5ms. I tried to change
configuration but it changes nothing :

accControl = (IAccelerometerControl)serviceProv.getService(IAccelerometerControl.class); accConfig = accControl.getConfiguration(); accConfig.setSensitivity((byte)0); accConfig.setReadQueueThreshold(1); accConfig.setReadQueueSize(20); accConfig.setDelayMode((byte)1); accConfig.setDelayResolution((byte)1); accConfig.setDelay((short)1); accControl.setConfiguration(accConfig) ;


may be a conflict between BugLcd and BugMotion services ? How to
know where I read acceleration ?
  And of course, how to realy get a 5ms delay ?



Dec 24, 2010 2:01am
Medium Bug Labs team kgilmer 215 posts

Hi Edrae,

  What BUG version do you have, and what software release are you using?  Yes you may be right about interference with LCD module; both modules have accelerometers and offer the accelerometer services in the OSGi service registry.  You can confirm which module a service is coming from by checking the “Provider” property that is returned in the dictionary from BundleContext.getServiceReference() / ServiceReference.getProperty().  Also, you can construct an OSGi filter that will only pick up the service from a specific provider, such as the Motion module.

  I would suspect you’re getting the correct IAccelerometerControl service from the Motion module, but your configuration changes are not having an effect because you are reading acceleration from the LCD module.





Dec 27, 2010 7:45am
User_img_not_found_05_med Edrae 25 posts

Hi kgilmer,

I have the first BugBas (wifi edition) in 1.4.3.

I didn’t manage to know from which module the serice is coming (always get a null value). But I checked every class and import that ar being used and they all come from the Motion module.

I already have a service filter :

public void initServices() { getServices().add("com.buglabs.bug.accelerometer.pub.IAccelerometerControl"); getServices().add("com.buglabs.bug.accelerometer.pub.IAccelerometerRawFeed"); getServices().add("com.buglabs.bug.accelerometer.pub.IAccelerometerSampleFeed"); getServices().add("com.buglabs.bug.accelerometer.pub.IAccelerometerSampleProvider"); getServices().add("com.buglabs.bug.module.lcd.pub.ILCDModuleControl"); getServices().add("com.buglabs.bug.module.lcd.pub.IModuleDisplay"); getServices().add("com.buglabs.bug.module.motion.pub.IMotionSubject"); getServices().add("com.buglabs.device.IButtonEventProvider"); }

I tried to switch from IAccelerometerSampleFeed.getSampleImputStream() to the IAccelerometerSampleProvider and I get the same result.

I’m pretty sure that the problem come from reading a sample because when
I comment this step, my graphical interface show huge amount of frame
per second with everything else remaining. I put a timer on sample
reading and it’s also proving this.

I checked the build version of th module and they are the latest ones :

  • com.buglabs.bug.module.motion 1.0+svnr10658-r10

  • com.buglabs.bug.jni.motion 1.0+svnr10022-r5

If you wish the source code, I can send it, even if it is a draft.

Thanks for spending time on this,




Dec 28, 2010 12:50am
Medium Bug Labs team kgilmer 215 posts


Hi Edrae,

  Sure, if you send me the source to your application I can show you how the service filter is constructed such that you only get the acceleometer service from the Motion module.  Email me at ken at buglabs.net.



Dec 28, 2010 6:48pm
Medium Bug Labs team kgilmer 215 posts

Hi Edrae,

  I got your project source code and took a look.  Yes, so essentially the BUG app wizard generates some boilerplate code that needs to be modified.  Line 31 in Activator.java is where the service filter is created.  This filter string defines which services your application gets bound to at runtime.  You need to make a more specific filter that will only bind to accelerometer services provided by the motion module.  You can do this one of two ways:

1) Create a new app, use the wizard to generate the filter.  If you use the bug app wizard, and on the second page connect to your BUG with motion and LCD modules attached.  In the Target BUG group, select your BUG.  Below a list of services should be listed.  Go to the accelerometer services, check them, then double-click them to edit the service properties.  You want to set the Provider to be com.buglabs.bug.module.motion.MotionModlet.  Make this change for each of the services you want to come only from the motion device.

2) Update your source code.  You can manually specify the information needed to create the proper filter.  Here is some example code that will construct a filter string that binds your services only to the motion module:


SortedMap sm = new TreeMap();<br />Map vm = new HashMap(); <br /> vm.put("Provider", "com.buglabs.bug.module.motion.MotionModlet"); sm.put("com.buglabs.bug.accelerometer.pub.IAccelerometerControl", vm); sm.put("com.buglabs.bug.accelerometer.pub.IAccelerometerRawFeed", vm); sm.put("com.buglabs.bug.accelerometer.pub.IAccelerometerSampleFeed", vm); sm.put("com.buglabs.bug.accelerometer.pub.IAccelerometerSampleProvider", vm); sm.put("com.buglabs.bug.module.motion.pub.IMotionSubject", vm); sm.put("com.buglabs.bug.module.lcd.pub.ILCDModuleControl", new HashMap()); sm.put("com.buglabs.bug.module.lcd.pub.IModuleDisplay", new HashMap()); sm.put("com.buglabs.device.IButtonEventProvider", new HashMap()); <br />String fs = ServiceFilterGenerator.generateServiceFilter(sm); <br /> <br />System.out.println(fs);



Dec 30, 2010 5:33am
User_img_not_found_05_med Edrae 25 posts

It works !

I don’t try the wizard but updating ma code just work fine. Now graphics are update about 4 times per seconds. It’s not smooth but realy better. And it is not a motion sampling issue, just my code or cpu limitation.

I lost some time trying the filter with a virtual bug but it doesn’t work. I think it cannot manage provider. I installed Dragonfly 2.0 to test but it didn’t satisfy me, so back to 1.6. Is Dragonfly 2.0 works with BugBase 1 ?

Thanks for solution.



Jan 3, 2011 12:53am
Medium Bug Labs team kgilmer 215 posts


Hi Edrae,

  Awesome, glad to hear you got it working!  Regarding the SDK, no the 2.0 version is intended only for the BUG2.0 hardware.

Happy new year,


Jan 8, 2011 6:32am
User_img_not_found_05_med Edrae 25 posts

Happy new year !

I got it smooth with sample reading delay below 5 ms ! I got it by asking default configuration and not the custom one.
I didn’t take the time to really understand why but it was again a configuration issue. Not my code and not cpu limitation (yeah !).

Now I can focus on funny code.


Log in to reply to this topic
Forums BUGmodules BugMotion Configuration

Powered by Community Engine