Skip to content

Commit bb78c3c

Browse files
authored
Merge pull request #17 from gbr1/dev
0.1.0
2 parents b25117d + 3b2b9fb commit bb78c3c

33 files changed

+1731
-1573
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear in the root of a volume
13+
.DocumentRevisions-V100
14+
.fseventsd
15+
.Spotlight-V100
16+
.TemporaryItems
17+
.Trashes
18+
.VolumeIcon.icns
19+
.com.apple.timemachine.donotpresent
20+
21+
# Directories potentially created on remote AFP share
22+
.AppleDB
23+
.AppleDesktop
24+
Network Trash Folder
25+
Temporary Items
26+
.apdisk

LICENSE

Lines changed: 373 additions & 504 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
# Arduino_Robot_Firmware
2-
firmware
1+
# Arduino_AlvikCarrier
2+
3+
4+
W.I.P.

examples/.DS_Store

-6 KB
Binary file not shown.

examples/blink/.DS_Store

-6 KB
Binary file not shown.

examples/blink/blink.ino

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
/*
2-
This file is part of the Arduino Alvik library.
3-
Copyright (c) 2023 Arduino SA. All rights reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2+
This file is part of the Arduino_AlvikCarrier library.
3+
4+
Copyright (c) 2023 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
1810
*/
1911

2012

13+
2114
// This example makes the rear orange led blink. It is also called LED_BUILTIN
2215

23-
#include "Arduino_Alvik_Firmware.h"
16+
#include "Arduino_AlvikCarrier.h"
2417

2518

26-
Arduino_Alvik_Firmware alvik;
19+
Arduino_AlvikCarrier alvik;
2720

