From: Xavier L. <Ba...@us...> - 2010-05-20 13:43:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 9ab5f4a67923e98473a1685942ecf176e8c06fc4 (commit) via 755fd4c6d04fc43bc96eddfc9ee20f3007a717aa (commit) via b4fe376e4b223f387804ff33e89595c6345fa93d (commit) via 21a3822e7f2c19f56bfcda23fdf077c186a78080 (commit) via 4854cd39e1f97d00b3d77ecea3e50ce58852357d (commit) from 892d4515a07e0f72f224f324deea6fd8cc362bee (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9ab5f4a67923e98473a1685942ecf176e8c06fc4 Author: Xavier Lagorce <Xav...@cr...> Date: Thu May 20 15:42:23 2010 +0200 Added macro commands to monitor to move [Kro]bot Jr's AX12s commit 755fd4c6d04fc43bc96eddfc9ee20f3007a717aa Author: Xavier Lagorce <Xav...@cr...> Date: Thu May 20 15:41:53 2010 +0200 Remove some warnings commit b4fe376e4b223f387804ff33e89595c6345fa93d Author: Xavier Lagorce <Xav...@cr...> Date: Thu May 20 15:41:23 2010 +0200 Added constants for AX12 interesting positions for Krobot Jr commit 21a3822e7f2c19f56bfcda23fdf077c186a78080 Author: Xavier Lagorce <Xav...@cr...> Date: Wed May 19 23:26:28 2010 +0200 No need to wait after the last command commit 4854cd39e1f97d00b3d77ecea3e50ce58852357d Author: Xavier Lagorce <Xav...@cr...> Date: Wed May 19 23:23:47 2010 +0200 Modified AX12s IDs to be different from the default one ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c index dd17855..cf34548 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c @@ -150,8 +150,6 @@ void ax12Configure(uint8_t old_id, uint8_t new_id) { */ // Set ID ax12SendPacket(old_id, INST_WRITE, sizeof(paramsID), paramsID); - chThdSleepMilliseconds(1); - } void ax12Goto(uint8_t id, uint16_t position, uint16_t speed, uint8_t mode) { diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h index a685bcc..a3da360 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h @@ -6,7 +6,7 @@ #ifndef HEADER__AX12 #define HEADER__AX12 -#define AX12_BAUDRATE 1000000 +#define AX12_BAUDRATE 115200//1000000 #include <stdio.h> #include <stdlib.h> @@ -117,12 +117,20 @@ #define CMD_ACTION 2 // AX12 names -#define AX12_ARM1 1 -#define AX12_GRIP1 2 -#define AX12_ARM2 3 -#define AX12_GRIP2 4 -#define AX12_ARM3 5 -#define AX12_GRIP3 6 +#define AX12_ARM1 2 +#define AX12_GRIP1 3 +#define AX12_ARM2 4 +#define AX12_GRIP2 5 +#define AX12_ARM3 6 +#define AX12_GRIP3 7 + +// AX12 positions +#define GRIP_OPEN 250 +#define GRIP_CLOSE 435 +#define GRIP_RELEASE 350 + +#define ARM_GET 512 +#define ARM_CARRY 200 void ax12Init(void); void ax12SendPacket(uint8_t id, uint8_t instruction, uint8_t len, uint8_t *params); diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c index abf1662..66d0b06 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c @@ -203,8 +203,8 @@ void ax12Handler(BaseChannel *chp, int argc, char* argv[]) { uint8_t id, new_id; uint16_t pos, spd; - if (argc < 2) { - shellPrintLine(chp, "Usage : ax12 (config|goto|goto_delayed|action) id ..."); + if (argc < 1) { + shellPrintLine(chp, "Usage : ax12 (config|goto|goto_delayed|action|open|close) id ..."); return; } @@ -239,6 +239,153 @@ void ax12Handler(BaseChannel *chp, int argc, char* argv[]) { else if(strcmp(argv[0], "action") == 0) { ax12Action(id); } + else if(strcmp(argv[0], "open") == 0) { + if (argc == 1) { + ax12Goto(AX12_GRIP1, GRIP_OPEN, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP2, GRIP_OPEN, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP3, GRIP_OPEN, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Action(ID_BROADCAST); + } + else if (argc == 2) { + switch(argv[1][0]) { + case '1': + ax12Goto(AX12_GRIP1, GRIP_OPEN, 0, CMD_NOW); + break; + case '2': + ax12Goto(AX12_GRIP2, GRIP_OPEN, 0, CMD_NOW); + break; + case '3': + ax12Goto(AX12_GRIP3, GRIP_OPEN, 0, CMD_NOW); + break; + default: + shellPrintLine(chp, "Identifiant de pince entre 1 et 3"); + break; + } + } + else { + shellPrintLine(chp, "Usage : ax12 open [id]"); + } + } + else if(strcmp(argv[0], "close") == 0) { + if (argc == 1) { + ax12Goto(AX12_GRIP1, GRIP_CLOSE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP2, GRIP_CLOSE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP3, GRIP_CLOSE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Action(ID_BROADCAST); + } + else if (argc == 2) { + switch(argv[1][0]) { + case '1': + ax12Goto(AX12_GRIP1, GRIP_CLOSE, 0, CMD_NOW); + break; + case '2': + ax12Goto(AX12_GRIP2, GRIP_CLOSE, 0, CMD_NOW); + break; + case '3': + ax12Goto(AX12_GRIP3, GRIP_CLOSE, 0, CMD_NOW); + break; + default: + shellPrintLine(chp, "Identifiant de pince entre 1 et 3"); + break; + } + } + else { + shellPrintLine(chp, "Usage : ax12 close [id]"); + } + } + else if(strcmp(argv[0], "release") == 0) { + if (argc == 1) { + ax12Goto(AX12_GRIP1, GRIP_RELEASE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP2, GRIP_RELEASE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_GRIP3, GRIP_RELEASE, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Action(ID_BROADCAST); + } + else if (argc == 2) { + switch(argv[1][0]) { + case '1': + ax12Goto(AX12_GRIP1, GRIP_RELEASE, 0, CMD_NOW); + break; + case '2': + ax12Goto(AX12_GRIP2, GRIP_RELEASE, 0, CMD_NOW); + break; + case '3': + ax12Goto(AX12_GRIP3, GRIP_RELEASE, 0, CMD_NOW); + break; + default: + shellPrintLine(chp, "Identifiant de pince entre 1 et 3"); + break; + } + } + else { + shellPrintLine(chp, "Usage : ax12 close [id]"); + } + } + else if(strcmp(argv[0], "get") == 0) { + if (argc == 1) { + ax12Goto(AX12_ARM1, ARM_GET, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_ARM2, ARM_GET, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_ARM3, ARM_GET, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Action(ID_BROADCAST); + } + else if (argc == 2) { + switch(argv[1][0]) { + case '1': + ax12Goto(AX12_ARM1, ARM_GET, 0, CMD_NOW); + break; + case '2': + ax12Goto(AX12_ARM2, ARM_GET, 0, CMD_NOW); + break; + case '3': + ax12Goto(AX12_ARM3, ARM_GET, 0, CMD_NOW); + break; + default: + shellPrintLine(chp, "Identifiant de pince entre 1 et 3"); + break; + } + } + } + else if(strcmp(argv[0], "carry") == 0) { + if (argc == 1) { + ax12Goto(AX12_ARM1, ARM_CARRY, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_ARM2, ARM_CARRY, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Goto(AX12_ARM3, ARM_CARRY, 0, CMD_ACTION); + chThdSleepMilliseconds(5); + ax12Action(ID_BROADCAST); + } + else if (argc == 2) { + switch(argv[1][0]) { + case '1': + ax12Goto(AX12_ARM1, ARM_CARRY, 0, CMD_NOW); + break; + case '2': + ax12Goto(AX12_ARM2, ARM_CARRY, 0, CMD_NOW); + break; + case '3': + ax12Goto(AX12_ARM3, ARM_CARRY, 0, CMD_NOW); + break; + default: + shellPrintLine(chp, "Identifiant de pince entre 1 et 3"); + break; + } + } + else { + shellPrintLine(chp, "Usage : ax12 close [id]"); + } + } else { shellPrintLine(chp, "Usage : ax12 (config|goto|goto_delayed|action) ..."); return; diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h index 77fb7ed..021ef64 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h @@ -14,6 +14,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include "ch.h" #include "hal.h" hooks/post-receive -- krobot |