タコ 腕

Dependencies:   2017NHKpin_config FEP ikarashiMDC

Fork of NHK2017_octopus2 by NagaokaRoboticsClub_mbedTeam

Files at this revision

API Documentation at this revision

Comitter:
number_key
Date:
Tue Nov 28 17:58:04 2017 +0900
Parent:
54:857390145ac4
Commit message:
move

Changed in this revision

bot/bot.cpp Show annotated file Show diff for this revision Revisions of this file
bot/bot.h Show annotated file Show diff for this revision Revisions of this file
bot/elevator/elevator.cpp Show annotated file Show diff for this revision Revisions of this file
bot/elevator/elevator.h Show annotated file Show diff for this revision Revisions of this file
bot/sword_unit/sword_unit.cpp Show annotated file Show diff for this revision Revisions of this file
bot/tentacle_unit/tentacle_unit.cpp Show annotated file Show diff for this revision Revisions of this file
bot/tentacle_unit/tentacle_unit.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/bot.cpp
--- a/bot/bot.cpp	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/bot.cpp	Tue Nov 28 17:58:04 2017 +0900
@@ -8,11 +8,8 @@
     tentacle(&RS485Controller, &RS485),
     nishijoSword(&RS485Controller, &RS485),
     nishijo(&RS485Controller, &RS485),
-    receiveSuccessed(0),
-    debugSerial(USBTX, USBRX, 115200)
+    receiveSuccessed(0)
 {
-    debugSerial.printf("OK\r\n");
-
     tentacle.stop();
     nishijoSword.stop();
     nishijo.stop();
@@ -22,9 +19,9 @@
 void Bot::confirmPad()
 {
     receiveSuccessed = pad.receiveState();
-    if(!pad.getButton2(3) && !pad.getButton2(0)) {
-        powerSwitch = 0;
-    }
+    // if(!pad.getButton2(3) && !pad.getButton2(0)) {
+    //     powerSwitch = 0;
+    // }
     if(!receiveSuccessed) {
         tentacle.stop();
         nishijoSword.stop();
@@ -44,8 +41,8 @@
     if (!pad.getButton2(1)) nishijoSword.move(WIND_UP_SPEED);
     if(pad.getButton2(0) && pad.getButton2(1))  nishijoSword.move(0);
 
-    if (!pad.getButton2(3)) nishijo.move(-SWORD_SPEED);
-    if (!pad.getButton2(2)) nishijo.move(SWORD_SPEED);
+    if (!pad.getButton2(2)) nishijo.move(-SWORD_SPEED);
+    if (!pad.getButton2(3)) nishijo.move(SWORD_SPEED);
     if(pad.getButton2(2) && pad.getButton2(3))  nishijo.move(0);
   } else {
     tentacle.stop();
@@ -53,14 +50,3 @@
     nishijo.stop();
   }
 }
-
-void Bot::checkConnection()
-{
-  if(receiveSuccessed == 1) debugSerial.printf("ON\r\n");
-  else  debugSerial.printf("OFF");
-}
-
-void Bot::checkReceiveData()
-{
-  debugSerial.printf("%f %f %f %f\r\n",pad.getStick(0),pad.getStick(1),pad.getStick(2),pad.getStick(3));
-}
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/bot.h
--- a/bot/bot.h	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/bot.h	Tue Nov 28 17:58:04 2017 +0900
@@ -47,7 +47,6 @@
     Elevator nishijoSword;
     Sword nishijo;
     bool receiveSuccessed;
-    Serial debugSerial;
 };
 
 #endif//BOT_H
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/elevator/elevator.cpp
--- a/bot/elevator/elevator.cpp	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/elevator/elevator.cpp	Tue Nov 28 17:58:04 2017 +0900
@@ -1,17 +1,19 @@
 #include "elevator.h"
 
 Elevator::Elevator(DigitalOut* RS485Controller, Serial* RS485) :
-  elevatorMotor(RS485Controller, 1, 2, SM, RS485),
-  limit(LIMIT4, LIMIT5),
-  debugSerial(USBTX, USBRX, 115200)
+  elevatorMotor(RS485Controller, 0, 1, SM, RS485),
+  //limit(LIMIT2,LIMIT5)
+  front(LIMIT2),back(LIMIT5)
 {
 	elevatorMotor.braking = true;
 }
 
 void Elevator::move(float speed)
 {
-  if(speed*limit.getPosition() < 0)    speed = 0;
-  if(speed*limit.getPosition() > 0)    limit.resetPosition();
+  if(speed*front<0) speed=0;
+  if(speed*back>0) speed=0;
+  // if(speed*limit.getPosition() < 0)    speed = 0;
+  // if(speed*limit.getPosition() > 0)    limit.resetPosition();
 	elevatorMotor.setSpeed(speed);
 }
 
@@ -19,8 +21,3 @@
 {
   elevatorMotor.setSpeed(0);
 }
-
-void Elevator::debugPrint()
-{
-  debugSerial.printf("elevator:%d\r\f",limit.getPosition());
-}
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/elevator/elevator.h
--- a/bot/elevator/elevator.h	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/elevator/elevator.h	Tue Nov 28 17:58:04 2017 +0900
@@ -4,7 +4,7 @@
 #include "mbed.h"
 #include "pin_config.h"
 #include "ikarashiMDC.h"
