-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRobotIndustrial.cpp
138 lines (127 loc) · 3.59 KB
/
RobotIndustrial.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "RobotIndustrial.h"
// Aquí se añade el objeto de la articulación con servo
void RobotIndustrial::addArticulacion(String Motor_type, String Motor_tag_, int pin)
{
if (flag_assembled == false) {
if (curr_art < MAX_Articulacion )
{
if (Motor_type == "SERVO") {
arts[curr_art].initServo(Motor_tag_, pin);
Articulacion_tag[curr_art] = Motor_tag_;
curr_art++;
}
}
}
}
// Aquí añade el objeto articulación con un motor DC
void RobotIndustrial::addArticulacion(String Motor_type, String Motor_tag_, int pin1, int pin2)
{
}
// Sensoresrs con un pin
void RobotIndustrial::addSensor(String Sensor_type, String Sensor_tag, int pin) {
if (flag_assembled == false) {
if (Sensor_type == "PIR") {
if (curr_sensor < MAX_SENSORS) {
sensors[curr_sensor].addPir( pin);
sensors_tag[curr_sensor] = Sensor_tag;
curr_sensor++;
}
}
else if (Sensor_type == "Infrarrojo") {
if (curr_sensor < MAX_SENSORS) {
sensors[curr_sensor].addInfrarrojo( pin);
sensors_tag[curr_sensor] = Sensor_tag;
curr_sensor++;
}
}
else if (Sensor_type == "Generico") {
if (curr_sensor < MAX_SENSORS) {
sensors[curr_sensor].addGenerico( pin);
sensors_tag[curr_sensor] = Sensor_tag;
curr_sensor++;
}
}
}
}
// Sensors con dos pins
void RobotIndustrial::addSensor(String Sensor_type, String Sensor_tag, int pin1, int pin2)
{
if (flag_assembled == false) {
if (Sensor_type == "ULTRASONIC") {
if (curr_sensor < MAX_SENSORS) {
sensors[curr_sensor].addUltrasonic( pin1, pin2);
sensors_tag[curr_sensor] = Sensor_tag;
curr_sensor++;
}
}
}
}
// leé los datos del sensor
int RobotIndustrial::readdatafromsensor( String sensor_tag) {
for (int i = 0 ; i < curr_sensor ; i++) {
if (sensor_tag.equals(sensors_tag[i])) {
return sensors[i].readdata();
}
}
}
void RobotIndustrial::addMovimiento(String motion_tag, String motor_tag, int posF, int posI)
{
if (flag_assembled == false) {
if (curr_move < Max_Movements )
{
for (int i = 0 ; i < MAX_Articulacion ; i++) {
if ( Articulacion_tag[i].equals( motor_tag)) {
movimientos[curr_move].addMovimiento(arts[i], posF, posI);
movimientos_tag[curr_move] = motion_tag;
curr_move++;
}
}
}
}
}
void RobotIndustrial::addMovimientoatras(String motion_tag, String motor_tag, int posF, int posI)
{
if (flag_assembled == false) {
if (curr_move < Max_Movements )
{
for (int i = 0 ; i < MAX_Articulacion ; i++) {
if ( Articulacion_tag[i].equals( motor_tag)) {
movimientos[curr_move].addMovimiento(arts[i], posI, posF);
movimientos_tag[curr_move] = motion_tag;
curr_move++;
}
}
}
}
}
void RobotIndustrial::robotassembly() {
flag_assembled = true;
}
// sentencia para decirle al robot que se mueva (actuators movement)
/*void RobotIndustrial::action()
{
if (flag_assembled == true) {
for (int i = 0; i < curr_move; i++)
{
movimientos[i].execute();
}
} else {
Serial.println("You didin't indicate robot assembled");
}
}
*/
// Run specific instant movements
void RobotIndustrial::executemove(String tag_move)
{
if (flag_assembled == true) {
for (int i = 0; i < curr_move; i++)
{
if(tag_move.equals(movimientos_tag[i])){
movimientos[i].execute();
break;
}
}
} else {
Serial.println("You didin't indicate robot assembled");
}
}