]> git.droids-corp.org - aversive.git/commitdiff
kickstand
authorzer0 <zer0@carbon.local>
Sat, 8 May 2010 00:15:43 +0000 (02:15 +0200)
committerzer0 <zer0@carbon.local>
Sat, 8 May 2010 00:15:43 +0000 (02:15 +0200)
projects/microb2010/ballboard/ax12_user.c
projects/microb2010/cobboard/ax12_user.c
projects/microb2010/cobboard/commands_cobboard.c
projects/microb2010/cobboard/shovel.c
projects/microb2010/cobboard/shovel.h
projects/microb2010/cobboard/state.c
projects/microb2010/common/i2c_commands.h
projects/microb2010/mainboard/commands_mainboard.c

index e3a5f9fc01ae7d3e1966da6835e457f627253226..ae443f1e21707d248998c7a760579ad6775fe221 100644 (file)
@@ -80,7 +80,6 @@
  */
 
 static volatile uint8_t ax12_state = AX12_STATE_READ;
-extern volatile struct cirbuf g_tx_fifo[]; /* uart fifo */
 static volatile uint8_t ax12_nsent = 0;
 
 /* Called by ax12 module to send a character on serial line. Count the
index b022ef720f3ab77c6680ee8f6e3ab094cc088ecc..ceb84139503b9948632e1a0b9974b41d8accee49 100644 (file)
@@ -91,7 +91,6 @@ static microseconds t_prev_msg = 0;
  */
 
 static volatile uint8_t ax12_state = AX12_STATE_READ;
-extern volatile struct cirbuf g_tx_fifo[]; /* uart fifo */
 static volatile uint8_t ax12_nsent = 0;
 
 /* Called by ax12 module to send a character on serial line. Count the
index 9cfda19daf050f92f3fe3d2138203a313081104c..24226e1e3446d5895b9f371beabec8f0b6ca8ef3 100644 (file)
@@ -193,6 +193,8 @@ static void cmd_state1_parsed(void *parsed_result,
                state_init();
        else if (!strcmp_P(res->arg1, PSTR("eject")))
                state_set_mode(I2C_COBBOARD_MODE_EJECT);
+       else if (!strcmp_P(res->arg1, PSTR("kickstand")))
+               state_set_mode(I2C_COBBOARD_MODE_KICKSTAND);
        else if (!strcmp_P(res->arg1, PSTR("ignore_i2c")))
                state_set_i2c_ignore(1);
        else if (!strcmp_P(res->arg1, PSTR("care_i2c")))
@@ -203,7 +205,7 @@ static void cmd_state1_parsed(void *parsed_result,
 
 prog_char str_state1_arg0[] = "cobboard";
 parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
-prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c";
+prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c#kickstand";
 parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
 
 prog_char help_state1[] = "set cobboard mode";
index 56efa9685c59b5d7803d77686ae58ba49bbd80ae..71139ab7ad78fab6357f6e59843c54d0e60d6071 100644 (file)
@@ -142,6 +142,13 @@ void shovel_up(void)
        cs_set_consign(&cobboard.shovel.cs, SHOVEL_UP);
 }
 
+void shovel_kickstand(void)
+{
+       quadramp_set_1st_order_vars(&cobboard.shovel.qr, 200, 200);
+       quadramp_set_2nd_order_vars(&cobboard.shovel.qr, 10, 10);
+       cs_set_consign(&cobboard.shovel.cs, SHOVEL_UP);
+}
+
 uint8_t shovel_is_up(void)
 {
        return shovel_is_at_pos(SHOVEL_UP);
index fa0e2a29b5a043bf98241bde7f5f37aa66493189..3b01e77e0885b9581a87715efc770e1d2c2facc1 100644 (file)
@@ -32,6 +32,7 @@ void shovel_set(void *mot, int32_t cmd);
 void shovel_down(void);
 void shovel_mid(void);
 void shovel_up(void);
+void shovel_kickstand(void);
 
 uint8_t shovel_is_up(void);
 uint8_t shovel_is_down(void);
index 4eef55f5c55247e6de410c51d2e92a3e211acb60..d9e6533c8f8f47bf379b379615c09b7eeb231c1e 100644 (file)
@@ -66,6 +66,7 @@ static uint8_t cob_count;
 #define INIT(mode)       ((mode) == I2C_COBBOARD_MODE_INIT)
 #define HARVEST(mode)    ((mode) == I2C_COBBOARD_MODE_HARVEST)
 #define EJECT(mode)      ((mode) == I2C_COBBOARD_MODE_EJECT)
+#define KICKSTAND(mode)  ((mode) == I2C_COBBOARD_MODE_KICKSTAND)
 
 uint8_t state_debug = 0;
 
@@ -131,6 +132,10 @@ uint8_t state_spicklemode_weak(uint8_t side)
 /* pack/deploy spickles depending on mode */
 static void spickle_prepare(uint8_t side)
 {
+       /* pack spickle if we are not in harvest mode */
+       if (!HARVEST(state_mode))
+               spickle_pack(side);
+
        /* we do nothing in mode no out */
        if (state_spicklemode_nomove(side))
                return;
@@ -337,20 +342,36 @@ void state_machine(void)
                        state_mode = I2C_COBBOARD_MODE_HARVEST;
                }
 
