home

=**Project Summary**=

In this section we are going to summarise what we have done for our project and provide all the code, images and videos that we have made. As we have explained in the previous pages (week 1-4), we have designed a robotic arm that consists of four servo motors connected together with 3 pin cables and different shaped frames. Those servos are internally built with pressure and heat sensors to get feedbacks on their state, a potentiometer to know their position, and a little Arduino which can receive commands and execute them. The main purpose of the robotic arm is to show that it can be manipulated as if it was a real human arm. It mimic human constraints as much as possible.

The robotic arm has been set to have constraints so that it does not execute invalid moves which a human can not do. For the project we have designed a simple housing that allows the arm to hang just like a relaxed human arm and we have dressed it up, so that it looks more fun and realistic. We use a C++ graphical interface using the library Qt, and URBIscript which uses a specific Urbi language to interact with the servo motors. We use the library bioloid with Urbi to make the interaction easier.

During the coding, we have experienced quite a few problems, but all were solved on time. The first problem was to create an interface with Qt which can interact with the Urbi server. However with a bit of research, we have managed to find a simple solution. As Urbi is a server, we have set it up to listen on a certain port. Then with the C++ program, we created a function to send it messages using a socket connection. The initial idea was to use the serial port but it appeared not to be a good idea because Urbi was already using it.

Another problem that we encountered was to stop the record script. The script being executed in the foreground and in an infinite loop, we were not able to stop it. However again with a bit of research we found some functions which allow us to execute it in background and so to execute commands to stop it.

The last problem we had was to take in account the constraints we fixed to respect a human arm. In fact, the recorder did not care about them and recorded any given movement. We finally found the solution by controlling whether a movement should be played while reading the recorded positions. Only the position inside the boundaries are sent to the servo motors. The others are ignored.

To interact with the robot, we use two analog inputs, namely a mouse and a keyboard. Obviously, we can use any controller connected to the computer, like a joystick or a trackball. The mouse allows the user to interact with the graphical interface and press buttons that we have designed to send specific messages to Urbi which react to them by either playing already recorded scripts, playing a demo, reset the servos of the robotic arm or record your own script and then play it straight away. The keyboard was used to manually control the robotic arm. It allows the user to press different keys to trigger each servo individually and try out different kinds of movements without any recorded script.

There are two different outputs in this project: the motors and the screen. The motors act according to an order sent by Urbi. They make the arm move and allow a physical output of the commands executed. On another side, the user might want to control the internal state of the program. That is why we also display some messages on the server terminal so that an output of what is happening is accessible. A simple user is not supposed to interact with the robot outside of the graphical interface. But an experimented user or the owner of the robot might need it.

Below are the pictures that we have taken for the project along with the presentation video and all the fully explained and commented code that we have written.

media type="youtube" key="glY9EVgUJrQ" height="315" width="560" align="center"







Following is the code used to create the graphical interface. You can also download it from the links below: [|Urbi files] [|C++ files]

**main.cpp** #include  #include "mainwindow.h"

int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show;

return a.exec; }

Here is the header file for the mainWindow.cpp that is used to define the objects and call the libraries and other files needed, such as the socketConnecton.hpp that is required in order to establish a connection. **mainWindow.h** #ifndef MAINWINDOW_H #define MAINWINDOW_H