2821
void setup(){
2922
alvik.begin();

examples/firmware_01/firmware_01.ino

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
/*
2-
This file is part of the Arduino Alvik library.
3-
Copyright (c) 2023 Arduino SA. All rights reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2+
This file is part of the Arduino_AlvikCarrier library.
3+
4+
Copyright (c) 2023 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
1810
*/
1911

20-
#include "Arduino_Alvik_Firmware.h"
12+
13+
#include "Arduino_AlvikCarrier.h"
2114
#include "sensor_line.h"
2215
#include "sensor_tof_matrix.h"
2316
#include "ucPack.h"
2417

25-
Arduino_Alvik_Firmware robot;
18+
Arduino_AlvikCarrier alvik;
2619
SensorLine line(EXT_A2,EXT_A1,EXT_A0);
27-
SensorTofMatrix tof(robot.wire, EXT_GPIO3, EXT_GPIO2);
20+
SensorTofMatrix tof(alvik.wire, EXT_GPIO3, EXT_GPIO2);
2821

2922

3023
ucPack packeter(200);
@@ -51,17 +44,17 @@ float kp, ki, kd;
5144

5245
void setup(){
5346
Serial.begin(115200);
54-
robot.begin();
55-
robot.setLedBuiltin(HIGH);
47+
alvik.begin();
48+
alvik.setLedBuiltin(HIGH);
5649
line.begin();
5750
tof.begin();
5851

5952
uint8_t version[3];
60-
robot.getVersion(version[0], version[1], version[2]);
53+
alvik.getVersion(version[0], version[1], version[2]);
6154
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
62-
robot.serial->write(packeter.msg,msg_size);
55+
alvik.serial->write(packeter.msg,msg_size);
6356

64-
robot.setLedBuiltin(LOW);
57+
alvik.setLedBuiltin(LOW);
6558

6659

6760
code=0;
@@ -72,33 +65,33 @@ void setup(){
7265
}
7366

7467
void loop(){
75-
while(robot.serial->available() > 0) {
76-
packeter.buffer.push(robot.serial->read());
68+
while(alvik.serial->available() > 0) {
69+
packeter.buffer.push(alvik.serial->read());
7770
}
7871
if (packeter.checkPayload()) {
7972
code = packeter.payloadTop();
8073
switch (code){
8174
case 'J':
8275
packeter.unpacketC2F(code,left,right);
83-
robot.setRpm(left, right);
76+
alvik.setRpm(left, right);
8477
break;
8578
/*
8679
case 'S':
87-
robot.setRpm(0,0);
80+
alvik.setRpm(0,0);
8881
break;
8982
*/
9083
case 'L':
9184
packeter.unpacketC1B(code,leds);
92-
robot.setAllLeds(leds);
85+
alvik.setAllLeds(leds);
9386
break;
9487

9588
case 'P':
9689
packeter.unpacketC1B3F(code,pid,kp,ki,kd);
9790
if (pid=='L'){
98-
robot.setKPidLeft(kp,ki,kd);
91+
alvik.setKPidLeft(kp,ki,kd);
9992
}
10093
if (pid=='R'){
101-
robot.setKPidRight(kp,ki,kd);
94+
alvik.setKPidRight(kp,ki,kd);
10295
}
10396
break;
10497
}
@@ -110,27 +103,27 @@ void loop(){
110103
case 0:
111104
line.update();
112105
msg_size = packeter.packetC3I('l', line.getLeft(), line.getCenter(), line.getRight());
113-
robot.serial->write(packeter.msg,msg_size);
106+
alvik.serial->write(packeter.msg,msg_size);
114107
break;
115108
case 1:
116-
robot.updateTouch();
117-
msg_size = packeter.packetC1B('t', robot.getTouchKeys());
118-
robot.serial->write(packeter.msg,msg_size);
109+
alvik.updateTouch();
110+
msg_size = packeter.packetC1B('t', alvik.getTouchKeys());
111+
alvik.serial->write(packeter.msg,msg_size);
119112
break;
120113
case 2:
121-
robot.updateAPDS();
122-
msg_size = packeter.packetC3I('c', robot.getRed(), robot.getGreen(), robot.getBlue());
123-
robot.serial->write(packeter.msg,msg_size);
114+
alvik.updateAPDS();
115+
msg_size = packeter.packetC3I('c', alvik.getRed(), alvik.getGreen(), alvik.getBlue());
116+
alvik.serial->write(packeter.msg,msg_size);
124117
break;
125118
case 3:
126119
if (tof.update_rois()){
127120
msg_size = packeter.packetC7I('f', tof.getLeft(), tof.getCenterLeft(), tof.getCenter(), tof.getCenterRight(), tof.getRight(), tof.get_min_range_top_mm(), tof.get_max_range_bottom_mm());
128-
robot.serial->write(packeter.msg,msg_size);
121+
alvik.serial->write(packeter.msg,msg_size);
129122
}
130123
break;
131124
case 4:
132-
msg_size = packeter.packetC3F('q', robot.getRoll(), robot.getPitch(), robot.getYaw());
133-
robot.serial->write(packeter.msg,msg_size);
125+
msg_size = packeter.packetC3F('q', alvik.getRoll(), alvik.getPitch(), alvik.getYaw());
126+
alvik.serial->write(packeter.msg,msg_size);
134127
break;
135128
}
136129
sensor_id++;
@@ -141,17 +134,17 @@ void loop(){
141134

142135
if (millis()-tmotor>20){
143136
tmotor=millis();
144-
robot.updateMotors();
145-
robot.updateImu();
146-
msg_size = packeter.packetC2F('j', robot.getRpmLeft(),robot.getRpmRight());
147-
robot.serial->write(packeter.msg,msg_size);
137+
alvik.updateMotors();
138+
alvik.updateImu();
139+
msg_size = packeter.packetC2F('j', alvik.getRpmLeft(),alvik.getRpmRight());
140+
alvik.serial->write(packeter.msg,msg_size);
148141

149142
}
150143

151144
if (millis()-timu>10){
152145
timu=millis();
153-
robot.updateImu();
154-
msg_size = packeter.packetC6F('i', robot.getAccelerationX(), robot.getAccelerationY(), robot.getAccelerationZ(), robot.getAngularVelocityX(), robot.getAngularVelocityY(), robot.getAngularVelocityZ());
155-
robot.serial->write(packeter.msg,msg_size);
146+
alvik.updateImu();
147+
msg_size = packeter.packetC6F('i', alvik.getAccelerationX(), alvik.getAccelerationY(), alvik.getAccelerationZ(), alvik.getAngularVelocityX(), alvik.getAngularVelocityY(), alvik.getAngularVelocityZ());
148+
alvik.serial->write(packeter.msg,msg_size);
156149
}
157150
}

examples/imu/.DS_Store

-6 KB
Binary file not shown.

examples/imu/imu.ino

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
/*
2-
This file is part of the Arduino Alvik library.
3-
Copyright (c) 2023 Arduino SA. All rights reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2+
This file is part of the Arduino_AlvikCarrier library.
3+
4+
Copyright (c) 2023 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
1810
*/
1911

2012

13+
2114
// This example shows IMU data, accelerations are in Gs, angular velocities in deg/s and orientation is in degrees.
2215

23-
#include "Arduino_Alvik_Firmware.h"
16+
#include "Arduino_AlvikCarrier.h"
2417

2518
unsigned long time_imu_update=0;
2619

27-
Arduino_Alvik_Firmware alvik;
20+
Arduino_AlvikCarrier alvik;
2821

2922
void setup(){
3023
Serial.begin(115200);

examples/kinematics/kinematics.ino

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
This file is part of the Arduino_AlvikCarrier library.
3+
4+
Copyright (c) 2023 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
10+
*/
11+
12+
// WIP
13+
14+
#include "Arduino_AlvikCarrier.h"
15+
16+
Arduino_AlvikCarrier alvik;
17+
18+
unsigned long tmotor=0;
19+
unsigned long ttask=0;
20+
uint8_t task=0;
21+
22+
void setup() {
23+
Serial.begin(115200);
24+
alvik.begin();
25+
ttask=millis();
26+
tmotor=millis();
27+
task=0;
28+
}
29+
30+
void loop() {
31+
if (millis()-tmotor>20){
32+
tmotor=millis();
33+
alvik.updateMotors();
34+
alvik.kinematics->updatePose(alvik.motor_control_left->getTravel(), alvik.motor_control_right->getTravel());
35+
Serial.print("\t");
36+
Serial.print(alvik.kinematics->getDeltaX());
37+
Serial.print("\t");
38+
Serial.print(alvik.kinematics->getDeltaY());
39+
Serial.print("\t");
40+
Serial.print(alvik.kinematics->getTheta());
41+
Serial.print("\n");
42+
}
43+
44+
if (millis()-ttask>2000){
45+
ttask=millis();
46+
switch (task){
47+
case 0:
48+
alvik.drive(50,0);
49+
break;
50+
case 1:
51+
alvik.drive(0,0);
52+
break;
53+
case 2:
54+
alvik.drive(0,-90);
55+
break;
56+
case 3:
57+
alvik.drive(0,0);
58+
break;
59+
}
60+
task++;
61+
if (task>3){
62+
task=0;
63+
}
64+
}
65+
66+
}

examples/motor/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)