Sunday, 20 March 2016

Offtopic: Appium - OpenGL based app automation testing

AWS Device Farm and Appium

A few days ago i checked "unread" emails in my account. One of them was from Amazon AWS about their AWS Device Farm.
I checked it on one my mobile application, everything was good but only "Fuzzy testing" option was suitable for me.
I saw "Appium python" option and  decided to do some smart tests for my application.
The biggest problem is a testing UI for OpenGL application, because OpenGL application uses one GLView, UI in games rendered by OpenGL and Appium does't see app UI hierarchy and controls - only one root view.
As a first steps i used tap events to simulate pushing of OpenGL drawn buttons. 
This technique was good for devices where width and height is known and buttons always in the same places, but may fail in other cases (like other device orientation or width/height aspect is different). Also there is no feedback. Test does not have ways to determine is button was pressed or not.

Example to simulate button pushing:
window_size = self.driver.get_window_size()
# tap ok button  
positions = []positions.append((window_size['width']/2, window_size['height']*0.7))self.driver.tap(positions)

NOTE: AWS Device Farm and Appuim examples is available here
NOTE2: Good start point for Appium and AWS  is available here 

The feedback

Seems like i need some ways to organize feedback between app and Appium
I had a few ideas: 
  1. Hard and long - Instantiate simple http server on app side and organize network pipe between app and python test script. i.e. my python test script recieves data about controls hierarchy (of cause you opengl app should send UI layout and controls to this pipe)
  2. Fast but hacky variant - use something simpler - i choosed this one

 Feedback (Hacky)

I used special key codes to send event to my app to activate testing mode (i used key press event with almost impossible keycodes for android app)
def activeTestMode(self):
   # activate test mode   self.driver.press_keycode(152);
 In my app key code 152 is a signal to activate testing mode, when app receive this signal it just adds TextView on top left with "TestActivated" text


        if ((event.getKeyCode()==152) && (event.getAction() == KeyEvent.ACTION_DOWN))
        {
                appiumPipe = new TextView(this);
                appiumPipe.setId(123456);
                appiumPipe.setTag("AppiumPipe");
                appiumPipe.setText("TestActivated");
                appiumPipe.setBackgroundColor(Color.RED);
                appiumPipe.setSingleLine(true);

                FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.MATCH_PARENT,
                        FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP);
                params.setMargins(0, 0, 0, 0);

                appiumPipe.setLayoutParams(params);
                frame.addView(appiumPipe);
                return true;
      }
Next i used Apium api to find this control:
els = self.driver.find_elements_by_class_name('android.widget.TextView') # find_elements_by_xpath('//android.widget.TextView[*]')print els
# find textviewfor element in els:
   if element.text=="TestActivated":
      self.AppiumPipe = element
      break
 When control found the control text used as a pipe between app and my Appium python script.
Next - the other key code 153 used to send signal  to my app to update this control with my gui hierarchy in json format.

def updateTestInfo(self):
   self.driver.press_keycode(153);
   time.sleep(1)

   #print "-------------------"   #print self.AppiumPipe.text   #print "-------------------"
   #print AppiumPipe.name   self.data = json.loads(self.AppiumPipe.text)
   #pprint(self.data)
 
        else if ((event.getKeyCode()==153) && (event.getAction() == KeyEvent.ACTION_DOWN))
        {
                String res = NativeMethods.executeCommand("APPIUM:GetJSON", null);
                appiumPipe.setText(res);
                return true;
        }
String res = NativeMethods.executeCommand("APPIUM:GetJSON", null); is a code in my app returns gson with my internal opengl controls

After parsing json from control text i know elements and places of visible controls in my GUI

def controlCenterByPath(self,json,path):
   pCur = self.controlByPath(json,path);
   self.assertIsNotNone(pCur)
   return (pCur['x']+pCur['w']/2,pCur['y']+pCur['h']/2);

def tapControlByPath(self,json,path):
   pos = self.controlCenterByPath(json,path)
   # set up array of two coordinates   positions = []
   positions.append(pos)
   self.driver.tap(positions)

Simulation tap by Control name

self.updateTestInfo() # call this to update UI gson
self.tapControlByPath(self.data["TopLevel"][0],"DialogPanel.OKButton")