#include <QMainWindow> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">#include <QKeyEvent> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">#include "socketConnection.hpp"

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">namespace Ui { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">class MainWindow; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">class MainWindow : public QMainWindow <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Q_OBJECT

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">public: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">explicit MainWindow(QWidget *parent = 0); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">virtual void keyPressEvent ( QKeyEvent * event ); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">~MainWindow;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">private slots: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_reset_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_demo_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_record_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_play_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_play1_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_play2_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">void on_play3_clicked;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">private: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Ui::MainWindow *ui; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">bool stopRecording; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">#endif //MAINWINDOW_H//

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">This is where the buttons of the keyboard and the user interfaces buttons are defined and called. When a button is pressed, a connection is established that sends a signal through the port that contains a specific functions that we call inside the urbiscript code. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//**mainWindow.cpp**// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include "mainwindow.h"// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include "ui_mainwindow.h"//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//MainWindow::MainWindow(QWidget *parent) :// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//QMainWindow(parent),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//ui(new Ui::MainWindow)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//ui->setupUi(this);// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//stopRecording = false;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//MainWindow::~MainWindow// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//delete ui;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::keyPressEvent(QKeyEvent *event)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//switch(event->key){// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case (Qt::Key_S):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s1_move_down");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_Z):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s1_move_up");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case (Qt::Key_Q):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s2_move_down");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_D):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s2_move_up");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case (Qt::Key_I):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s3_move_up");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_K):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("s3_move_down");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case (Qt::Key_J):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("e_move_down");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_L):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("e_move_up");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_Escape):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//close;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//case(Qt::Key_W):// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("stopRecording");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//break;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_reset_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("reset");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_demo_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("demo");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_play_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("play");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_record_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("record");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_play1_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("play1");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_play2_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("play2");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//void MainWindow::on_play3_clicked// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection("play3");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}//

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">This is the header file which uses the libraries required for the socketConnection.cpp file which is used for establishing a connection. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//**socketConnection.hpp**// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#ifndef SOCKETCONNECTION_HPP// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#define SOCKETCONNECTION_HPP//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <sys/types.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <sys/socket.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <netinet/in.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <arpa/inet.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <unistd.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <stdio.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include <stdlib.h>// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#include //

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#define INVALID_SOCKET -1// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#define SOCKET_ERROR -1// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#define closesocket(s) close(s)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#define PORT 5353//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//typedef int SOCKET;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//typedef struct sockaddr_in SOCKADDR_IN;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//typedef struct sockaddr SOCKADDR;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//using namespace std;//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//class socketConnection// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//private:// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//SOCKET sock;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//SOCKADDR_IN sin;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//int erreur;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//bool connected;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//public:// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//socketConnection(string message);// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//};//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//#endif// SOCKETCONNECTION_HPP

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">the socketConnection is used to create a link or a network between urbi script and the serial communication so that commands can be sent through the user interface <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**socketConnection.cpp** <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">#include "socketConnection.hpp"

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socketConnection::socketConnection(string message){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">int erreur = 0;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">SOCKET sock; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">SOCKADDR_IN sin;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(!erreur) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/* socket creation */ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sock = socket(AF_INET, SOCK_STREAM, 0);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/* connection config */ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sin.sin_addr.s_addr = inet_addr("127.0.0.1"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sin.sin_family = AF_INET; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sin.sin_port = htons(PORT);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/* if the program can connect */ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(connect(sock, (SOCKADDR*)&sin, sizeof(sin)) != SOCKET_ERROR){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">printf("Connected on server %s on port %d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">cout << message.length; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">send(sock, message.c_str, message.length,0); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">printf("Connection refused\n");

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/*close the socket*/ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">closesocket(sock); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">The code below represents the user interface code which defines the names and size of the buttons and their location. Most of the code is automatically generated since it uses drag and drop function, however linking the code does require some coding which is used later <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**mainWindow.ui** <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><?xml version="1.0" encoding="UTF-8"?> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><ui version="4.0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> MainWindow <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QMainWindow" name="MainWindow"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><x>0</x> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><y>0</y> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 544 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 418 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="windowTitle"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> MainWindow <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QWidget" name="centralWidget"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QWidget" name="gridLayoutWidget"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><x>9</x> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><y>9</y> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 531 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 353 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><layout class="QGridLayout" name="gridLayout"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><item row="1" column="3" rowspan="13"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="Line" name="line"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Vertical <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QSlider" name="shoulder3"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> false <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QSlider" name="elbow"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> false <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="horizontalSpacer"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeType"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> QSizePolicy::Fixed <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QLabel" name="label_2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Shoulder 2 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QLabel" name="label_4"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Elbow <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QSlider" name="shoulder2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> false <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QLabel" name="label_3"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Shoulder 3 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QLabel" name="label"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Shoulder 1 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="horizontalSpacer_3"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeType"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> QSizePolicy::Minimum <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="horizontalSpacer_2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="play1"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Play script 1 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><item row="11" column="4" colspan="2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="Line" name="line_2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><item row="6" column="4" colspan="2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="Line" name="line_3"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><item row="3" column="4" colspan="2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="Line" name="line_4"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QSlider" name="shoulder1"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> false <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> -200 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 160 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="singleStep"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 10 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> -147 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="horizontalSpacer_4"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Horizontal <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeType"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> QSizePolicy::Fixed <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="play2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Play script 2 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="play3"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Play script 3 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="record"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Record <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="play"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Play <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="verticalSpacer"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Vertical <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><spacer name="verticalSpacer_2"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Qt::Vertical <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><property name="sizeHint" stdset="0"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 20 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 40 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="demo"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Demo <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QPushButton" name="reset"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><cursorShape>PointingHandCursor</cursorShape> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> Reset <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QMenuBar" name="menuBar"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><x>0</x> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><y>0</y> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 544 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> 25 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QToolBar" name="mainToolBar"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><attribute name="toolBarArea"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> TopToolBarArea <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><attribute name="toolBarBreak"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> false <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><widget class="QStatusBar" name="statusBar"/> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"><layoutdefault spacing="6" margin="11"/> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"> <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;"></ui>

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**And this is the urbi code.**
<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//Loads the main class roboArm with a variable arm which is used to call the roboArm.u class// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**start.u** <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">load("roboArm.u"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var arm = roboArm.new;

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">This is the main class which controls the robotic arm. We first load the dynamixel.u library which we use for our servo control // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**roboArm.u** <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">load("dynamixel.u"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var Global.d = Dynamixel.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var range = 0.1;

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//Creates a variable server which// //is used to connect to the C++ file to be able to receive data through an external application// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var server = Server.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">at (server.connection?(var socket)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">at (socket.received?(var data)){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">switch (data) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #008000; font-family: 'Courier New',Courier,monospace; font-size: 100%;">//Each case commands command corresponds to a message sent from the external C++ application which in return executes a function from the roboArm.u file// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "reset": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Reset"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "demo": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Demo"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.sM; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "record": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.stopRecording = false; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Recording"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.record; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "stopRecording": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.stopRecording = true; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.record; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Record stopped"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "play": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Playing"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.player; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "play1": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Playing"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.player1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "play2": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Playing"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.player2; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "play3": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Playing"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.player3; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s1_move_up":

<span style="color: #008000; font-family: 'Courier New',Courier,monospace; font-size: 100%;">//The IF statements represent the boundaries of the roboric arm while manually moving it with a keyboard. It states that if any of the servos go out of the predefined position, then stop moving them.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulder1.position+range <= arm.shoulder1.upperPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move up"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulder1.targetPos = arm.shoulder1.position+range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s1_move_down": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulder1.position-range >= arm.shoulder1.lowerPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move Down"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulder1.targetPos = arm.shoulder1.position-range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s2_move_up": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulder2.position+range <= arm.shoulder2.iniPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move up"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulder2.targetPos = arm.shoulder2.position+range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s2_move_down": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulder2.position-range >= arm.shoulder2.lowerPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move Down"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulder2.targetPos = arm.shoulder2.position-range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s3_move_up": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulderRot.position+range <= arm.shoulderRot.maxRight){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move up"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulderRot.targetPos = arm.shoulderRot.position+range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "s3_move_down": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.shoulderRot.position-range >= arm.shoulderRot.maxLeft){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move Down"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.shoulderRot.targetPos = arm.shoulderRot.position-range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "e_move_up": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.elbow.position+range <= arm.elbow.iniPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move up"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.elbow.targetPos = arm.elbow.position+range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case "e_move_down": <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(arm.elbow.position-range >= arm.elbow.lowerPos){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo ("Move Down"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">arm.elbow.targetPos = arm.elbow.position-range; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">server.listen("localhost", "5353");

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">class roboArm <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace; font-size: 100%; line-height: 17px;">The init function represents where all variables and positions are defined. It also presents where each servo is called. // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function init <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var speed = 2;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.stopRecording = false;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder1 = Dynamixel.Device.new(d,17,Dynamixel.DeviceDesc.AX12); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder2 = Dynamixel.Device.new(d,9,Dynamixel.DeviceDesc.AX12); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulderRot = Dynamixel.Device.new(d,2,Dynamixel.DeviceDesc.AX12); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.elbow = Dynamixel.Device.new(d,6,Dynamixel.DeviceDesc.AX12);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetSpeed = speed; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetSpeed = speed; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetSpeed = speed; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetSpeed = speed;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder1.iniPos = -1.47; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder1.upperPos = 1.6; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder1.lowerPos = -2;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder2.iniPos = 1.27; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulder2.lowerPos = -1.21;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulderRot.iniPos = -0.03; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulderRot.maxLeft = -1.45; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.shoulderRot.maxRight = 0.57;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.elbow.iniPos = 1.58; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.elbow.lowerPos = -0.57; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">The reset functions resets each servo to it's initial position when executed // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function reset <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var delay = 1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = this.shoulder2.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = this.shoulderRot.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = this.elbow.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">unlock; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">The unlock functions unlocks each servo because once a speed is defined, or a servo has been moved, the servo gets locked and cannot be manually moved. We require manual movements of the servos whenever we want to record a script // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function unlock{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.load = 0; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.load = 0; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.load = 0; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.load = 0; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">the sM function represents the demo that we have played in class. This function represents all the movements of each servo with its minimum and maximum positions. It is used to test if each servo is functioning correctly // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function sM <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var delay = 0.5; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var range = 0.05; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulder1.position<this.shoulder1.upperPos-range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.upperPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulder1.position>this.shoulder1.lowerPos+range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.lowerPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulder1.position<this.shoulder1.iniPos-range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulder2.position>this.shoulder2.lowerPos+range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = this.shoulder2.lowerPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulder2.position<this.shoulder2.iniPos-range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = this.shoulder2.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulderRot.position>this.shoulderRot.maxLeft+range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = this.shoulderRot.maxLeft; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulderRot.position<this.shoulderRot.maxRight-range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = this.shoulderRot.maxRight; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.shoulderRot.position>this.shoulderRot.iniPos+range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = this.shoulderRot.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.elbow.position>this.elbow.lowerPos+range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = this.elbow.lowerPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">while(this.elbow.position<this.elbow.iniPos-range) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = this.elbow.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//simpleMovement2 and 3 are the same as the sM function, but shorter. They only execute a particular servo// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function simpleMovement2 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var delay = 0.1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.upperPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = this.shoulder2.iniPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function simpleMovement3 <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var delay = 0.1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = this.shoulder1.upperPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = this.shoulderRot.maxLeft; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(delay); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = this.elbow.lowerPos; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//The player function is used to play the recorded script. This is the main player function which is used to play the newest recorded script// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function player{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(1s);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var is = InputStream.new(File.new("output.txt"));

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var line;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading:every(0.01) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">line = is.getLine.acceptVoid; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (line.isVoid) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading.stop; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo(line); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var ns = line.split(",");

<span style="color: #008000; font-family: 'Courier New',Courier,monospace; font-size: 12px; line-height: 17px;">//Here we have set boundaries so that the function plays only the variables which are within our defined limits for the servos.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[0].asFloat<=this.shoulder1.upperPos && ns[0].asFloat>=this.shoulder1.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = ns[0].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[1].asFloat<=this.shoulder2.iniPos && ns[1].asFloat>=this.shoulder2.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = ns[1].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[2].asFloat<=this.shoulderRot.maxRight && ns[2].asFloat>=this.shoulderRot.maxLeft) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = ns[2].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[3].asFloat<=this.elbow.iniPos && ns[3].asFloat>=this.elbow.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = ns[3].asFloat; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

//<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">player1, 2 and 3 are the same functions as the initial player, but here we have stored 3 recorded scripts which cannot be modified, unless the script has been overwritten // <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function player1{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(1s);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var is = InputStream.new(File.new("output1.txt"));

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var line;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading:every(0.01) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">line = is.getLine.acceptVoid; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (line.isVoid) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading.stop; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo(line); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var ns = line.split(","); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[0].asFloat<=this.shoulder1.upperPos && ns[0].asFloat>=this.shoulder1.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = ns[0].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[1].asFloat<=this.shoulder2.iniPos && ns[1].asFloat>=this.shoulder2.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = ns[1].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[2].asFloat<=this.shoulderRot.maxRight && ns[2].asFloat>=this.shoulderRot.maxLeft) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = ns[2].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[3].asFloat<=this.elbow.iniPos && ns[3].asFloat>=this.elbow.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = ns[3].asFloat; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function player2{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(1s);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var is = InputStream.new(File.new("output2.txt"));

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var line;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading:every(0.01) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">line = is.getLine.acceptVoid; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (line.isVoid) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading.stop; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo(line); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var ns = line.split(","); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[0].asFloat<=this.shoulder1.upperPos && ns[0].asFloat>=this.shoulder1.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = ns[0].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[1].asFloat<=this.shoulder2.iniPos && ns[1].asFloat>=this.shoulder2.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = ns[1].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[2].asFloat<=this.shoulderRot.maxRight && ns[2].asFloat>=this.shoulderRot.maxLeft) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = ns[2].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[3].asFloat<=this.elbow.iniPos && ns[3].asFloat>=this.elbow.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = ns[3].asFloat; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function player3{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sleep(1s);

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var is = InputStream.new(File.new("output3.txt"));

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var line;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading:every(0.01) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">line = is.getLine.acceptVoid; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (line.isVoid) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reading.stop; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">echo(line); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var ns = line.split(","); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[0].asFloat<=this.shoulder1.upperPos && ns[0].asFloat>=this.shoulder1.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder1.targetPos = ns[0].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[1].asFloat<=this.shoulder2.iniPos && ns[1].asFloat>=this.shoulder2.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulder2.targetPos = ns[1].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[2].asFloat<=this.shoulderRot.maxRight && ns[2].asFloat>=this.shoulderRot.maxLeft) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.shoulderRot.targetPos = ns[2].asFloat;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(ns[3].asFloat<=this.elbow.iniPos && ns[3].asFloat>=this.elbow.lowerPos) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">this.elbow.targetPos = ns[3].asFloat; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//This is the main record function. Whenever the function is executed and the servos manually moved by the user, it would record a new position every 0.01 seconds and store it only a .txt file which can later be played// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function record{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if(!stopRecording){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">reset; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var o1 = OutputStream.new(File.create("output.txt")); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">detach({ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">writing:every(0.01){ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">o1 << this.shoulder1.position << "," << this.shoulder2.position << "," << this.shoulderRot.position << "," << this.elbow.position << "\n"; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">writing.stop; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #008000; font-family: 'Courier New',Courier,monospace;">//The dynamixel.u is the library we have used. It has to be used as a default and it has been used for some variables such as declaring the servos and their ID's. We have added the code for the library because we have used it in our main urbiscript program and it is called at the very first line of our main script.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">**dynamixel.u** <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* This software is provided "as is" without warranty of any kind, <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* See the LICENSE file for more information. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">*/
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Copyright (C) 2010, Gostai S.A.S.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">either expressed or implied, including but not limited to the
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">implied warranties of fitness for a particular purpose.

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (!hasSlot("DynamixelPacket")) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">loadModule("/home/thibbo/urbi-for-bioloid/bioloid.so"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/** Link to a bioloid CM-5 brick patched with gostai firmware. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* usage: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">*/
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">This code will also work with a direct connection to the dynamixel bus
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(using for instance the usb2dynamixel), if you disable all 'multiRead'
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">optimization.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var Global.d = Dynamixel.new;
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var m = Dynamixel.Device.new(d, 3, Dynamixel.DeviceDesc.AX12);
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">m.val = 100;
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var s = Dynamixel.Device.new(d, 100, Dynamixel.DeviceDesc.AXS1);
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">s.buzzerIndex = 10;

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">class Global.Dynamixel <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function init(host="/dev/ttyUSB0", speed=57600, cm5 = false) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.io = IoService.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.socket = io.makeSocket; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.data = ""; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.m = Mutex.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/// Are we connected throug a cm5 or directly on the bus.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.cm5 = cm5;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/ Mutex used to prevent multiple parallel operations. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.sendMutex = Mutex.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.reply = Event.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.lastDataSize = 1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.parseTime = 1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.writeTime = 1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.debug = Tag.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/// For each write offset, pairs of (deviceId, value)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.writeCache = * 256;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/ Time of last read for given offset. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.readTime = [time] * 256; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/// Cache of read values.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.readValues = 256.seq.map(function(x) {[0] * 256});// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/ List of active device IDs <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var this.addresses = [];

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socket.connectSerial(host, speed, false); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">at(socket.error?) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">wall("socket error"); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//Write the list of (address, val) in addrVal to index 'idx'.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//function multiWrite(addrVal, idx, size)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var addresses = addrVal.map(function(x) { x[0]})|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var vals = addrVal.map(function(x) { x[1]});// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">No reply to multiwrite packets <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sendMutex: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socket.syncWrite(DynamixelPacket.multiWrite(addresses, idx,size, vals)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//Get one packet// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//function syncGetPacket(dataSize=1)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var res|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var p|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var clen|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//do(socket)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//p = ""|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//while| (p != "\xFF")// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//p = read(1)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//p += read(3)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//if (p[1] != "\xff")// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//wall("fail: " + p.asPrintable)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//return nil|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//clen = p[3].toAscii|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//p += read(clen)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//res = DynamixelPacket.parse(p, dataSize)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//res// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//};//

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Write to one motor. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function write(address, idx, size, val) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sendMutex: { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socket.syncWrite(DynamixelPacket.write(address, idx, size, val))| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (idx != 254) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">syncGetPacket <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function read(address, idx, size) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">sendMutex: { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (address.isA(List)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socket.syncWrite(DynamixelPacket.multiRead(address, idx, size)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">socket.syncWrite(DynamixelPacket.read(address, idx, size))| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var v = syncGetPacket(size)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var res = { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (v.isNil) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">nil <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (v.size>2 && (address.isA(List) || v[0] == address)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (!address.isA(List)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v[2] <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.removeFront| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.removeFront| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">nil <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">res <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/// Return the list of existing devices, with their type// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//function scan(maxid=253, verbose=true, fast=true)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var res = [];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//debug.block;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var vals = [];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//if (verbose)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//wall("Scanning for devices, this can take up to 30 seconds.");// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//if (fast && cm5)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var alls = maxid.seq;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Big requests can take time <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var chunk = 16; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for(var i: maxid/chunk) if (i*chunk <=maxid) { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">vals += read(alls.range(i*chunk, (i*chunk+chunk).min(maxid)), 0, 2)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">wall("done")| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var i:maxid) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var v = { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (!fast) read(i, 0, 2) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">vals[i] <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">switch(v) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case 13: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">res << (i, DeviceDesc.AXS1)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (verbose) wall("Found AXS1 at address " + i) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case 12: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">res << (i, DeviceDesc.AX12)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (verbose) wall("Found AX12 at address " + i) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case 65535: <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">case (var x) if (x.isA(Float)): <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">res << (i, nil) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">wall("Scanning finished, " + res.size + " device(s) found."); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">debug.unblock; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">res <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/** Create one device per scan result, using basename and the index. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">*/ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function instanciate(scanResult, where=Global) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">// Extract model list. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var d = Dictionary.new; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var s: scanResult) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">d[s[1].basename] = 1; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var k: d.keys) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">where.setSlot(k+"s", [nil]*254); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var s: scanResult) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var n = s[1].basename + s[0]; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">wall("Creating " + n); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var d = Device.new(this, s[0], s[1]); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">where.setSlot(n, d); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">where.getSlot(s[1].basename+"s")[s[0]] = d; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Also create an array with basename.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Example: [(1, AX12)] will create motor1, motor[1].

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">/** Device descriptions. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">* Only set multiWrite/Read for slots that will be read/written often. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">*/ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">class Dynamixel.DeviceDesc { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function identity(x) { x}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function fallback { call.message}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mapIn = [getSlot("identity")]*255; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mapOut = [getSlot("identity")]*255; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var range = [nil] * 255; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">function deviceSetup {}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var R = (true, false); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var W = (false, true); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var RW = (true, true); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var NOOP = (false, false); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var base = [ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//key size read/write// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(model, 2, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//("version", 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(ID, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(bitRate, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(returnDelay,1, RW)];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//class AX12: this// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var slots = base + [// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">key size read/write <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(cwLimit, 2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(ccwLimit, 2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(reserved, 1, NOOP), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(tempLimit, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(voltageMin, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(voltageMax, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(torqueMax, 2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(statusLevel,1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(alarmLED, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(alarmShutdown, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(reserved2, 1, NOOP), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(downCalib, 2, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(upCalib, 2, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">("load", 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(led, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(cwMargin, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(ccwMargin, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(cwSlope, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(ccwSlope, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(targetPos, 2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(targetSpeed,2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(torqueLimit,2, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(position, 2, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(currentSpeed, 2, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(torque, 2, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(voltage, 1, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(temperature,1, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(registeredInstruction, 1, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(reserved3, 1, NOOP), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(moving, 1, R), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(lock, 1, RW), <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">(punch, 2, RW) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">]; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//Trigger cow.// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.mapIn = mapIn.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.mapOut = mapOut.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.range = range.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Motor position: 0-1023 -> -150-150deg <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">mapIn[6] = mapIn[8] = mapIn[36] <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">= function(x) { (x / 1023 - 0.5) * 300deg}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">mapOut[6] = mapOut[8] = mapOut[30] <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">= function(x) { ((x / 300deg) + 0.5) * 1023}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">range[6] = range[8] = range[36] = range[30] = (-150deg, 150deg); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//Same thing for angle limit// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Motor speed: 1023 = 114 RPM <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//0.0116697 = 1 / 1023 * 228 * pi / 60// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//mapIn[38] = function(x) { {if (x<1024) x else 1024 - x} * 0.0116697};// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//mapOut[32] = function(x) { var v = x/0.0116697| if (v<0) 1024-v else v };// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//range[38] = range[32] = (-228*pi/60, 228*pi/60);// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var multiWrite = ["targetPos", "targetSpeed"];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var multiRead = ["position, speed, torque"];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var pairs = [// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//"val" => ("position", "targetPos"),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//"speed" => ("currentSpeed", "targetSpeed")// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var basename = "motor";// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//};// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//class AXS1: this {// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var slots = base + [// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved5, 5, NOOP),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(tempLimit, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(voltageMin, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(voltageMax, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved2, 2, NOOP),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(statusLevel,1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved3, 3, NOOP),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(obstacleRange, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lightRange, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved4, 4, NOOP),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRLeft, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRCenter, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRRight, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lightLeft, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lightCenter,1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lightRight, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(obstacle, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(light, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved1, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(soundVolume, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(soundVolumeMax, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(clapCount, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(clapTime, 2, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(buzzerIndex,1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(buzzerTime, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(voltage, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(temperature,1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(registeredInstruction, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(reserved1, 1, NOOP),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRData, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lock, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRRX0, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRRX1, 1, R),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRTX0, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(IRTX1, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(obstacleCompare, 1, RW),// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(lightCompare, 1, RW)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.mapIn = mapIn.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.mapOut = mapOut.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//this.range = range.clone;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var multiWrite = [];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var multiRead = [];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var pairs = [];// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var basename = "sensor";// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//}// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//};//
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Each device description is made of:
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">-slots: list of (name, size, (readable, writable))
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">Must be in the order of addresses, starting from 0, without gaps.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">-multiWrite: list of names for which to use optimized writing.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">-multiRead: list of names for which to use optimized reading.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">-pairs: dictionary targetSlot => (readslot, writeslot)
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">create new slots merging tho two read/write ones
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">- mapOut[]: Array of functions mapping from user values to dynamixel values
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">- mapIn[addr]: Mapping from dynamixel values to user values.
 * <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">- range[addr]: (rangemin, rangemax) for value, or nil for none

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//class Dynamixel.Device {// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//function init(conn, address, model)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.conn = conn;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.address = address;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.deviceModel = model;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var this.handle = WeakPointer.new;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//conn.addresses << address;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//createSlots;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//};// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//function createSlots// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var idx = 0;// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//for|(var item: deviceModel.slots)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//{// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//(var name, var size, (var read, var write)) = item|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var myidx = idx |// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var writeCache = conn.writeCache[myidx]|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//idx += size|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//if (!read && !write)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//continue|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//var v = UVar.new(this, name)|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//v.owned = true|// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//if (read)// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">//v.notifyAccess(handle, {// <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">No multiread primivite without cm5. <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (item not in deviceModel.multiRead || conn.cm5) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">closure <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mi = deviceModel.mapIn[myidx] | <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var raw = conn.read(address, myidx, size)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (!raw.isNil) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.writeOwned(mi(raw)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">closure <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mi = deviceModel.mapIn[myidx] | <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (time - conn.readTime[myidx] < period) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.writeOwned(mi(conn.readValues[myidx][address])) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">conn.readTime[myidx] = time| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var vals = conn.read(conn.addresses, myidx, size)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (vals.isA(List) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">&& vals.size == conn.addresses.size) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var i: vals.size) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">conn.readValues[myidx][conn.addresses[i]] = <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">vals[i]| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.writeOwned(mi(conn.readValues[myidx][address])) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">debug: wall("reply error: " +vals) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">)| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (write) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.notifyChangeOwned(handle, { <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (item not in deviceModel.multiWrite) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">closure <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mo = deviceModel.mapOut[myidx]| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">conn.write(address, myidx, size, mo(v.val)) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">else <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">closure <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var mo = deviceModel.mapOut[myidx]| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var first = writeCache.empty | <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">writeCache << (address, mo(v.val))| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (first) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">detach({ sleep(period) | <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">conn.multiWrite(writeCache, myidx, size) | <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">writeCache.clear <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">})| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (deviceModel.range[myidx]) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">setProperty(name, "rangemin", deviceModel.range[myidx][0])| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">setProperty(name, "rangemax", deviceModel.range[myidx][1]) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">}; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">for|(var i: deviceModel.pairs) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var name = i[0]; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var readName = i[1][0]; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var writeName = i[1][1]; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">var v = UVar.new(this, name); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.owned = true; <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.notifyChangeOwned(handle, closure { updateSlot(writeName, v.val)}); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">v.notifyAccess(handle, closure {v.writeOwned(getSlot(readName).accessor)}); <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">if (! getProperty(writeName, "rangemin").isVoid) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">{ <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">setProperty(name, "rangemin", getProperty(writeName, "rangemin"))| <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">setProperty(name, "rangemax", getProperty(writeName, "rangemax")) <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">} <span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">};

<span style="color: #3b3b3b; font-family: 'Courier New',Courier,monospace; font-size: 90%;">trace: trace.block;