Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
brunofraga committed Apr 2, 2016
1 parent 57ec292 commit 091fc0d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
Empty file modified 2016.1/Robot/examples/Robot/Robot.ino
100644 → 100755
Empty file.
Empty file modified 2016.1/Robot/keywords.txt
100644 → 100755
Empty file.
13 changes: 11 additions & 2 deletions 2016.1/Robot/robot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "robot.h"


// This constructor was designed to be used with the Duo-Driver (China)
Robot::Robot(byte r_enable,
byte r_motor_1, byte r_motor_2,

Expand All @@ -13,10 +15,17 @@ Robot::Robot(byte r_enable,
AutoControlBoard(r_enable, r_motor_1, r_motor_2,
l_enable, l_motor_1, l_motor_2,
r_vcc_ref, r_gnd_ref,
l_vcc_ref, l_gnd_ref)
{
l_vcc_ref, l_gnd_ref){
}

// This constructor was designed to be used with the Duo-Driver (China)
// Robot::Robot(byte left_motor, byte right_motor):
// SensorBoard(),
// AutoControlBoard(left_motor, right_motor){
// }



void Robot::useCommand(char command)
{
/*
Expand Down
3 changes: 3 additions & 0 deletions 2016.1/Robot/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Robot: public SensorBoard, public AutoControlBoard
byte r_vcc_ref=UNUSED, byte r_gnd_ref=UNUSED,
byte l_vcc_ref=UNUSED, byte l_gnd_ref=UNUSED);

Robot(byte left_motor, byte right_motor);


void useCommand(char command);
};

Expand Down
19 changes: 6 additions & 13 deletions 2016.1/Trekking/trekking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,6 @@ void Trekking::trackTrajectory() {


void Trekking::regulateControl() {
if(linear){
desired_linear_velocity = MAX_LINEAR_VELOCITY;
desired_angular_velocity = 0;
}else{
desired_linear_velocity = 0;
desired_angular_velocity = MAX_ANGULAR_VELOCITY;
}

//constants to handle errors
const int k_rho = 1;
const int k_gamma = 3;
Expand All @@ -328,16 +320,17 @@ void Trekking::regulateControl() {
// getting configurations (final/desired and current/real)
Position* q_real = locator.getLastPosition(); //real robot position
unsigned long t = tracking_regulation_timer.getElapsedTime();
Position gap = q_real->calculateGap(targets.get(current_target_index));
Position gap = q_real->calculateGap(*targets.get(current_target_index));

//Angular transformation
float rho = (gap.getX()^2 + gap.getY()^2)^(0.5);
float gamma = 0; // atan2(gap.getY(), gap.getX()) - q_real->getTheta() ?????????????????

float rho = sqrt( pow(gap.getX(),2) + pow(gap.getY(),2) );
float gamma = atan2(gap.getY(), gap.getX()) - q_real->getTheta();
float delta = -gamma - q_real->getTheta();

//Error Gain and v e w definition
v = (k_rho * rho) * cos(gamma);
w = (k_delta * delta + gamma) * (k_gamma * sin(gamma) * cos(gamma)/gamma);
float v = (k_rho * rho) * cos(gamma);
float w = (k_delta * delta + gamma) * (k_gamma * sin(gamma) * cos(gamma)/gamma);

controlMotors(v, w, true);
distance_to_target = q_real->distanceFrom(targets.get(current_target_index));
Expand Down
2 changes: 1 addition & 1 deletion 2016.1/Trekking/trekkingpins.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
const byte INIT_BUTTON_PIN = 3;
const byte EMERGENCY_BUTTON_PIN = 2;
const byte OPERATION_MODE_SWITCH_PIN = A3; \\ Não está atualizado!
const byte OPERATION_MODE_SWITCH_PIN = A3; // Não está atualizado!

const bool MANUAL_MODE = 0;
const bool AUTO_MODE = 1;
Expand Down

0 comments on commit 091fc0d

Please sign in to comment.