-               /* pack/deply spickles, enable/disable roller */
-               cobroller_off(I2C_LEFT_SIDE);
-               cobroller_off(I2C_RIGHT_SIDE);
-               spickle_prepare(I2C_LEFT_SIDE);
-               spickle_prepare(I2C_RIGHT_SIDE);
-
-               /* harvest */
-               if (cob_count < 5) {
-                       if (state_spicklemode_deployed(I2C_LEFT_SIDE) &&
-                           state_spicklemode_autoharvest(I2C_LEFT_SIDE))
-                               state_do_harvest(I2C_LEFT_SIDE);
-                       if (state_spicklemode_deployed(I2C_RIGHT_SIDE) &&
-                           state_spicklemode_autoharvest(I2C_RIGHT_SIDE))
-                               state_do_harvest(I2C_RIGHT_SIDE);
+               if (HARVEST(state_mode)) {
+                       /* init for each loop */
+                       shovel_down();
+                       servo_carry_close();
+                       servo_door_close();
+                       shovel_current_limit_enable(0);
+
+                       /* pack/deply spickles, enable/disable roller */
+                       cobroller_off(I2C_LEFT_SIDE);
+                       cobroller_off(I2C_RIGHT_SIDE);
+                       spickle_prepare(I2C_LEFT_SIDE);
+                       spickle_prepare(I2C_RIGHT_SIDE);
+
+                       /* harvest if not many cobs */
+                       if (cob_count < 5) {
+                               if (state_spicklemode_deployed(I2C_LEFT_SIDE) &&
+                                   state_spicklemode_autoharvest(I2C_LEFT_SIDE))
+                                       state_do_harvest(I2C_LEFT_SIDE);
+                               if (state_spicklemode_deployed(I2C_RIGHT_SIDE) &&
+                                   state_spicklemode_autoharvest(I2C_RIGHT_SIDE))
+                                       state_do_harvest(I2C_RIGHT_SIDE);
+                       }
+               }
+
+               /* help to climb the hill */
+               if (KICKSTAND(state_mode)) {
+                       servo_carry_open();
+                       servo_door_open();
+                       shovel_current_limit_enable(1);
+                       shovel_kickstand();
                }
 
                /* eject */
index b5c9d36897e6ee80ae32d5209255621ef6b12818..5e4a449053ebba2df31833e32d5e8c15939fd004 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Copyright Droids Corporation (2007)
- * 
+ *  Copyright Droids Corporation (2010)
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -78,6 +78,7 @@ struct i2c_cmd_cobboard_set_mode {
 #define I2C_COBBOARD_MODE_HARVEST      0x01 /* harvest mode */
 #define I2C_COBBOARD_MODE_EJECT        0x02 /* eject cobs */
 #define I2C_COBBOARD_MODE_INIT         0x03 /* init state machine */
+#define I2C_COBBOARD_MODE_KICKSTAND    0x04 /* help to climb the hill */
        uint8_t mode;
 };
 
@@ -128,6 +129,7 @@ struct i2c_ans_cobboard_status {
 #define I2C_COBBOARD_STATUS_LBUSY         0x02
 #define I2C_COBBOARD_STATUS_RBUSY         0x03
 #define I2C_COBBOARD_STATUS_EJECT         0x04
+#define I2C_COBBOARD_STATUS_KICKSTAND     0x05
        uint8_t status;
 
        uint8_t cob_count;
index 2335ce38662fc347a09540081d0c547470bf8724..04e8c9171120bde625ac2b2895ac3708e45a18fc 100644 (file)
@@ -738,11 +738,13 @@ static void cmd_cobboard_setmode1_parsed(void *parsed_result, void *data)
                i2c_cobboard_set_mode(I2C_COBBOARD_MODE_INIT);
        else if (!strcmp_P(res->arg1, PSTR("eject")))
                i2c_cobboard_set_mode(I2C_COBBOARD_MODE_EJECT);
+       else if (!strcmp_P(res->arg1, PSTR("kickstand")))
+               i2c_cobboard_set_mode(I2C_COBBOARD_MODE_KICKSTAND);
 }
 
 prog_char str_cobboard_setmode1_arg0[] = "cobboard";
 parse_pgm_token_string_t cmd_cobboard_setmode1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg0, str_cobboard_setmode1_arg0);
-prog_char str_cobboard_setmode1_arg1[] = "init#eject";
+prog_char str_cobboard_setmode1_arg1[] = "init#eject#kickstand";
 parse_pgm_token_string_t cmd_cobboard_setmode1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg1, str_cobboard_setmode1_arg1);
 
 prog_char help_cobboard_setmode1[] = "set cobboard mode (mode)";