|
|
|
|
|
|
3) error: lvalue required as decrement operand pos_1--; ^ 4) error: lvalue required as increment operand pos_1++; |
pos_1[servo]++;
1) why are there two void loop? (the beginning and the line 88) |
position[i] = position[i][0]; |
1) error: variable or field 'go_to_position' declared void void go_to_position(pos1[0], pos1[1], pos1[2], pos1[3], rest_pos[0], rest_pos[1], rest_pos[2], rest_pos[3]);//function ^ |
void go_to_position(int pos1[], int rest_pos[], int servo)
2) error: 'servo' was not declared in this scope while (pos_1[servo] != rest_pos[servo_count]) ^ |
The right hand side should be positionn[i][0]. The positionn array is 2 dimensional. |
Notice that your signature contained values whereas my function signature declared variables of type int[] and int. |
If you change the function signature, servo is now being passed into the function. |
|
|
line 115: error: invalid types 'int[int]' for array subscript position[i] = position[i][0]; ^ line 123: error: expected primary-expression before ']' token go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ line 123: error: 'rest_pos' was not declared in this scope go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ line 123: error: expected primary-expression before ']' token go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ line 123: error: 'servo' was not declared in this scope go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ line 140: error: array must be initialized with a brace-enclosed initializer int next_pos[servo] = 1; ^ exit status 1 invalid types 'int[int]' for array subscript |
line 115: error: invalid types 'int[int]' for array subscript position[i] = position[i][0]; ^ |
line 123: error: expected primary-expression before ']' token go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ |
line 123: error: 'rest_pos' was not declared in this scope go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ |
line 123: error: expected primary-expression before ']' token go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ |
line 123: error: 'servo' was not declared in this scope go_to_position(pos1[], rest_pos[], servo); //Function that moves the robot to the initial position ^ |
for (int servo = 0; servo < servo_count; ++servo)
), and then you can pass the loop index into go_to_position as the value servo
. You can't change the way the function is written without changing the way the function is called.line 140: error: array must be initialized with a brace-enclosed initializer int next_pos[servo] = 1; ^ |
next_pos[servo_count];
in the code that you copied. Declare right after line 125 (right after the declaration of the initial
array).
|
|
ID: 1 ID: 2 ID: 3 ID: 4 How many times do you want to repeat the sequence? repetitions = 1 How fast do you want to repeat the sequence? 1 = Slow 2 = Normal 3 = Fast Speed = 1000 microseconds Positions vector : [3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2397, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802, 379, 221, 2398, 3802,....] The servos will move to the initial position. SEQUENCE 1 Now the servos will do the registered movements. Turns engine 3: 0 Turns engine 3: 0 Turns engine 3: 0 Turns engine 3: 0 Turns engine 3: 0 Turns engine 3: 0 |
That is, i move the robot and the program takes the positions of each engine correctly. |
|
|
As I told you before you should send the position once and wait until it is reached. |
|
|
How many times do you want to repeat the sequence? repetitions = 2 How fast do you want to repeat the sequence? 1 = Slow 2 = Normal 3 = Fast Speed = 1000 microseconds Positions vector : [-983, -998, -1015, -1034, -1049, -1068, -1084, -1101, -1117, -1133, -1149, -1165, -1181, -1196, -1210, -1224, -1239, -1251, -1265, -1277, -1292, -1304, -1318, -1330, -1343, -1354, -1366, -1378, -1390, -1403, -1415, -1426, -1438, -1450, -1461, -1474, -1486, -1499, -1511, -1525, -1537, -1550, -1562, -1576, -1590, -1603, -1619, -1635, -1650, -1665, ] The servos will move to the initial position. |
SEQUENCE 1 Now the servos will do the registered movements. Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 Turns engine 0: 0 ....and more and more.... |
ID: 4 How many times do you want to repeat the sequence? repetitions = 1 How fast do you want to repeat the sequence? 1 = Slow 2 = Normal 3 = Fast Speed = 1000 microseconds Positions vector : [847, 847, 848, 847, 848, 848, 848, 848, 848, 850, 860, 879, 903, 932, 959, 984, 1006, 1020, 1028, 1029, ] The servos will move to the initial position. SEQUENCE 1 Now the servos will do the registered movements. linea 144 servo: 0 movement: 2 positionn: 848 next_pos: 1 intial: 847 linea 149 before_position: 847 initial: 848 turns: 0 Turns engine 0: 0 linea 144 servo: 0 movement: 3 positionn: 847 next_pos: -1 intial: 848 linea 149 before_position: 848 initial: 847 turns: 0 Turns engine 0: 0 linea 144 servo: 0 movement: 4 positionn: 848 next_pos: 1 intial: 847 linea 149 before_position: 847 initial: 848 turns: 0 Turns engine 0: 0 linea 144 servo: 0 movement: 9 positionn: 850 next_pos: 1 intial: 848 linea 149 before_position: 848 initial: 849 turns: 0 Turns engine 0: 0 linea 149 before_position: 849 initial: 850 turns: 0 Turns engine 0: 0 linea 144 servo: 0 movement: 10 positionn: 860 next_pos: 1 intial: 850 linea 149 before_position: 850 initial: 851 turns: 0 Turns engine 0: 0 linea 149 before_position: 851 initial: 852 turns: 0 Turns engine 0: 0 linea 149 before_position: 852 initial: 853 turns: 0 Turns engine 0: 0 linea 149 before_position: 853 initial: 854 turns: 0 Turns engine 0: 0 linea 149 before_position: 854 initial: 855 turns: 0 Turns engine 0: 0 linea 149 before_position: 855 initial: 856 turns: 0 Turns engine 0: 0 linea 149 before_position: 856 initial: 857 turns: 0 Turns engine 0: 0 linea 149 before_position: 857 initial: 858 turns: 0 Turns engine 0: 0 linea 149 before_position: 858 initial: 859 turns: 0 Turns engine 0: 0 linea 149 before_position: 859 initial: 860 turns: 0 Turns engine 0: 0 |
For example, when the robot has to go from position 848 to 850, the line 149 is printed twice, if the robot has to go from 848 to 853, the prints of the line 149 will print 5 times...and I do not know exactly why.
|
|
|
|
Finally, what are you trying to do with lines 154 - 163? I don't think you are succeeding. |
p.s. I am looking back at the code you have now. It looks much better than it did. Realize that my suggestions for most of the changes was renaming your variables to make them arrays where appropriate. Now that the code is more cleaned up, I see places for more efficiencies. |
The only doubt is that I do not know where to put the print of the line (167-171), since that was what made everything so slow, yes i know that i an so rookie in this. |
for (server = 0; etc...)
loop to be able to print info for all 4 servos. If you just want to print after every repetition, leave the lines where you have them, but wrap them in a for loop.In those lines I calculate the number of laps that each engine gives, and of course I always put 0 laps because in the tests to small movements, and did not give time to give a full turn, but now with 400 movements, it tells me correctly the amount of turns. |
If you have some new ideas I'll be happy to hear them!! |
int servo;
is unnecessary. Simply change line 136 to for (int servo = 0; etc...)
int before_position = initial[servo];
|
|
go_to_position(positionn[servo][0], servo); //Function that moves the robot to the initial position
go_to_position(pos2[servo], servo); //Function that moves the robot to the rest position
|
|
SEQUENCE 1 Now the servos will do the registered movements. Turns engine 4: 3827 Turns engine 4: 3827 Turns engine 4: 3827 Turns engine 4: 3827 |
|
|