58 #define ARDRONE_GPIO_PORT 0x32524
60 #define ARDRONE_GPIO_PIN_MOTOR1 171
61 #define ARDRONE_GPIO_PIN_MOTOR2 172
62 #define ARDRONE_GPIO_PIN_MOTOR3 173
63 #define ARDRONE_GPIO_PIN_MOTOR4 174
65 #define ARDRONE_GPIO_PIN_IRQ_FLIPFLOP 175
66 #define ARDRONE_GPIO_PIN_IRQ_INPUT 176
88 perror(
"open_port: Unable to open /dev/ttyO0 - ");
95 struct termios options;
100 cfsetospeed(&options,
B115200);
102 options.c_cflag |= (CLOCAL | CREAD);
105 options.c_oflag &= ~OPOST;
127 for (
int m = 0; m < 4; m++) {
130 if (reply[0] != 0xe0 || reply[1] != 0x00) {
131 printf(
"motor%d cmd=0x%02x reply=0x%02x\n", m + 1, (
int)reply[0], (
int)reply[1]);
161 perror(
"actuators_ardrone_cmd: write failed");
172 static bool last_motor_on =
false;
175 static uint8_t reset_flipflop_counter = 0;
176 if (reset_flipflop_counter > 0) {
177 reset_flipflop_counter--;
179 if (reset_flipflop_counter == 10) {
183 }
else if (reset_flipflop_counter == 1) {
198 reset_flipflop_counter = 20;
207 #define BIT_NUMBER(VAL,BIT) (((VAL)>>BIT)&0x03)
212 static uint32_t previous_led_hw_values = 0x00;
234 cmd[0] = 0x20 | ((pwm0 & 0x1ff) >> 4);
235 cmd[1] = ((pwm0 & 0x1ff) << 4) | ((pwm1 & 0x1ff) >> 5);
236 cmd[2] = ((pwm1 & 0x1ff) << 3) | ((pwm2 & 0x1ff) >> 6);
237 cmd[3] = ((pwm2 & 0x1ff) << 2) | ((pwm3 & 0x1ff) >> 7);
238 cmd[4] = ((pwm3 & 0x1ff) << 1);
265 cmd[0] = 0x60 | ((led0 & 1) << 4) | ((led1 & 1) << 3) | ((led2 & 1) << 2) | ((led3 & 1) << 1);
266 cmd[1] = ((led0 & 2) << 3) | ((led1 & 2) << 2) | ((led2 & 2) << 1) | ((led3 & 2) << 0);
int actuator_ardrone2_fd
Power consumption @ 11V all 4 motors running PWM A 0 0.2 80 1.3 100 1.5 150 2.0 190 2...
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
bool autopilot_get_motors_on(void)
get motors status
Some architecture independent helper functions for GPIOs.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
#define ARDRONE_GPIO_PIN_MOTOR2
void actuators_ardrone_commit(void)
void actuators_ardrone_set_leds(uint8_t led0, uint8_t led1, uint8_t led2, uint8_t led3)
Write LED command cmd = 011rrrr0 000gggg0 (this is ardrone1 format, we need ardrone2 format) ...
Hardware independent API for actuators (servos, motor controllers).
ssize_t full_read(int fd, uint8_t *buf, size_t count)
Read from fd even while being interrupted.
Architecture independent timing functions.
#define ARDRONE_GPIO_PIN_IRQ_INPUT
#define ARDRONE_GPIO_PIN_MOTOR4
static void actuators_ardrone_reset_flipflop(void)
void actuators_ardrone_set_pwm(uint16_t pwm0, uint16_t pwm1, uint16_t pwm2, uint16_t pwm3)
Write motor speed command cmd = 001aaaaa aaaabbbb bbbbbccc ccccccdd ddddddd0.
ardrone2 navdata aquisition driver.
void actuators_ardrone_motor_status(void)
#define ARDRONE_GPIO_PIN_MOTOR3
Core autopilot interface common to all firmwares.
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
#define BIT_NUMBER(VAL, BIT)
volatile uint32_t nb_sec
full seconds since startup
#define ARDRONE_GPIO_PORT
ssize_t full_write(int fd, const uint8_t *buf, size_t count)
Write to fd even while being interrupted.
void autopilot_set_motors_on(bool motors_on)
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly FIXME is i...
Actuator driver for ardrone2-raw version.
void actuators_ardrone_close(void)
void actuators_ardrone_led_run(void)
void gpio_setup_input(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
int actuators_ardrone_cmd(uint8_t cmd, uint8_t *reply, int replylen)
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
void actuators_ardrone_init(void)
#define ARDRONE_GPIO_PIN_IRQ_FLIPFLOP
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]
#define ARDRONE_GPIO_PIN_MOTOR1