mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-04 11:44:08 +05:30
Fixed some indentation
This commit is contained in:
parent
f37836d4e0
commit
5f0125da8b
@ -237,34 +237,34 @@ int runCommand() {
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(BAUDRATE);
|
Serial.begin(BAUDRATE);
|
||||||
|
|
||||||
// Initialize the motor controller if used */
|
// Initialize the motor controller if used */
|
||||||
#ifdef USE_BASE
|
#ifdef USE_BASE
|
||||||
#ifdef ARDUINO_ENC_COUNTER
|
#ifdef ARDUINO_ENC_COUNTER
|
||||||
//set as inputs
|
//set as inputs
|
||||||
DDRD &= ~(1<<LEFT_ENC_PIN_A);
|
DDRD &= ~(1<<LEFT_ENC_PIN_A);
|
||||||
DDRD &= ~(1<<LEFT_ENC_PIN_B);
|
DDRD &= ~(1<<LEFT_ENC_PIN_B);
|
||||||
DDRC &= ~(1<<RIGHT_ENC_PIN_A);
|
DDRC &= ~(1<<RIGHT_ENC_PIN_A);
|
||||||
DDRC &= ~(1<<RIGHT_ENC_PIN_B);
|
DDRC &= ~(1<<RIGHT_ENC_PIN_B);
|
||||||
|
|
||||||
//enable pull up resistors
|
// Enable pull up resistors
|
||||||
PORTD |= (1<<LEFT_ENC_PIN_A);
|
PORTD |= (1<<LEFT_ENC_PIN_A);
|
||||||
PORTD |= (1<<LEFT_ENC_PIN_B);
|
PORTD |= (1<<LEFT_ENC_PIN_B);
|
||||||
PORTC |= (1<<RIGHT_ENC_PIN_A);
|
PORTC |= (1<<RIGHT_ENC_PIN_A);
|
||||||
PORTC |= (1<<RIGHT_ENC_PIN_B);
|
PORTC |= (1<<RIGHT_ENC_PIN_B);
|
||||||
|
|
||||||
// tell pin change mask to listen to left encoder pins
|
// Tell pin change mask to listen to left encoder pins
|
||||||
PCMSK2 |= (1 << LEFT_ENC_PIN_A)|(1 << LEFT_ENC_PIN_B);
|
PCMSK2 |= (1 << LEFT_ENC_PIN_A)|(1 << LEFT_ENC_PIN_B);
|
||||||
// tell pin change mask to listen to right encoder pins
|
// Tell pin change mask to listen to right encoder pins
|
||||||
PCMSK1 |= (1 << RIGHT_ENC_PIN_A)|(1 << RIGHT_ENC_PIN_B);
|
PCMSK1 |= (1 << RIGHT_ENC_PIN_A)|(1 << RIGHT_ENC_PIN_B);
|
||||||
|
|
||||||
// enable PCINT1 and PCINT2 interrupt in the general interrupt mask
|
// Enable PCINT1 and PCINT2 interrupt in the general interrupt mask
|
||||||
PCICR |= (1 << PCIE1) | (1 << PCIE2);
|
PCICR |= (1 << PCIE1) | (1 << PCIE2);
|
||||||
|
#endif
|
||||||
|
initMotorController();
|
||||||
|
resetPID();
|
||||||
#endif
|
#endif
|
||||||
initMotorController();
|
|
||||||
resetPID();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Attach servos if used */
|
/* Attach servos if used */
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < N_SERVOS; i++) {
|
for (i = 0; i < N_SERVOS; i++) {
|
||||||
@ -321,26 +321,26 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are using base control, run a PID calculation at the appropriate intervals
|
// If we are using base control, run a PID calculation at the appropriate intervals
|
||||||
#ifdef USE_BASE
|
#ifdef USE_BASE
|
||||||
if (millis() > nextPID) {
|
if (millis() > nextPID) {
|
||||||
updatePID();
|
updatePID();
|
||||||
nextPID += PID_INTERVAL;
|
nextPID += PID_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if we have exceeded the auto-stop interval
|
// Check to see if we have exceeded the auto-stop interval
|
||||||
if ((millis() - lastMotorCommand) > AUTO_STOP_INTERVAL) {;
|
if ((millis() - lastMotorCommand) > AUTO_STOP_INTERVAL) {
|
||||||
setMotorSpeeds(0, 0);
|
setMotorSpeeds(0, 0);
|
||||||
moving = 0;
|
moving = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sweep servos
|
// Sweep servos
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < N_SERVOS; i++) {
|
for (i = 0; i < N_SERVOS; i++) {
|
||||||
servos[i].doSweep();
|
servos[i].doSweep();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user