RAW
03.08.2010, 17:49
hallo
bin neu in die robotik eingestiegen (RP6). habe auch gleich eine frage: Wie integriere ich ein servo code(von radbruch) 2. in ein bestehenden code 1. mein problem ist das ich kein make file erstellen kann. d.h wie kann ich die codes verbinden. meine codes lauten:
1.
#include "RP6RobotBaseLib.h"
void acsStateChanged(void)
{
// Print messages to UART:
writeString_P("ACS state changed L: ");
if(obstacle_left) // Left "sensor" has detected something
writeChar('o');
else
writeChar(' ');
writeString_P(" | R: ");
rotate(40, RIGHT, 90, BLOCKING);
if(obstacle_right) // Right "sensor" has detected something
writeChar('o');
else
writeChar(' ');
writeString_P(" | L: ");
rotate(0, LEFT, 0, BLOCKING);
if(obstacle_right && obstacle_left) // left AND right sensor have detected something...
writeString_P(" MIDDLE!");
writeChar('\n');
moveAtSpeed(0,0); //Bremsen
move(50, FWD, DIST_MM(6000), BLOCKING); //zurückfahren
rotate(40, RIGHT, 320, BLOCKING); //Drehen
move(50, FWD, DIST_MM(6000), BLOCKING);//Vorwärts (am Hindernis vorbei) fahren
rotate(40, LEFT, 320, BLOCKING); //zurückdrehen
//dann geradeaus weiter
// -----------------------------------------------------------
if(obstacle_left && obstacle_right) // Obstacle in the middle?
statusLEDs.byte = 0b100100;
else
statusLEDs.byte = 0b000000;
statusLEDs.LED5 = obstacle_left;
statusLEDs.LED4 = (!obstacle_left); // Inverted LED5!
statusLEDs.LED2 = obstacle_right;
statusLEDs.LED1 = (!obstacle_right); // Inverted LED2!
// Update the LED values:
updateStatusLEDs(); // The LEDs are turned on/off here! __Not__ in the lines above!
}
void bumpersStateChanged(void)
{
writeString_P("Bumpers state changed! BPL: ");
if(bumper_left) // Left Bumper
writeChar('o');
else
writeChar(' ');
move(50, BWD, DIST_MM(100), BLOCKING); //zurückfahren
writeString_P(" | BPR: ");
if(bumper_right) // Right Bumper
writeChar('o');
else
writeChar(' ');
move(50, BWD, DIST_MM(100), BLOCKING); //zurückfahren
writeChar('\n');
}
/************************************************** ***************************/
// Main - The program starts here:
int main(void)
{
initRobotBase(); // Always call this first! The Processor will not work
// correctly otherwise.
// Write Message to UART:
writeString_P("\nRP6 ACS - Testprogram\n");
writeString_P("_____________________\n\n");
setLEDs(0b111111);
mSleep(1000);
setLEDs(0b001001);
// ---------------------------
// Register Event Handlers:
// Set ACS state changed event handler:
ACS_setStateChangedHandler(acsStateChanged);
// Set Bumpers state changed event handler:
BUMPERS_setStateChangedHandler(bumpersStateChanged );
// ---------------------------
powerON();
// ---------------------------
setACSPwrMed(); //
// setACSPwrLow(); // Low power
// setACSPwrHigh(); // High Power
// ---------------------------
// Main loop
while(true)
{
task_RP6System();
}
return 0;
}
2.
// Servoansteuerung mit sleep(), Servoimpuls an ADC0, 2 Positionen 10.1.09 mic
#include "RP6RobotBaseLib.h"
uint8_t i;
int main(void)
{
initRobotBase(); // initialisieren
DDRA |= 1; // Datenrichtung Port A Bit 0 (das ist ADC0) auf Ausgang
while(true)
{
for(i=0;i<100; i++) // 100 mal Impuls für Position 1 senden
{
PORTA |= 1;
sleep(10);
PORTA &= ~1;
sleep(200-10);
}
for(i=0;i<100; i++) // 100 mal Impuls für Position 2 senden
{
PORTA |= 1;
sleep(20);
PORTA &= ~1;
sleep(200-20);
}
}
return(0);
}
danke
bin neu in die robotik eingestiegen (RP6). habe auch gleich eine frage: Wie integriere ich ein servo code(von radbruch) 2. in ein bestehenden code 1. mein problem ist das ich kein make file erstellen kann. d.h wie kann ich die codes verbinden. meine codes lauten:
1.
#include "RP6RobotBaseLib.h"
void acsStateChanged(void)
{
// Print messages to UART:
writeString_P("ACS state changed L: ");
if(obstacle_left) // Left "sensor" has detected something
writeChar('o');
else
writeChar(' ');
writeString_P(" | R: ");
rotate(40, RIGHT, 90, BLOCKING);
if(obstacle_right) // Right "sensor" has detected something
writeChar('o');
else
writeChar(' ');
writeString_P(" | L: ");
rotate(0, LEFT, 0, BLOCKING);
if(obstacle_right && obstacle_left) // left AND right sensor have detected something...
writeString_P(" MIDDLE!");
writeChar('\n');
moveAtSpeed(0,0); //Bremsen
move(50, FWD, DIST_MM(6000), BLOCKING); //zurückfahren
rotate(40, RIGHT, 320, BLOCKING); //Drehen
move(50, FWD, DIST_MM(6000), BLOCKING);//Vorwärts (am Hindernis vorbei) fahren
rotate(40, LEFT, 320, BLOCKING); //zurückdrehen
//dann geradeaus weiter
// -----------------------------------------------------------
if(obstacle_left && obstacle_right) // Obstacle in the middle?
statusLEDs.byte = 0b100100;
else
statusLEDs.byte = 0b000000;
statusLEDs.LED5 = obstacle_left;
statusLEDs.LED4 = (!obstacle_left); // Inverted LED5!
statusLEDs.LED2 = obstacle_right;
statusLEDs.LED1 = (!obstacle_right); // Inverted LED2!
// Update the LED values:
updateStatusLEDs(); // The LEDs are turned on/off here! __Not__ in the lines above!
}
void bumpersStateChanged(void)
{
writeString_P("Bumpers state changed! BPL: ");
if(bumper_left) // Left Bumper
writeChar('o');
else
writeChar(' ');
move(50, BWD, DIST_MM(100), BLOCKING); //zurückfahren
writeString_P(" | BPR: ");
if(bumper_right) // Right Bumper
writeChar('o');
else
writeChar(' ');
move(50, BWD, DIST_MM(100), BLOCKING); //zurückfahren
writeChar('\n');
}
/************************************************** ***************************/
// Main - The program starts here:
int main(void)
{
initRobotBase(); // Always call this first! The Processor will not work
// correctly otherwise.
// Write Message to UART:
writeString_P("\nRP6 ACS - Testprogram\n");
writeString_P("_____________________\n\n");
setLEDs(0b111111);
mSleep(1000);
setLEDs(0b001001);
// ---------------------------
// Register Event Handlers:
// Set ACS state changed event handler:
ACS_setStateChangedHandler(acsStateChanged);
// Set Bumpers state changed event handler:
BUMPERS_setStateChangedHandler(bumpersStateChanged );
// ---------------------------
powerON();
// ---------------------------
setACSPwrMed(); //
// setACSPwrLow(); // Low power
// setACSPwrHigh(); // High Power
// ---------------------------
// Main loop
while(true)
{
task_RP6System();
}
return 0;
}
2.
// Servoansteuerung mit sleep(), Servoimpuls an ADC0, 2 Positionen 10.1.09 mic
#include "RP6RobotBaseLib.h"
uint8_t i;
int main(void)
{
initRobotBase(); // initialisieren
DDRA |= 1; // Datenrichtung Port A Bit 0 (das ist ADC0) auf Ausgang
while(true)
{
for(i=0;i<100; i++) // 100 mal Impuls für Position 1 senden
{
PORTA |= 1;
sleep(10);
PORTA &= ~1;
sleep(200-10);
}
for(i=0;i<100; i++) // 100 mal Impuls für Position 2 senden
{
PORTA |= 1;
sleep(20);
PORTA &= ~1;
sleep(200-20);
}
}
return(0);
}
danke