- Demo Systems Architecture & Data Flow
- User Interface
- Geometric Calculation
- Wiring Between the Arm Robot and PHPoC
- Source Code
Arm robot has 6 motors illustrated as follows:
- Zone A: Control motor 2, 3, 4.
- Zone B: Control motor 1.
- Zone C: Control motor 5.
- Zone D: Control motor 6 (gripper)
When a user touches or sweeps finger (or clicks or moves mouse), we can get coordinate (x, y). The working flow is as follows:
In case of Zone A, to calculate angles of motor 2, 3, 4, we need to do some geometric calculation. You can refer to it at the end of this page.
Once receiving a set of angles from clients, six motors moves from the current angles to the new angles gradually. Six motor should move and reach new angles at the same time. Before going into detail how to control all motors, let’s look at how to control a single motor. Suppose that we want to move a motor from current angle ($angle) to new angle ($new_angle). Since speed of motor is high, we should slow down it. To do like that, two following steps are repeated until the motor reach new angle:
- Move motor with a small step.
- Pause a small time and then move another step.
The following diagram illustrates the above scheme in case new angle is greater than current angle:
$n is number of steps the motor has to take.
$step and $sleep_time is predefined values. Two later ones decide the speed and smoothness. The above is just only for one robot. To make robots start to move and reach destination at the same time, we can do as follows: Six motors take the same
of each motor is different from each other. So we have to choose
. In this project is maximum. The following code show how to calculate the
$n = 0;
After selecting the number of step, we calculate value of step for each motor as follow:
if($n > 0)
Generally, working flow of sever side is as follows:
Let’s make arm robot calculation into the following geometry problem:
- C is fixed
- a known point - D is the input from user
- a known point - CB, BA, AD (denoted by b, a, d respectively)
- lengths of each arm segments Find: angles C, B, A Solution:
- Make assumption that angle B and A are the same
- Add some additional points and segment
- We knew points C and D => we can calculate the length of DC (denoted by c)
- We can also calculate the δ
- Look at triangle ABE, we can infer that AE = BE and ∠E = π - 2α.
- The Law of Cosines in triangle CDE:
- Change (1) and (2) into (3), we have:
- Simplify the above:
- Since we know a, b, c and d, solve the above quadratic equation, we can calculate the value of α. - And β = π – α - Until now we found β, let’s find γ - The Law of Cosines in triangles BDC and BDA:
- Solve this set of equations, we can calculate γ.
- So, their required angles is: (δ+γ), β and β. These are angles of motors 2, 3 and 4 respectively.