The Robotic Arm Controller Feature in PSLab Android Application.
Recently while working on PSLab Android Project, a new feature was implemented to add a controller for a Robotic Arm in the Android Application. In this blog, I will explain what this new feature is, how it has been implemented and what are some of the functionalities of it. What is Robotic Arm? Robotic Arm, as the name suggests is a small arm-like structure, which moves with the help of 4 servo motors connected to it. The image of the robotic arm is as under, (Figure 1 : Robotic Arm) What is the Robotic Arm Controller Feature in Android App? As mentioned earlier, the robotic arm uses 4 servos for the movements. The aim of the controller feature in the Android app is to allow users to adjust the rotation of each servo with a very intuitive UI, so they can move the robotic arm as they wish. Further, in this blog, I will discuss UI, implementation and some cool features of the robotic Arm Controller. User Interface (figure 2: UI of the robotic arm controller) In the screenshot above, there are 4 circular controllers for each respective servo. The user can use the knob or enter the values using the keyboard by tapping on the value at the center of the knobs. Each value indicates the value in degrees the user wishes to move that servo. Timeline Below the 4 servo controllers is a black timeline. There are 60 boxes in each of the 4 timelines. These 60 boxes indicates the seconds. So basically if the user wants the robotic arm to perform some set of actions sequentially, using these timelines, users can set the rotation for each servo at each second, then user can use the play button on the red control panel to play this timeline and the app will send the degree value at each second to the respective servo. A filled timeline would look something like below, (Figure 3: Timeline) As can be seen, there are different values for each servo at each second, so when the user starts the timeline, values at each second will be sent to the respective servos. servo4() function of the ScienceLab class is called to set values for all for servos at each second. How to add the values to the timeline? There is a small handle on the top right corner of each servo controller, user can long-press the handle and drag and drop the values to desired seconds for respective servos. This functionality can be found in this video between 0:33 to 0:43 This feature uses Android’s drag and drops listener. The code for this drag and drop function is as under, private View.OnDragListener servo1DragListener = new View.OnDragListener() { @Override public boolean onDrag(View v, DragEvent event) { if (event.getAction() == DragEvent.ACTION_DRAG_ENTERED) { View view = (View) event.getLocalState(); TextView text = view.findViewById(R.id.degreeText); if (view.getId() == R.id.servo_1) { ((TextView) v.findViewById(R.id.timeline_box_degree_text)).setText(text.getText()); } } return true; } }; Such drag listeners are created for each servo controller. Save Timeline Feature Suppose…
