Hola a todos, recientemente me he impreso un hexapodo y estoy utilizando la libreria de Juan Gonzalez (obijuan)
El caso es que cuando intento compilar uno de los ejemplos me aparece un error en el include oscillador.h
Antes de poner este post he estado mirando por todos los sitios para buscar el error.
In file included from hexapodFullDemo.ino:13:
C:\Users\Paco\Documents\Arduino\libraries\ArduSnake/Oscillator.h:8:19: warning: extra tokens at end of #ifndef directive
C:\Users\Paco\Documents\Arduino\libraries\ArduSnake/Oscillator.h:9:19: warning: missing whitespace after the macro name
In file included from hexapodFullDemo.ino:13:
C:\Users\Paco\Documents\Arduino\libraries\ArduSnake/Oscillator.h:18: error: expected identifier before '.' token
C:\Users\Paco\Documents\Arduino\libraries\ArduSnake/Oscillator.h:18: error: expected unqualified-id before '.' token
el programa es:
//--------------------------------------------------------------
//-- MicroHexapod controller example Printed Micro-Hexapod (Plate and code) by CarlosGS - Thingiverse
//--
//-- Uses the ArduSnake oscillator library by Juan Gonzalez-Gomez
//-- GitHub - Obijuan/ArduSnake: Arduino modular snake robots library. Generate the locomotion of snake robots easily!
//-----------------------------------------------------------
//-- Layer: Oscillator
//------------------------------------------------------------
//-- Example of use of the Oscillator layer
//--
//-- MOD Example 5: A mini-wave is used for the locomotion of
//-- a three modules worm robot
//--------------------------------------------------------------
//-- (c) Carlos Garcia-Saura (Carlosgs), November-2012
//-- CC-BY-SA license
//--------------------------------------------------------------
#include <Servo.h>
#include <Oscillator.h>
//-- Declare the oscillators
Oscillator osc_middle, osc_right, osc_left;
//-- Global parameters for the oscillators
const int A=30; // Amplitude (higher -> longer steps) set 10-40
const int T=1000; // Period (lower -> faster moves)
void setup()
{
delay(1000); // Small startup delay, replace with start-button press (if present)
//-- Attach the oscillators to the servos
osc_middle.attach(2); // 2,3 and 4 are the digital pins
osc_right.attach(3);
osc_left.attach(4);
//-- Set the parameters
osc_middle.SetO(-17); // Correction for the offset of the servos
osc_right.SetO(-20);
osc_left.SetO(0);
osc_middle.SetA(5); // Middle motor needs a small amplitude (5-10)
osc_right.SetA(A);
osc_left.SetA(A);
osc_middle.SetT(T); // Set the period of work
osc_right.SetT(T);
osc_left.SetT(T);
//-- Refresh the oscillators
osc_middle.refresh();
osc_right.refresh();
osc_left.refresh();
//-- Set the phase difference
//-- This defines the type of movement the robot makes
osc_middle.SetPh(DEG2RAD( 90 ));
osc_left.SetPh( DEG2RAD( 0 ));
osc_right.SetPh( DEG2RAD( 0 )); // For example, putting 180 here will make the robot spin clockwise
}
void loop()
{
//-- Refresh the oscillators
osc_middle.refresh();
osc_right.refresh();
osc_left.refresh();
}
y el archivo Oscillator.h es
//--------------------------------------------------------------
//-- Oscillator.pde
//-- Generate sinusoidal oscillations in the servos
//--------------------------------------------------------------
//-- (c) Juan Gonzalez-Gomez (Obijuan), Dec 2011
//-- GPL license
//--------------------------------------------------------------
#ifndef Oscillator_h
#define Oscillator_h
#endif
#include <Servo.h>
//-- Macro for converting from degrees to radians
#ifndef DEG2RAD
#define DEG2RAD(g) ((g)*M_PI)/180
#endif
class Oscillator
{
public:
Oscillator(){};
void attach(int pin, bool rev =false);
void SetA(unsigned int A) {_A=A;};
void SetO(unsigned int O) {_O=O;};
void SetPh(double Ph) {_phase0=Ph;};
void SetT(unsigned int T);
void Stop() {_stop=true;};
void Play() {_stop=false;};
void Reset() {_phase=0;};
void refresh();
private:
bool next_sample();
private:
//-- Servo that is attached to the oscillator
Servo _servo;
//-- Oscillators parameters
unsigned int _A; //-- Amplitude (degrees)
unsigned int _O; //-- Offset (degrees)
unsigned int _T; //-- Period (miliseconds)
double _phase0; //-- Phase (radians)
//-- Internal variables
int _pos; //-- Current servo pos
double _phase; //-- Current phase
double _inc; //-- Increment of phase
double _N; //-- Number of samples
unsigned int _TS; //-- sampling period (ms)
long _previousMillis;
long _currentMillis;
//-- Oscillation mode. If true, the servo is stopped
bool _stop;
//-- Reverse mode
bool _rev;
};
#endif
Ardusnake la tengo puesta en la libreria
Gracias de antemano