Skip to content

Commit b57c459

Browse files
Sylwester DawidaSylwester Dawida
Sylwester Dawida
authored and
Sylwester Dawida
committed
update
1 parent e52b5e9 commit b57c459

File tree

9 files changed

+61
-48
lines changed

9 files changed

+61
-48
lines changed

python/.idea/workspace.xml

+23-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/C_code/arduinoTestCode/arduinoTestCode.ino

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
SoftwareSerial arlo(4, 5); // RX | TX
99
#define LOCKLED 12
10-
#define halfTurn 500
10+
#define halfTurn 44
1111

1212
//napięcia na pinach 3.3V
1313
//command frame dates and meaining
@@ -75,17 +75,17 @@ char formatBuff[30];
7575

7676
//changing steps with settings
7777
const int turnOffest = halfTurn / (2 * 5); //18 deg
78-
const int speedOffest = 127 / 8; //max 127
79-
const int stepOffest = 80;
78+
const int speedOffest = 127 / 10; //max 127
79+
const int stepOffest = halfTurn/4;
8080

8181
const int minSpeed = 10;
8282
const int maxSpeed = 120;
83-
const int maxStep = 800;
84-
const int minStep = 50;
83+
const int maxStep = 255;
84+
const int minStep = 10;
8585
const int maxTurn = halfTurn; //180 deg
8686
const int minTurn = halfTurn / 18; //10 deg
8787
//default
88-
int step = halfTurn;
88+
int step = halfTurn/2;
8989
int speed = 50;
9090
int turn = halfTurn / 4;
9191

@@ -217,19 +217,19 @@ void setExecutionParameters() {
217217
if (command == forward) {
218218
leftEnd = step;
219219
rightEnd = step;
220-
drive_speed(speed, speed, step);
220+
drive_speed(-speed, -speed, step);
221221
} else if (command == backward) {
222222
leftEnd = step;
223223
rightEnd = step;
224-
drive_speed(-speed, -speed, step);
224+
drive_speed(speed, speed, step);
225225
} else if (command == turnLeft) {
226226
leftEnd = turn;
227227
rightEnd = turn;
228-
drive_speed(-speed, speed, turn);
228+
drive_speed(speed, -speed, turn);
229229
} else if (command == turnRight) {
230230
leftEnd = turn;
231231
rightEnd = turn;
232-
drive_speed(speed, -speed, turn);
232+
drive_speed(-speed, speed, turn);
233233
} else if (command == turnAround) {
234234
leftEnd = halfTurn;
235235
rightEnd = halfTurn;
@@ -292,7 +292,7 @@ char cleft = 127 + left;
292292
arlo.write(cleft);
293293
char cright = 127 + right;
294294
arlo.write(cright);
295-
char cend = 200; //endD;
295+
char cend = endD;
296296
arlo.write(cend);
297297
}
298298

python/C_code/arlo2.0.binary

-172 Bytes
Binary file not shown.

python/C_code/arlo2.0.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void getData() {
2626
char c = 1;
2727
while(1){
2828
//dprint(xbee, "begin\n");
29+
//freqout(4, 500, 2000);
2930
while(c != 184)
3031
c = fdserial_rxChar(xbee);
3132
myWait();
@@ -46,7 +47,7 @@ void getData() {
4647
//dprint(xbee, "You typed: %d %d %d\n", speedR, speedL, end);
4748
myWait();
4849
c = fdserial_rxChar(xbee);
49-
end = 2 * (int)c;
50+
end = 4 * (int)c;
5051
if(!end){
5152
emergency = 1;
5253
continue;
@@ -60,16 +61,18 @@ void getData() {
6061
}
6162
}
6263
commandEnded = 0;
64+
//freqout(4, 500, 3000);
6365
dprint(xbee, "r");
66+
//freqout(4, 500, 3000);
6467
}
6568
}
6669

6770
int main()
6871
{
6972
int ticksL = 0;
7073
int ticksR = 0;
71-
freqout(2, 2000, 3000);
72-
print("starting\n");
74+
freqout(4, 500, 2000);
75+
//print("starting\n");
7376
cog_run(getData, 128);
7477

7578

@@ -78,20 +81,21 @@ int main()
7881

7982
while(1)
8083
{
81-
print("before\n");
84+
//print("before\n");
8285
while(!ready)
8386
;
84-
85-
print("before2\n");
87+
freqout(4, 500, 3000);
88+
//print("before2\n");
8689
drive_clearTicks();
8790
drive_speed(speedL, speedR);
8891
ticksR = 0;
89-
print("before3\n"); // 20/127 of full power to motors
92+
//print("before3\n"); // 20/127 of full power to motors
9093
while(abs(ticksR) < end && !emergency)
9194
drive_getTicks(&ticksL, &ticksR);
9295
drive_speed(0,0);
9396
emergency = 0;
9497
ready = 0;
95-
print("before4\n");
98+
freqout(4, 500, 3000);
99+
//print("before4\n");
96100
}
97101
}

python/C_code/arlo2.0.elf

-334 Bytes
Binary file not shown.

python/C_code/cmm/arlo2.0.binary

-208 Bytes
Binary file not shown.

python/C_code/cmm/arlo2.0.elf

-365 Bytes
Binary file not shown.
Binary file not shown.

python/serialComunication.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,13 @@ class SerialComunicator(object):
195195

196196
def __init__(self, fnct):
197197
self.connected = False
198-
self.port = 'COM7' ##port com
198+
self.nmb = 9
199+
self.port = 'COM{}'.format(self.nmb) ##port com
199200
self.secourityCode = b'QV9JKMNASKJNWKJSNKWJ'
200201
self.serial_port = serial.Serial()
201202
self.baud = 9600
202203
self.data = b''
204+
self.gotData = b''
203205
self.event = threading.Event()
204206
self.onDataFunction = fnct
205207
self.disc = False
@@ -222,10 +224,19 @@ def runRx(self):
222224
data = self.serial_port.read(9999999999)
223225
if len(data) > 0:
224226
print("raw Data: {}".format(data))
227+
if self.gotData:
228+
self.gotData += data
229+
if len(self.gotData) == 5:
230+
self.onDataFunction(self.gotData)
231+
self.gotData = b''
225232
if data[0] == 3:
226-
#print("command: {}".format(data[1:]))
227-
self.onDataFunction(data[1:])
228-
233+
data = data[1:]
234+
if len(data) != 5:
235+
self.gotData = data
236+
else:
237+
#print("command: {}".format(data[1:]))
238+
self.onDataFunction(data)
239+
self.gotData = b''
229240

230241
async def run(self, loop):
231242
self.print("Running communicator interface")

0 commit comments

Comments
 (0)