Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

6 ‐ Python client API

Pierre-Yves Lapersonne edited this page Oct 28, 2024 · 1 revision

Python client API

The API

A Python client has been written in order to use the Tapster robot and send to its server the commands to process. The Python client provides several methods which match the robot's HTTP API.

Keywords Parameters Description of parameters Returned values Comment
checkRobotConnection True if status code is 200, false otherwise Check if the connection with the robot's server has been established
robot_getAngles The angles of the arms in JSON Gets the angles of the three arms, i.e. finaly the servomotors
robot_setAngles theta1 ; theta2 ; theta3 The 3 angles as float numbers The server's reponse in JSON Defines the angles of the three arms, i.e. finaly the servomotors
robot_getPosition The 3D position in JSON Gets the position in 3D landmark of the robot
robot_setPosition x ; y ; z The (x,y,z) point, with integer values The server's reponse in JSON Defines the position in 3D landmark of the finger of the robot
robot_tap x ; y The (x,y) point to tap on, with integer values The server's reponse in JSON Taps on the point at (x,y) in 2D landmark
robot_longTap x ; y ; duration The (x,y) point to tap on, with integer values, duration to wait The server's reponse in JSON Taps on the point at (x,y) in 2D landmark and wait during duration
robot_doubleTap x ; y ; duration The (x,y) point to tap on, with integer values, duration to wait The server's reponse in JSON Double taps on the point at (x,y) in 2D landmark and wait during duration between each tap
robot_tripleTap x ; y ; duration The (x,y) point to tap on, with integer values, duration to wait The server's reponse in JSON Triple taps on the point at (x,y) in 2D landmark and wait during duration between each tap
robot_reset The server's response Resets the position of the arms of the robot in their initial states
robot_getCalibration The calibration data in JSON Returns in JSON format the calibration data the robot's server uses
robot_setCalibration jsonData The calibration data in JSON format The server's reponses Defines the claibration data the robot's server must use
robot_status The status of the robot's server in JSON Gets the status of the robot's server
robot_dance The server's response in JSON Make the robot dance
robot_stopDance The server's response Make the robot stop dancing
robot_swipe startX ; startY ; endX ; endY The start end end points, with integer numbers The server's response Make the robot swipe from (startX,startY) to (endX,endY)
robot_ntap n ; x ; y The number of taps ; the point to tap on (x,y) The server's response Makes the robot tap n times on the point at (x,y)
robot_posForScreen x ; y The (x,y) point, with integer numbers The position Returns the position of the robot's finger for an (x,y) point
robot_angForPos x ; y ; z The (x,y,z) point with integer numbers The angles of the arms Returns the angles of the arms for a point at (x,y,z)
robot_stressSwipe n ; startX ; startY ; endX ; endY The number of swipes ; the start and end points The server's response Makes the robot make n quick swipes from (startX,startY) to (endX,endY) points
robot_stressTap n ; x ; y The number of taps ; the point to tap on at (x,y) The server's response Makes the robot make n quick tap on (x,y) point
robot_getContactZ The Z value Returns the Z-axis value of the contact point, i.e. where the finger of the robot can touch the screen of the device under it
robot_nswipe n ; startX ; startY ; endX ; endY The number of swipes ; the start and end points The server's response Makes the robot swipe n times from (startX,startY) to (endX,endY)
robot_drawSquare n ; length Draw each n point ; the length of the square The server's response Draws a square
robot_drawStar The server's response Draws a star
robot_drawTriangle x1 ; y1 ; x2 ; y2 ; x3 ; y3 The 3 points of the triangle The server's response Draws a triangle with the 3 points (coordinates based on 2D device landmark)
robot_drawCircle x ; y ; r The point (x,y) as center ; the radius of the circle The server's response Draws a circle centered on (x,y) with a radius r
robot_drawCross x1 ; y1 ; x2 ; y2 ; x3 ; y3 ; x4 ; y4 The 4 points of the cross The server's response Draws a cross with 2 strokes: (x1,y1) -> (x4,y4) and (x2,y2) -> (x3,y3)
robot_drawSpiral x ; y ; n ; r The point where to start ; the number of rings ; the radius The server's response Draws a spiral starting from (x,y) with n rings and a global r radius
robot_drawRandom n ; minWidth ; minHeight ; maxWidth ; maxHeight The number of points ; the area to draw The server's response Draws a random pattern with (n-1) strokes in a defined area

Use the client

Three types of execution are provided for this client: the interactive mode where you write within the console the commands to process, the light mode where you trigger only one command per program execution, and the file mode where you can provide to the program a list of commands to process.

To start in interactive mode:

  python client.py

To start in light mode:

  python client.py --light the-command-to-process

To start in file mode:

  python client.py --file path-to-the-command-file

If you are look for the formalism of the commands, run:

  python client.py --help