Validation


self.updateTestInfo()
time.sleep(1)
nodialog = self.controlByPath(self.data["TopLevel"][0],"DialogPanel")
self.assertIsNone(nodialog,"Reward must be closed")
 

Sunday, 21 February 2016

Monday, 15 February 2016

V3 progress

Just a photo



Sunday, 17 January 2016

Scara based 3D printer V3 details

Scara based 3D printer V3

Details:
  • 100mm arms, designed to cover almost all mk2b heated bed, 
  • 1/4 reduction ratio (gt2-16 teeth to 64 teeth)
  • 608 bearings used for center axis
  • 624 bearings for other.




Saturday, 9 January 2016

Scara 3D printer v2 - fail

Short review - fail.

Aluminum tubes (od-8, Id-6) too weak, on a 30 cm distance twists for a 0.5 degrees along 30cm. 5mm threaded rod have the same problem.
Because of issues above printing results does not match target quality.

But, v3 is started.

My v3 ideas:
1) classic arm scheme
2) platform is fixed, printing block movable
3) smaller footprint -50x150x20mm
4) ability to convert to robot arm manipulator

Sunday, 20 September 2015

Off topic

V2 still In progress, but not fast enough.

There are a few funny reasons:
• I have 2 apps on Google play and AppStore - totally 4 apps.
• Apple new iOS 9.0 broke all 2 my application - 2-3 hours per day sleeping during last 7 days.
• One of my Android app suddenly reached tops in one big region - I did 6 updates during last 2 weeks.
• Because of previous - database for game push, options and etc grows on 10% in 2 days (10-15K installs per day) - some time required to fix it.

In a few days I hope come back to V2 development.

P.S. My idea with inverted belts seems to be successful - I installed 1 belt and after 3 days belt tension the same.




Friday, 14 August 2015

Scara 3d printer cost calculations for V1

Approximate cost calculation for V1:
  • 51$ — 5 Nema17 (you need only 4, so you get 1 for spare parts)
  • 32$ — Ramps 1.4+5 Dvr8825+LCD (you need 4 drv8825, so you get 1 for spare parts)
  • 7$ — E3DV5 (china made) with 1m PTFE tube (0.5m for spare parts)
  • 2$ — extruder gear
  • 6$ — gt2 pulleys and gt2 belt
  • 5$ — 6mm smooth rods (2x20cm)
  • 4$ - 4 LM6UU linear bearings
  • ~10$ — ball bearings+bolts+screws+other stuff
  • 10$ - external power supply 8.5A 12V



Total: 127$ (with power supply, but without ABS filament — approx 200g)
NOTE: All prices from my aliexpress orders, free shipping to my country, no taxes (in my country taxes begins only from 200+$).

NOTE2: V2 seems to be in the same price level, but not cheaper.

Ways to save costs:
  • ~8-10$ - get rid of of LCD module 
  • ~5-7$ - Replace one Nema17(for gearbox) to small 2.5$(28BYJ-48 12V) stepper + printed high ratio spur gears.
Not a lot.

More global idea:
Replace 2x10$  Nema17 steppers to cheap DC MOTOR + Hall Sensor + L293N + gearbox. The main problem is a backlash free gearbox. I think gearbox should have approx 1:100 gear ratio.

Backlash free gearbox ideas.
  1. Looks like it is possible to combine 2 stage of 1:10 belt driven gears. Belt driven gear theoretically backlash free. 1:10 belt driven gear is a 16 teeth gt2 pulley and 160 teeth pulley (~101mm diameter), or use more stages with less teeth pulleys (seems like better due to the less belts length).
  2. Planetary gears - at least 2 stages required - i tried to print - seems like printed does not work well.
  3. Hypocycloid Gear - looks better but seems like it does not work due to printing precision, plus vibration may affect print results.
  4. Harmonic drive - not tested
  5. Classic gears - seems like not backlash free, there are a few ways to decrease backlash, but i not sure.
NOTE: It is just an idea

Wednesday, 5 August 2015

Printrun is forked

https://github.com/pavlog/Printrun

My first ideas:
  • Add mark to show center of ccordinated - DONE
  • Fix or rewrite ugly 3d viewport rotation (is Repetier like viewport rotation) - DONE