Skip to content

Commit

Permalink
Merge branch 'devel' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gbr1 authored Jan 24, 2024
2 parents 887737b + 287f05a commit b2d1b4a
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 163 deletions.
2 changes: 1 addition & 1 deletion examples/firmware_01/firmware_01.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void loop(){
}

break;

case 'S':
packeter.unpacketC2B(code,servo_A,servo_B);
alvik.setServoA(servo_A);
Expand Down
19 changes: 12 additions & 7 deletions examples/kinematics/kinematics.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ void loop() {
if (millis()-tmotor>20){
tmotor=millis();
alvik.updateMotors();
alvik.kinematics->updatePose(alvik.motor_control_left->getTravel(), alvik.motor_control_right->getTravel());
alvik.kinematics->inverse(alvik.motor_control_left->getRPM(),alvik.motor_control_right->getRPM());
alvik.kinematics->updatePose();
Serial.print("\t");
Serial.print(alvik.kinematics->getDeltaX());
Serial.print(alvik.kinematics->getLinearVelocity());
Serial.print("\t");
Serial.print(alvik.kinematics->getDeltaY());
Serial.print(alvik.kinematics->getAngularVelocity());
Serial.print("\t");
Serial.print(alvik.kinematics->getX());
Serial.print("\t");
Serial.print(alvik.kinematics->getY());
Serial.print("\t");
Serial.print(alvik.kinematics->getTheta());
Serial.print("\n");
Expand All @@ -45,16 +50,16 @@ void loop() {
ttask=millis();
switch (task){
case 0:
alvik.drive(50,0);
alvik.rotate(90);
break;
case 1:
alvik.drive(0,0);
alvik.drive(40,0);
break;
case 2:
alvik.drive(0,-90);
alvik.rotate(-90);
break;
case 3:
alvik.drive(0,0);
alvik.drive(-40,0);
break;
}
task++;
Expand Down
83 changes: 83 additions & 0 deletions examples/position/position.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
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_AlvikCarrier.h"

Arduino_AlvikCarrier alvik;

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

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

void loop() {
if (millis()-tmotor>20){
tmotor = millis();
alvik.updateMotors();
Serial.print(reference);
Serial.print("\t");
Serial.print(alvik.getPositionLeft());
Serial.print("\n");
}

if (millis()-ttask>5000){
ttask = millis();
switch (task){
case 0:
reference = 90;
break;
case 1:
reference = 0;
break;
case 2:
reference = -90;
break;
case 3:
reference = 0;
break;
case 4:
reference = 360;
break;
case 5:
reference = 45;
break;
case 6:
reference = -270;
break;
case 7:
reference = 0;
break;
case 8:
reference = 5;
break;
case 9:
reference = 10;
break;
}
alvik.setPositionLeft(reference);
task++;
if (task>9){
task = 0;
}
}

}

Loading

0 comments on commit b2d1b4a

Please sign in to comment.