-#include "limitSwitch.h"
+// #include "limitSwitch.h"
 
 
 class Elevator {
@@ -13,12 +13,12 @@
 
 	void move(float speed);
 	void stop();
-	void debugPrint();
 private:
 
 	ikarashiMDC elevatorMotor;
-	Limit limit;
-	Serial debugSerial;
+	// Limit limit;
+	DigitalIn front;
+	DigitalIn back;
 };
 
 #endif
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/sword_unit/sword_unit.cpp
--- a/bot/sword_unit/sword_unit.cpp	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/sword_unit/sword_unit.cpp	Tue Nov 28 17:58:04 2017 +0900
@@ -1,7 +1,7 @@
 #include "sword_unit.h"
 
 Sword::Sword(DigitalOut* RS485Controller, Serial* RS485) :
-  swordMotor(RS485Controller, 1, 0, SM, RS485)
+  swordMotor(RS485Controller, 0, 2, SM, RS485)
 {
 	swordMotor.braking = true;
 }
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/tentacle_unit/tentacle_unit.cpp
--- a/bot/tentacle_unit/tentacle_unit.cpp	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/tentacle_unit/tentacle_unit.cpp	Tue Nov 28 17:58:04 2017 +0900
@@ -2,11 +2,13 @@
 
 Tentacle::Tentacle(DigitalOut* RS485Controller, Serial* RS485) :
 	tentacleMotor({
-    {RS485Controller, 1, 3, SM, RS485},
-    {RS485Controller, 1, 1, SM, RS485},
+    {RS485Controller, 0, 3, SM, RS485},
+    {RS485Controller, 0, 0, SM, RS485},
   }),
-  right(LIMIT0, LIMIT1),left(LIMIT2,LIMIT3),
-	debugSerial(USBTX, USBRX, 115200)
+	// right(LIMIT1,LIMIT0),
+  // left(LIMIT3,LIMIT4)
+	front({{LIMIT1},{LIMIT3}}),
+	back({{LIMIT0},{LIMIT4}})
 {
 	tentacleMotor[0].braking = true;
   tentacleMotor[1].braking = true;
@@ -14,15 +16,19 @@
 
 void Tentacle::rightMove(float speed)
 {
-  /*if(speed*right.getPosition() < 0)    speed = 0;
-  if(speed*right.getPosition() > 0)    right.resetPosition();*/
+	if(speed*front[0]>0) speed=0;
+  if(speed*back[0]<0) speed=0;
+  // if(speed*right.getPosition() < 0)    speed = 0;
+  // if(speed*right.getPosition() > 0)    right.resetPosition();
 	tentacleMotor[0].setSpeed(speed);
 }
 
 void Tentacle::leftMove(float speed)
 {
-  /*if(speed*left.getPosition() < 0)    speed = 0;
-  if(speed*left.getPosition() > 0)    left.resetPosition();*/
+	if(speed*front[1]>0) speed=0;
+  if(speed*back[1]<0) speed=0;
+  // if(speed*left.getPosition() < 0)    speed = 0;
+  // if(speed*left.getPosition() > 0)    left.resetPosition();
   tentacleMotor[1].setSpeed(speed);
 }
 
@@ -31,8 +37,3 @@
   tentacleMotor[0].setSpeed(0);
   tentacleMotor[1].setSpeed(0);
 }
-
-void Tentacle::debugPrint()
-{
-	debugSerial.printf("right:%d left:%d\r\n",right.getPosition(),left.getPosition());
-}
diff -r 857390145ac4 -r ccf2ac8f6f32 bot/tentacle_unit/tentacle_unit.h
--- a/bot/tentacle_unit/tentacle_unit.h	Thu Nov 23 14:59:59 2017 +0900
+++ b/bot/tentacle_unit/tentacle_unit.h	Tue Nov 28 17:58:04 2017 +0900
@@ -4,7 +4,7 @@
 #include "mbed.h"
 #include "pin_config.h"
 #include "ikarashiMDC.h"
-#include "limitSwitch.h"
+// #include "limitSwitch.h"
 
 
 class Tentacle {
@@ -14,13 +14,13 @@
 	void rightMove(float speed);
 	void leftMove(float speed);
 	void stop();
-	void debugPrint();
 private:
 
 	ikarashiMDC tentacleMotor[2];
-	Limit right;
-	Limit left;
-	Serial debugSerial;
+	// Limit right;
+	// Limit left;
+	DigitalIn front[2];
+	DigitalIn back[2];
 };
 
 #endif
diff -r 857390145ac4 -r ccf2ac8f6f32 main.cpp
--- a/main.cpp	Thu Nov 23 14:59:59 2017 +0900
+++ b/main.cpp	Tue Nov 28 17:58:04 2017 +0900
@@ -3,13 +3,14 @@
 #include "bot.h"
 
 Bot OCTOPUS;
-Serial pc(USBTX, USBRX, 115200);
+DigitalOut led(LED1);
 
 int main()
 {
+  led = true;
     while(1) {
+        led = !led;
         OCTOPUS.confirmPad();
         OCTOPUS.controllMech();
-        pc.printf("loop\r\n");
     }
 }