Skip to content

Commit

Permalink
Merge pull request #17 from gbr1/dev
Browse files Browse the repository at this point in the history
0.1.0
  • Loading branch information
gbr1 authored Jan 17, 2024
2 parents b25117d + 3b2b9fb commit bb78c3c
Show file tree
Hide file tree
Showing 33 changed files with 1,731 additions and 1,573 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
877 changes: 373 additions & 504 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Arduino_Robot_Firmware
firmware
# Arduino_AlvikCarrier


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



// This example makes the rear orange led blink. It is also called LED_BUILTIN

#include "Arduino_Alvik_Firmware.h"
#include "Arduino_AlvikCarrier.h"


Arduino_Alvik_Firmware alvik;
Arduino_AlvikCarrier alvik;

void setup(){
alvik.begin();
Expand Down
89 changes: 41 additions & 48 deletions examples/firmware_01/firmware_01.ino
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
/*
This file is part of the Arduino Alvik library.
Copyright (c) 2023 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
This file is part of the Arduino_AlvikCarrier library.
Copyright (c) 2023 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "Arduino_Alvik_Firmware.h"

#include "Arduino_AlvikCarrier.h"
#include "sensor_line.h"
#include "sensor_tof_matrix.h"
#include "ucPack.h"

Arduino_Alvik_Firmware robot;
Arduino_AlvikCarrier alvik;
SensorLine line(EXT_A2,EXT_A1,EXT_A0);
SensorTofMatrix tof(robot.wire, EXT_GPIO3, EXT_GPIO2);
SensorTofMatrix tof(alvik.wire, EXT_GPIO3, EXT_GPIO2);


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

void setup(){
Serial.begin(115200);
robot.begin();
robot.setLedBuiltin(HIGH);
alvik.begin();
alvik.setLedBuiltin(HIGH);
line.begin();
tof.begin();

uint8_t version[3];
robot.getVersion(version[0], version[1], version[2]);
alvik.getVersion(version[0], version[1], version[2]);
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
robot.serial->write(packeter.msg,msg_size);
alvik.serial->write(packeter.msg,msg_size);

robot.setLedBuiltin(LOW);
alvik.setLedBuiltin(LOW);


code=0;
Expand All @@ -72,33 +65,33 @@ void setup(){
}

void loop(){
while(robot.serial->available() > 0) {
packeter.buffer.push(robot.serial->read());
while(alvik.serial->available() > 0) {
packeter.buffer.push(alvik.serial->read());
}
if (packeter.checkPayload()) {
code = packeter.payloadTop();
switch (code){
case 'J':
packeter.unpacketC2F(code,left,right);
robot.setRpm(left, right);
alvik.setRpm(left, right);
break;
/*
case 'S':
robot.setRpm(0,0);
alvik.setRpm(0,0);
break;
*/
case 'L':
packeter.unpacketC1B(code,leds);
robot.setAllLeds(leds);
alvik.setAllLeds(leds);
break;

case 'P':
packeter.unpacketC1B3F(code,pid,kp,ki,kd);
if (pid=='L'){
robot.setKPidLeft(kp,ki,kd);
alvik.setKPidLeft(kp,ki,kd);
}
if (pid=='R'){
robot.setKPidRight(kp,ki,kd);
alvik.setKPidRight(kp,ki,kd);
}
break;
}
Expand All @@ -110,27 +103,27 @@ void loop(){
case 0:
line.update();
msg_size = packeter.packetC3I('l', line.getLeft(), line.getCenter(), line.getRight());
robot.serial->write(packeter.msg,msg_size);
alvik.serial->write(packeter.msg,msg_size);
break;
case 1:
robot.updateTouch();
msg_size = packeter.packetC1B('t', robot.getTouchKeys());
robot.serial->write(packeter.msg,msg_size);
alvik.updateTouch();
msg_size = packeter.packetC1B('t', alvik.getTouchKeys());
alvik.serial->write(packeter.msg,msg_size);
break;
case 2:
robot.updateAPDS();
msg_size = packeter.packetC3I('c', robot.getRed(), robot.getGreen(), robot.getBlue());
robot.serial->write(packeter.msg,msg_size);
alvik.updateAPDS();
msg_size = packeter.packetC3I('c', alvik.getRed(), alvik.getGreen(), alvik.getBlue());
alvik.serial->write(packeter.msg,msg_size);
break;
case 3:
if (tof.update_rois()){
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());
robot.serial->write(packeter.msg,msg_size);
alvik.serial->write(packeter.msg,msg_size);
}
break;
case 4:
msg_size = packeter.packetC3F('q', robot.getRoll(), robot.getPitch(), robot.getYaw());
robot.serial->write(packeter.msg,msg_size);
msg_size = packeter.packetC3F('q', alvik.getRoll(), alvik.getPitch(), alvik.getYaw());
alvik.serial->write(packeter.msg,msg_size);
break;
}
sensor_id++;
Expand All @@ -141,17 +134,17 @@ void loop(){

if (millis()-tmotor>20){
tmotor=millis();
robot.updateMotors();
robot.updateImu();
msg_size = packeter.packetC2F('j', robot.getRpmLeft(),robot.getRpmRight());
robot.serial->write(packeter.msg,msg_size);
alvik.updateMotors();
alvik.updateImu();
msg_size = packeter.packetC2F('j', alvik.getRpmLeft(),alvik.getRpmRight());
alvik.serial->write(packeter.msg,msg_size);

}

if (millis()-timu>10){
timu=millis();
robot.updateImu();
msg_size = packeter.packetC6F('i', robot.getAccelerationX(), robot.getAccelerationY(), robot.getAccelerationZ(), robot.getAngularVelocityX(), robot.getAngularVelocityY(), robot.getAngularVelocityZ());
robot.serial->write(packeter.msg,msg_size);
alvik.updateImu();
msg_size = packeter.packetC6F('i', alvik.getAccelerationX(), alvik.getAccelerationY(), alvik.getAccelerationZ(), alvik.getAngularVelocityX(), alvik.getAngularVelocityY(), alvik.getAngularVelocityZ());
alvik.serial->write(packeter.msg,msg_size);
}
}
Binary file removed examples/imu/.DS_Store
Binary file not shown.
29 changes: 11 additions & 18 deletions examples/imu/imu.ino
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
/*
This file is part of the Arduino Alvik library.
Copyright (c) 2023 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
This file is part of the Arduino_AlvikCarrier library.
Copyright (c) 2023 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/



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

#include "Arduino_Alvik_Firmware.h"
#include "Arduino_AlvikCarrier.h"

unsigned long time_imu_update=0;

Arduino_Alvik_Firmware alvik;
Arduino_AlvikCarrier alvik;

void setup(){
Serial.begin(115200);
Expand Down
66 changes: 66 additions & 0 deletions examples/kinematics/kinematics.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
This file is part of the Arduino_AlvikCarrier library.
Copyright (c) 2023 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

// WIP

#include "Arduino_AlvikCarrier.h"

Arduino_AlvikCarrier alvik;

unsigned long tmotor=0;
unsigned long ttask=0;
uint8_t task=0;

void setup() {
Serial.begin(115200);
alvik.begin();
ttask=millis();
tmotor=millis();
task=0;
}

void loop() {
if (millis()-tmotor>20){
tmotor=millis();
alvik.updateMotors();
alvik.kinematics->updatePose(alvik.motor_control_left->getTravel(), alvik.motor_control_right->getTravel());
Serial.print("\t");
Serial.print(alvik.kinematics->getDeltaX());
Serial.print("\t");
Serial.print(alvik.kinematics->getDeltaY());
Serial.print("\t");
Serial.print(alvik.kinematics->getTheta());
Serial.print("\n");
}

if (millis()-ttask>2000){
ttask=millis();
switch (task){
case 0:
alvik.drive(50,0);
break;
case 1:
alvik.drive(0,0);
break;
case 2:
alvik.drive(0,-90);
break;
case 3:
alvik.drive(0,0);
break;
}
task++;
if (task>3){
task=0;
}
}

}
Binary file removed examples/motor/.DS_Store
Binary file not shown.
Loading

0 comments on commit bb78c3c

Please sign in to comment.