Difference between revisions of "PhantomX Reactor Robot V2"
| Line 98: | Line 98: | ||
</pre> | </pre> | ||
| − | It is mandatory to rung option A first time, so the servos are correctly aligned. | + | <b>It is mandatory to rung option A first time, so the servos are correctly aligned. </b> |
Revision as of 20:12, 11 June 2026
Contents
Note: Most of the information of this website is obtained from: http://learn.trossenrobotics.com/projects/182-arbotix-getting-started-guide-arduino-ide-1-6-x-setup.html Please refer to the previuos link if you need more information.
Configuring the environment
Setting up the Arduino Software
- Download the Arduino IDE according to your operating system from: https://www.arduino.cc/en/Main/Software .
- Install the Arduino IDE
- If you have chosen to download the installer, run the installer and install the software in a path of your convenience.
- If you have chosen to download the sources (Linux or zip on Windows), uncompress the software in a path of your convenience
- Open/run Arduino IDE, so it will create all the folders needed
- Close Arduino IDE
Installing Tools and Libraries
-
On the Arduino IDE, go to File > Preferences from the top menu.
When the Preferences window appears, copy and paste following address in the Additional Boards Manager URLs textbox.
https://raw.githubusercontent.com/ROBOTIS-GIT/OpenRB-150/master/package_openrb_index.json
- Go to Tools > Board > Boards Manager. Search for Arduino SAMD and Install the latest version.
- Go to Tools > Board > Boards Manager. Search for OpenRB and Install the latest version.
- Go to Sketch -> Include library -> Manage Library Search for DYNAMIXEL2Arduino from the Library Manager and install the library.
- Go to Sketch -> Include library -> Manage Library Search for SAMDTimerInterrupt from the Library Manager and install the library.
Check installation
- Open/run Arduino IDE
- Open a Test:
File -> Examples --> Dynamixel2Arduino --> basic --> ping
Tools -> Board -> OpenRB-150 Std
Sketch-> Verify/Compile
If there is no errors, you are ready for the next step. If you found some errors, please review the previous steps.
FOR CONFIGURATION ONLY
Please download configApp from [here ] in your prefered destination.
Open, compile and load the .ino into the system.
Output should look as:
Timer started OK at millis() = 3351 ########################### Please enter option 1-7 to run individual tests again. 0) Relax Servos 1) Hold Servos 2) Get Joints Pos 3) Gripper Close 4) Gripper Open 5) TestAllJoints 6) MoveSpecificJoint 7) PingServos A) ServosHoming B) Get Servos Pos C) Move Specific Joint RAW D) Test trajectory E) Test Timer ###########################
It is mandatory to rung option A first time, so the servos are correctly aligned.
¡¡¡¡¡CHECK AFTER HERE!!!!!
Hello World example
We have created a helloWorld example to test the communication with the robot. Please download it from [here ] in your prefered destination. Untar the file:
tar -xvzf helloWorld.tgz
Compiling the code
File --> Open --> <HELLOWORLD_EXAMPLE>
Tools -> Board -> ArbotiX Std
Program-> Verify/Compile
Downloading the code to the robot
Once compiled, select the correct por to download the binaries: In Linux, typically:
tools -> Port -> /dev/ttyUSBX
In Windows, typically:
tools -> Port -> COMX
where X depends on your system and the number of peripherals on it
Upload your code to the board:
Program -> Upload
The IDE will notify that it is uploading and after some seconds it will say uploaded .
Playing with HelloWorld
This example allows you to move different joints of the robot.
Once the code have been loaded, you can open the serial port:
Tools --> Serial Monitor
Important:
- Select 115200 bauds. This is the speed selected on the code for communicating with the robot.
- Select "No line ending". To avoid sending a line end after entering commnds.
In some seconds you should see the board communicating the following menu:
################################ Serial Communication Established ################################ ################################ Please enter option 1-6 0) Relax Servos 1) Hold Servos 2) Get Joints Pos 3) Gripper Close 4) Gripper Open 5) TestAllJoints 6) MoveSpecificJoint ################################
These are the different options:
- Option 0 unpowers the servomotors of the robot.
- Option 1 powers the servomotors of the robot.
- Option 2 prints the position of every generalized coordinate (Base, Shoulder, Elbow, Wrist and Wrist rotation).
- Option 3 closes the gripper.
- Option 4 opens the gripper.
- Option 5 provides a test movement for the complete robot.
- Option 6 allows to move specific joints. In this case, once the option is selected, the following menu will appear:
Base: 0 Shoulder: 1 Elbow: 2 Wrist: 3 Wrist Rot: 4 Joint to move?:
The user must choose one of the 5 options, which correspond to different joints.
For every joint, once selected, the program will ask for a position to move, given the limits of the joint, for example:
Joint selected: 1 Shoulder: [-0.33, 2.97] Position to move?:
Once the position is provided through the serial port it will return all the information inserted, for example:
Moving Joint: 1 to position: 1.57
and it will move to the specified position.
Practice Template
For the implementation of the Practice of the "Control and Robotics in Medicine" subject of the "Master on Bioengineering" of the UPM, we have created a students template. You can download the template from [here ]
Structure
The template has 4 different files:
- poses.h : A file where different generalized coordinates can be stored.
- servos.h : A library to manage the servomotors independently.
- robot.h : A library to manage the different joints of the robot.
- P1-Template.h : The place where the practice should be developped.
Libraries
This Section provides important information for the resolution of Practice1. It is based on the explanation of different methods to control the robot, but it does not explain the complete set of methods. To get and exahustive description of all methods the servos.h and robot.h files must be studied.
In principle, all interaction with the robot will be made by means of the robot.h library. Main methors are as follows:
- void ROBOT_GripperOpen(void) : It opens the gripper, so it can release an object if already grasped.
- void ROBOT_GripperClose(void) : It close the gripper, so it can grasp an object if correctly located.
- void ROBOT_SetSingleTrajectory ( double *f_pos, uint16_t un_time, uint8_t un_trajectory_type ) : It performs a trajectory form one point (Q(t0)) to another point (Q(tf)).
Q(t0) and Q(tf) are defined as generalized coordinates Q={q1,q2,q3,q4,q5}.
Moreover, Q(t0) is defined as the coordinates at which the robot is located once the instruction is set.
- double *f_pos :
Q(tf) is coded as double * , for example:
double m_fCoordTest[] = {0,M_PI/2,-M_PI/2,0,0}; - uint16_t un_time , represents the time that it takes to travel from (Q(t0)) to Q(tf),that is: tf - t0 in milliseconds.
- uint8_t un_trajectory_type , represents the type of trajectory to perform: Linear (LINEAR = 0) or Cubic (CUBIC1 = 1)
Therefore, if we want to move the robot for the actual position to position m_fCoordTest taking 2 seconds with a linear function, we need to execute:ROBOT_SetSingleTrajectory (m_fCoordTest, 2000, LINEAR);
I we want to move the robot to the same coordinates but in 10 secons with a cubic function, we need to execute:
ROBOT_SetSingleTrajectory (m_fCoordTest, 10000, CUBIC1);
- double *f_pos :
Q(tf) is coded as double * , for example:
- void ROBOT_SetDoubleTrajectory ( double *un_pos1, double *un_pos2, uint16_t un_time1, uint16_t un_time2, uint8_t un_trajectory_type ) :
It performs a trajectory form one point (Q(t0)) to another point (Q(tf)) passing by a point (Q(tv)).
Q(t0), Q(tf) and Q(tv) are defined as generalized coordinates Q={q1,q2,q3,q4,q5}.
Moreover, Q(t0) is defined as the coordinates at which the robot is located once the instruction is set.
- double *f_pos1 :
Q(tv) is coded as double * , for example:
double m_fCoordTest[] = {0,M_PI/2,-M_PI/2,0,0}; - double *f_pos2 : Q(tf) is coded as double * .
- uint16_t un_time1 , represents the time that it takes to travel from (Q(t0)) to Q(tv),that is: tv - t0 in milliseconds.
- uint16_t un_time2 , represents the time that it takes to travel from (Q(tv)) to Q(tf),that is: tf - tv in milliseconds.
- uint8_t un_trajectory_type , represents the type of trajectory to perform. Only cubic trajectories are allowed (CUBIC2 = 2)
Therefore, if we want to move the robot for the actual position to position m_fCoordTest taking 5 seconds passing by m_fCoordVia with 2 seconds from the start, we need to execute:ROBOT_SetDoubleTrajectory (m_fCoordVia, m_fCoordTest, 2000, 3000, CUBIC2);
- double *f_pos1 :
Q(tv) is coded as double * , for example:
Implementation
P1-Template.ino follows the same structure as the helloWorld.ino example. However, a new option has been included in the menu (Opcion A). This option calls the P1Solution method. If you open P1-Template.ino and go to the end of the file, you will see the following code:
void P1Solution ( void )
{
/* START CODE TO BE IMPLEMENTED BY THE STUDENTS */
/* END CODE TO BE IMPLEMENTED BY THE STUDENTS */
}
It is between those comments where you must implement all functions required to achive the task. Remember you may need some delay instructions, defined as void delay (uint16_t millisec) , to prevent some instructions to execute before you need them.
Moreover, in the poses.h file you can find some examples of how to define the generalized coordinates of your system.