├── Code ├── CPP_Code │ ├── Bluetooth_Code.cpp │ ├── EEPROM_Flush_Code.cpp │ ├── Sensor_Code.cpp │ ├── Stable_Movement_Code.cpp │ └── Unstable_Movement_Code.cpp ├── Communication_Code │ ├── Communication_Code.py │ └── __pycache__ │ │ ├── Communication_Code.cpython-35.pyc │ │ └── desktop.ini ├── Control_Code │ └── Control_Code.ino └── Joystick_Code │ ├── Joystick_Code.py │ └── __pycache__ │ ├── Joystick_Code.cpython-35.pyc │ └── desktop.ini ├── Design_Files ├── Electrical_Design │ ├── Arduino_Design │ │ ├── Alimentation.SLDPRT │ │ ├── Arduino UNO.SLDASM │ │ ├── Buton.SLDPRT │ │ ├── Chip.SLDASM │ │ ├── Condensateur.SLDPRT │ │ ├── Crystal.SLDPRT │ │ ├── ICSP.SLDPRT │ │ ├── PCB UNO.SLDPRT │ │ ├── Pins Connection Shield.SLDPRT │ │ ├── Resistance.SLDPRT │ │ ├── Small Chip.SLDPRT │ │ ├── Transistor.SLDPRT │ │ ├── USB.SLDPRT │ │ ├── base chip.SLDPRT │ │ ├── box.SLDPRT │ │ ├── foot (big chip).SLDPRT │ │ └── foot (chip).SLDPRT │ └── Circuit_Design │ │ ├── Circuit_Flowchart.png │ │ ├── Fish_Circuitry.fzz │ │ ├── Fish_Circuitry.png │ │ └── Fritzing.ino └── Mechanical_Design │ ├── Servo_Design │ ├── Servo Motor (SG90).SLDPRT │ └── Servo_Horn.SLDPRT │ └── Structure_Design │ ├── Body.SLDPRT │ ├── Body_2.SLDPRT │ ├── Body_3.SLDPRT │ ├── Body_4.SLDPRT │ ├── Fish_Assembly.PDF │ ├── Fish_Assembly.SLDASM │ ├── Fish_Assembly.SLDDRW │ ├── Fish_Assembly_Dimensioned.PDF │ ├── Fish_Assembly_Snapshot.png │ └── Tail_Fin.SLDPRT ├── README.md └── build-log.md /Code/CPP_Code/Bluetooth_Code.cpp: -------------------------------------------------------------------------------- 1 | //This code is uded to communicate over bletooth with the Arduino. 2 | //loop and setup are commented out because the code is seen as C++ code by the Arduino compiler. 3 | //For detailed [LOG] and [INFO] have a look at the Stable_Movement.cpp code. 4 | 5 | //---------------------------------------------------------------------------------------------- 6 | 7 | 8 | #include 9 | //#include 10 | void BLUE_COM(){ 11 | Servo motor1, motor2, motor3; 12 | //void setup(){ 13 | motor1.attach(9); 14 | motor2.attach(10); 15 | motor3.attach(11); 16 | Serial.begin(9600); 17 | pinMode(13,OUTPUT); 18 | //j=EEPROM_FLUSH(); 19 | //} 20 | //void loop(){ 21 | int i; 22 | if(Serial.available()){ 23 | //if(j>0)Serial.println("[INFO] EEPROM has been flushed"); 24 | //Serial.println("[INFO] Connection established");} 25 | char VAL; 26 | VAL=Serial.read(); 27 | if(VAL=='1'){ 28 | //Serial.println("[STATUS] LED is ON"); 29 | digitalWrite(13,HIGH); 30 | for(i=0;i<=90;i++){ 31 | 32 | motor1.write(i); 33 | motor2.write(i); 34 | motor3.write(i); 35 | delay(10); 36 | } 37 | } 38 | else if(VAL=='0'){ 39 | digitalWrite(13,LOW); 40 | //Serial.println("[STATUS] LED is OFF"); 41 | for(i=90;i>=0;i--){ 42 | motor1.write(i); 43 | motor2.write(i); 44 | motor3.write(i); 45 | delay(10); 46 | } 47 | }} 48 | //} -------------------------------------------------------------------------------- /Code/CPP_Code/EEPROM_Flush_Code.cpp: -------------------------------------------------------------------------------- 1 | //Date: 31/05/2018 2 | //This code is a part of the robotic fish project. 3 | //EEPROM (Electrically Erasable Programmable Read Only Memory) onboard the Arduino needs to be flushed. 4 | //sometimes to get rid of values written in it. 5 | //Values might hinder with the functioning of bluetooth-communications module. 6 | //This code is called by the bluetooth module. 7 | 8 | //For detailed [LOG] and [INFO] have a look at the Stable_Movement.cpp code. 9 | 10 | //-----------------------------------------------------------------------------------------------------// 11 | 12 | #include 13 | #include 14 | #include 15 | int memoryIncrement;int incrementChecker=0; 16 | int EEPROM_FLUSH(){ 17 | pinMode(13,OUTPUT); 18 | // Serial.begin(9600); 19 | for(memoryIncrement=0;memoryIncrement0)Serial.println("EEPROM has been flushed"); 88 | Serial.print("Distance: "); Serial.println(reading); 89 | //This condition checks if obstacle has been detected. In this case, no obstacle. 90 | if(reading>=10){ 91 | 92 | //Function S has been triggered here. 93 | func_s(); 94 | } 95 | 96 | //Obstacle has been detected by the sensor in this case. 97 | else if(reading<10){ 98 | 99 | //Function C has been triggered in this case. 100 | func_c(); 101 | } 102 | } 103 | --------------------------------------------------------------------------------------------- 104 | 105 | END OF REPLACED ARDUINO CODE. 106 | 107 | --------------------------------------------------------------------------------------------- 108 | 109 | //This is executed when the obstacle has been detected on the left. 110 | //Each joint has been given an angle of 60 degrees. As we move away from n=1. each angle gets multiplied by 2 111 | //90 degrees is used as the median position, i.e. starting position. 112 | //For S and C movements median is taken as 90 degrees. 113 | 114 | /*Four types of movements are employed in this case: 115 | 1. S_MOVE()-Used for forward movement (Top view of the fish looks like an S) 116 | 2. C_MOVE()-Used for right movement, away from the obstacle 117 | 3. C_MOVE_RIGHT()-Same as C_MOVE() 118 | 4. C_MOVE_LEFT()-Used for left movement, away from the obstacle 119 | 120 | ----------------------------------------------------------------------------------------------*/ 121 | 122 | #include 123 | Servo motor_1,motor_2,motor_3; 124 | void S_MOVE(){ 125 | int angleIncrementer=90; 126 | for(angleIncrementer=90;angleIncrementer<=120;angleIncrementer++){ 127 | motor_1.write(angleIncrementer); 128 | motor_2.write(angleIncrementer); 129 | motor_3.write(angleIncrementer); 130 | delay(10); 131 | } 132 | 133 | for(angleIncrementer=120;angleIncrementer>=60;angleIncrementer--){ 134 | motor_1.write(angleIncrementer); 135 | motor_2.write(angleIncrementer); 136 | motor_3.write(angleIncrementer); 137 | delay(10); 138 | } 139 | 140 | for(angleIncrementer=60;angleIncrementer<=90;angleIncrementer++){ 141 | motor_1.write(angleIncrementer); 142 | motor_2.write(angleIncrementer); 143 | motor_3.write(angleIncrementer); 144 | delay(10); 145 | } 146 | } 147 | 148 | void C_MOVE(){ 149 | 150 | //Serial.println("You have entered the C - Right Function"); 151 | 152 | int angleIncrementer=90; 153 | for(angleIncrementer=90;angleIncrementer<=120;angleIncrementer++){ 154 | motor_1.write(angleIncrementer+5); 155 | motor_2.write(angleIncrementer); 156 | motor_3.write(angleIncrementer); 157 | delay(10); 158 | } 159 | 160 | for(angleIncrementer=120;angleIncrementer>=90;angleIncrementer--){ 161 | motor_1.write(angleIncrementer-5); 162 | motor_2.write(angleIncrementer); 163 | motor_3.write(angleIncrementer); 164 | delay(10); 165 | } 166 | } 167 | 168 | void C_MOVE_RIGHT(){ 169 | 170 | //Serial.println("You have entered the C - Right Function"); 171 | 172 | int angleIncrementer=90; 173 | for(angleIncrementer=90;angleIncrementer<=120;angleIncrementer++){ 174 | motor_1.write(angleIncrementer+5); 175 | motor_2.write(angleIncrementer); 176 | motor_3.write(angleIncrementer); 177 | delay(10); 178 | } 179 | 180 | for(angleIncrementer=120;angleIncrementer>=90;angleIncrementer--){ 181 | motor_1.write(angleIncrementer-5); 182 | motor_2.write(angleIncrementer); 183 | motor_3.write(angleIncrementer); 184 | delay(10); 185 | } 186 | } 187 | 188 | void C_MOVE_LEFT(){ 189 | 190 | //Serial.println("You have entered the C - Left Function"); 191 | 192 | int angleIncrementer=90; 193 | for(angleIncrementer=90;angleIncrementer>=60;angleIncrementer--){ 194 | motor_1.write(angleIncrementer+5); 195 | motor_2.write(angleIncrementer); 196 | motor_3.write(angleIncrementer); 197 | delay(10); 198 | } 199 | 200 | for(angleIncrementer=60;angleIncrementer<=90;angleIncrementer++){ 201 | motor_1.write(angleIncrementer-5); 202 | motor_2.write(angleIncrementer); 203 | motor_3.write(angleIncrementer); 204 | delay(10); 205 | } 206 | } -------------------------------------------------------------------------------- /Code/CPP_Code/Unstable_Movement_Code.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | Servo motor_1,motor_2,motor_3; 3 | int angleIncrementer=90; 4 | void S_MOVE(){ 5 | for(angleIncrementer=90;angleIncrementer<=150;angleIncrementer++){ 6 | motor_1.write(angleIncrementer); 7 | delay(10); 8 | motor_1.detach(); 9 | } 10 | for(angleIncrementer=150;angleIncrementer>=0;angleIncrementer--){ 11 | motor_1.write(angleIncrementer); 12 | delay(10); 13 | motor_1.detach(); 14 | } 15 | for(angleIncrementer=0;angleIncrementer<=90;angleIncrementer++){ 16 | motor_1.write(angleIncrementer); 17 | delay(10); 18 | motor_1.detach(); 19 | } 20 | } 21 | void C_MOVE(){ 22 | 23 | } 24 | void C_MOVE_RIGHT(){ 25 | 26 | } 27 | void C_MOVE_LEFT(){ 28 | 29 | } -------------------------------------------------------------------------------- /Code/Communication_Code/Communication_Code.py: -------------------------------------------------------------------------------- 1 | #serial is used to communicate with the COM4 to which the Arduino is connected. 2 | 3 | #Note: For detailed [LOG] and [INFO] have a look at the Stable_Movement.cpp code. 4 | 5 | #------------------------------------------------------------------------------# 6 | 7 | import serial 8 | def byte_sender(var,ser): 9 | var_bytes=str.encode(var) 10 | print(type(var_bytes)) 11 | ser.write(var_bytes) -------------------------------------------------------------------------------- /Code/Communication_Code/__pycache__/Communication_Code.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Code/Communication_Code/__pycache__/Communication_Code.cpython-35.pyc -------------------------------------------------------------------------------- /Code/Communication_Code/__pycache__/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /Code/Control_Code/Control_Code.ino: -------------------------------------------------------------------------------- 1 | /* Flow: 2 | * Autonomous Mode - without controller (not implemented in this phase). 3 | * Borrow functions from Stable_Code for S/C Movement for Bluetooth Controlled Motion. 4 | * Borrow fucntions from Stable_Code for S/C Movement for Autonomous Motion 5 | 6 | [LOG] Date: 31/05/2018 7 | [LOG] -EEPROM Code has been implemented. 8 | [LOG] -Movement Code has been implemented. 9 | [LOG] -Bluetooth Code has been implemented. 10 | [LOG] -Sensor Code has been implemented. 11 | [LOG] -Detection has been achieved. 12 | [LOG] -Conditional Movement has been acheived. 13 | 14 | 15 | [INFO] -Here, the number of joints is assumed as 3. 16 | [INFO] -Wait for 5 seconds (approximate) before sending commands through controller. 17 | [INFO] -EEPROM Flush has to take place before operation. 18 | [INFO] -COM4 is used as default communication port for bluetooth. 19 | [INFO] -COM3 is used as default communicaation port for Serial Communication. 20 | */ 21 | 22 | #include 23 | #include 24 | //#include 25 | #include 26 | #include 27 | void setup() { 28 | Serial.begin(9600); 29 | motor_1.attach(9); 30 | motor_2.attach(10); 31 | motor_3.attach(11); 32 | EEPROM_FLUSH(); 33 | } 34 | 35 | void loop() { 36 | int SENSOR_VAR=SENSOR_READ(); 37 | if(SENSOR_VAR>=5){ 38 | if(Serial.available()){ 39 | int BLUETOOTH_VAR; 40 | BLUETOOTH_VAR=Serial.read(); 41 | if(BLUETOOTH_VAR=='1'){ 42 | S_MOVE();} 43 | else if(BLUETOOTH_VAR=='2'){ 44 | C_MOVE_RIGHT();} 45 | else if(BLUETOOTH_VAR=='3'){ 46 | C_MOVE_LEFT();} 47 | } 48 | } 49 | else if(SENSOR_VAR<5){ 50 | C_MOVE();} 51 | } 52 | -------------------------------------------------------------------------------- /Code/Joystick_Code/Joystick_Code.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import serial 3 | import time 4 | 5 | #sys is used as a part of cross directory function import. 6 | import sys 7 | 8 | 9 | #Opening the Serial port here for communication with the Arduino. 10 | #COM4 is the standard for bluetooth communication 11 | ser=serial.Serial('COM4',9600) 12 | 13 | #This line is used to enable cross directory importing of libraries/functions 14 | sys.path.insert(0,'F:/Google Drive/IISc Files/Code/Communication_Code/') 15 | 16 | #Importing the byte_sender from Communication_Code 17 | from Communication_Code import byte_sender 18 | 19 | # Define some colors 20 | BLACK = ( 0, 0, 0) 21 | WHITE = ( 255, 255, 255) 22 | 23 | # This is a simple class that will help us print to the screen 24 | # It has nothing to do with the joysticks, just outputting the 25 | # information. 26 | class TextPrint: 27 | def __init__(self): 28 | self.reset() 29 | self.font = pygame.font.Font(None, 20) 30 | 31 | def print(self, screen, textString): 32 | textBitmap = self.font.render(textString, True, BLACK) 33 | screen.blit(textBitmap, [self.x, self.y]) 34 | self.y += self.line_height 35 | 36 | def reset(self): 37 | self.x = 10 38 | self.y = 10 39 | self.line_height = 15 40 | 41 | def indent(self): 42 | self.x += 10 43 | 44 | def unindent(self): 45 | self.x -= 10 46 | 47 | pygame.init() 48 | 49 | # Set the width and height of the screen [width,height] 50 | size = [500, 700] 51 | screen = pygame.display.set_mode(size) 52 | 53 | pygame.display.set_caption("My Game") 54 | 55 | #Loop until the user clicks the close button. 56 | done = False 57 | 58 | # Used to manage how fast the screen updates 59 | clock = pygame.time.Clock() 60 | 61 | # Initialize the joysticks 62 | pygame.joystick.init() 63 | 64 | # Get ready to print 65 | textPrint = TextPrint() 66 | 67 | # -------- Main Program Loop ----------- 68 | while done==False: 69 | # EVENT PROCESSING STEP 70 | for event in pygame.event.get(): # User did something 71 | if event.type == pygame.QUIT: # If user clicked close 72 | done=True # Flag that we are done so we exit this loop 73 | 74 | # Possible joystick actions: JOYAXISMOTION JOYBALLMOTION JOYBUTTONDOWN JOYBUTTONUP JOYHATMOTION 75 | '''if event.type == pygame.JOYBUTTONDOWN: 76 | print("Joystick button pressed.") 77 | if event.type == pygame.JOYBUTTONUP: 78 | print("Joystick button released.")''' 79 | 80 | 81 | # DRAWING STEP 82 | # First, clear the screen to white. Don't put other drawing commands 83 | # above this, or they will be erased with this command. 84 | screen.fill(WHITE) 85 | textPrint.reset() 86 | 87 | # Get count of joysticks 88 | joystick_count = pygame.joystick.get_count() 89 | 90 | textPrint.print(screen, "Number of joysticks: {}".format(joystick_count) ) 91 | textPrint.indent() 92 | 93 | # For each joystick: 94 | for i in range(joystick_count): 95 | joystick = pygame.joystick.Joystick(i) 96 | joystick.init() 97 | 98 | textPrint.print(screen, "Joystick {}".format(i) ) 99 | textPrint.indent() 100 | 101 | # Get the name from the OS for the controller/joystick 102 | name = joystick.get_name() 103 | textPrint.print(screen, "Joystick name: {}".format(name) ) 104 | 105 | # Usually axis run in pairs, up/down for one, and left/right for 106 | # the other. 107 | axes = joystick.get_numaxes() 108 | textPrint.print(screen, "Number of axes: {}".format(axes) ) 109 | textPrint.indent() 110 | for i in range( 0,2 ): 111 | axis = joystick.get_axis( i ) 112 | textPrint.print(screen, "Axis {} value: {:>6.3f}".format(i, axis) ) 113 | if((i==0)&(axis>=0.50)): 114 | print("[INFO] Fish is moving to the right") 115 | time.sleep(.5) 116 | #Character '2' is understood as right movement by the Arduino. 117 | var='2' 118 | #byte_sender is used to encode char '2' into bytes and flushes it to the Arduino. 119 | byte_sender(var,ser) 120 | 121 | elif((i==0)&(axis<=-0.50)): 122 | print("[INFO] Fish is moving to the left") 123 | time.sleep(.5) 124 | #Character '3' us understood as left movement by the Arduino. 125 | var='3' 126 | byte_sender(var,ser) 127 | if((i==1)&(axis<=-0.5)): 128 | print("[INFO] Fish is moving forward") 129 | time.sleep(.5) 130 | #Character '1' is understood as forward movement by the Arduino. 131 | var='1' 132 | byte_sender(var,ser) 133 | textPrint.unindent() 134 | 135 | buttons = joystick.get_numbuttons() 136 | textPrint.print(screen, "Number of buttons: {}".format(buttons) ) 137 | textPrint.indent() 138 | 139 | for i in range( buttons ): 140 | button = joystick.get_button( i ) 141 | textPrint.print(screen, "Button {:>2} value: {}".format(i,button) ) 142 | textPrint.unindent() 143 | 144 | # Hat switch. All or nothing for direction, not like joysticks. 145 | # Value comes back in an array. 146 | hats = joystick.get_numhats() 147 | textPrint.print(screen, "Number of hats: {}".format(hats) ) 148 | textPrint.indent() 149 | 150 | for i in range( hats ): 151 | hat = joystick.get_hat( i ) 152 | textPrint.print(screen, "Hat {} value: {}".format(i, str(hat)) ) 153 | textPrint.unindent() 154 | 155 | textPrint.unindent() 156 | 157 | 158 | # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT 159 | 160 | # Go ahead and update the screen with what we've drawn. 161 | pygame.display.flip() 162 | 163 | # Limit to 20 frames per second 164 | clock.tick(20) 165 | 166 | # Close the window and quit. 167 | # If you forget this line, the program will 'hang' 168 | # on exit if running from IDLE. 169 | pygame.quit () -------------------------------------------------------------------------------- /Code/Joystick_Code/__pycache__/Joystick_Code.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Code/Joystick_Code/__pycache__/Joystick_Code.cpython-35.pyc -------------------------------------------------------------------------------- /Code/Joystick_Code/__pycache__/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Alimentation.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Alimentation.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Arduino UNO.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Arduino UNO.SLDASM -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Buton.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Buton.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Chip.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Chip.SLDASM -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Condensateur.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Condensateur.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Crystal.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Crystal.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/ICSP.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/ICSP.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/PCB UNO.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/PCB UNO.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Pins Connection Shield.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Pins Connection Shield.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Resistance.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Resistance.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Small Chip.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Small Chip.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/Transistor.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/Transistor.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/USB.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/USB.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/base chip.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/base chip.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/box.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/box.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/foot (big chip).SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/foot (big chip).SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Arduino_Design/foot (chip).SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Arduino_Design/foot (chip).SLDPRT -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Circuit_Design/Circuit_Flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Circuit_Design/Circuit_Flowchart.png -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Circuit_Design/Fish_Circuitry.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Circuit_Design/Fish_Circuitry.fzz -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Circuit_Design/Fish_Circuitry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Circuit_Design/Fish_Circuitry.png -------------------------------------------------------------------------------- /Design_Files/Electrical_Design/Circuit_Design/Fritzing.ino: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Electrical_Design/Circuit_Design/Fritzing.ino -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Servo_Design/Servo Motor (SG90).SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Servo_Design/Servo Motor (SG90).SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Servo_Design/Servo_Horn.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Servo_Design/Servo_Horn.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Body.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Body.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Body_2.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Body_2.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Body_3.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Body_3.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Body_4.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Body_4.SLDPRT -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.PDF -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.SLDASM -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.SLDDRW: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly.SLDDRW -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly_Dimensioned.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly_Dimensioned.PDF -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly_Snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Fish_Assembly_Snapshot.png -------------------------------------------------------------------------------- /Design_Files/Mechanical_Design/Structure_Design/Tail_Fin.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SarthakJShetty/Fish/25b4d546d0bdabc0468d3c07be44d0abb467a42d/Design_Files/Mechanical_Design/Structure_Design/Tail_Fin.SLDPRT -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Open Source Robotic Fish 3 | 4 | This repository is dedicated to the development of the predatory robotic fish, developed at the [Theoretical Ecology and Evolution Laboratory](https://teelabiisc.wordpress.com/ "TEE-Lab, IISc"), [Indian Institute of Science](https://www.iisc.ac.in "Indian Institute of Science, Bengaluru"). 5 | 6 | ### :warning: Code is buggy :warning: 7 | 8 | ### Introduction: 9 | The robotic fish developed was used to study the aggregation and swarming characteristics of the Serpae tetra species of fish. 10 | 11 | ### Construction: 12 | - The body of the Fish is made of extruded polystyrene (thermocol). The [design](https://github.com/SarthakJShetty/Fish/tree/master/Design_Files/Mechanical_Design/Structure_Design "Mechanical Designs") was made in SolidWorks, and carved using a crafting blade. 13 | 14 | - The Fish is maneuvered using a joystick controller through the [pygame](Pygame.org "pygame") library for Python. A list of supported controllers is given [here](https://www.pygame.org/docs/ref/joystick.html "pygame"). We have tried out a number of joysticks, such as the [XBox 360 controller](https://www.amazon.com/Xbox-360-Wireless-Controller-Packaging-Black/dp/B073WJCQGT/ref=sr_1_4?ie=UTF8&qid=1530160595&sr=8-4&keywords=xbox+360+controller "XBox 360 controller"), and the [Logitech Extreme 3D Pro Gamepad](https://www.amazon.com/Extreme-3D-Pro-Joystick-Windows/dp/B00009OY9U/ref=sr_1_1?s=videogames&ie=UTF8&qid=1530160648&sr=1-1&keywords=logitech+extreme+pro "Logitech Extreme 3D Pro"). 15 | 16 | - The Fish is controlled through an Arduino UNO, which communicates with the computer running ```pygame``` through a [Bluetooth module](https://www.amazon.com/HiLetgo%C2%AE-Wireless-Bluetooth-Transceiver-Arduino/dp/B071YJG8DR/ref=sr_1_1_sspa?ie=UTF8&qid=1530698951&sr=8-1-spons&keywords=hc05&psc=1 "HC-05 Bluetooth Module"), mounted on it's head. 17 | 18 | - A [SHARP Distance Sensor GP2Y0A21YK0F](https://www.pololu.com/category/79/sharp-distance-sensors "Sharp Distance Sensor GP2Y0A21YK0F") was used to judge the distance between the fish and obstacles up ahead. 19 | 20 | - The Fish was encased in a layer of polythene to ensure waterproofing while operating underwater. Specifically, the joints between successive links was encased in a skin-like layer of polythene. 21 | 22 | - The necessary propelling movements were provided by a series of 3 [Tower SG90 Servo Motors](https://servodatabase.com/servo/towerpro/sg90 "Tower S690 Servo Motors"). 23 | 24 | - A pair of [9V batteries](https://www.amazon.com/AmazonBasics-Everyday-Alkaline-Batteries-8-Pack/dp/B00MH4QM1S "9V Batteries") were used in series to provide the necessary electric power for the operation of the fish. 25 | 26 | ### Fritzing Diagram: 27 |

Fritzing Diagram

28 |
Fig 1. Fritzing diagram of electrical wiring. 29 | Note: 3.7V LiPo is for representation purposes only.
30 | 31 | ### SolidWorks Model: 32 |

SolidWorks Model

33 |
Fig 2. SolidWorks assembly of mechanical structure.
34 | 35 | ### Command Flowchart: 36 |

Command flowchart

37 |
Fig 3. Flowchart of commands.
38 | 39 | ### Working: 40 | 1. The electrical connections are made as shown in the Fritzing diagram. 41 | 42 | 2. Once the connections are made and checked (to prevent short circuiting underwater!), the batteries are connected to the battery headers provided in the circuit. 43 | 44 | 3. The SHARP sensors are obstructed to check if the necessary commands are executed (in this case the ```C_MOVE()``` function would be executed). 45 | 46 | 4. Once the [Joystick.py](https://github.com/SarthakJShetty/fish/tree/master/Code/Joystick_Code/Joystick_Code.py) has been executed, wait for 5 seconds as the [EEPROM_Code.cpp](https://github.com/SarthakJShetty/Fish/tree/master/Code/CPP_Code/EEPROM_Flush_Code.cpp) script executes and flushes the EEPROM on-board the UNO to prevent interferences from previous stored values. 47 | 48 | 5. The Fish can be maneuvered as required using the left analog stick of the joystick. Three movements are possible: 49 | - [Forward](https://github.com/SarthakJShetty/Fish/tree/master/Code/CPP_Code/Stable_Movement_Code.cpp)- The Fish moves in an S-type movement. 50 | - [Left](https://github.com/SarthakJShetty/Fish/tree/master/Code/CPP_Code/Stable_Movement_Code.cpp)- The Fish moves in a C-type movement, deflecting towards the left. 51 | - [Right](https://github.com/SarthakJShetty/Fish/tree/master/Code/CPP_Code/Stable_Movement_Code.cpp)- The Fish moves in a C-type movement, deflecting towards the right. 52 | - [Obstacle Avoidance](https://github.com/SarthakJShetty/Fish/tree/master/Code/CPP_Code/Stable_Movement_Code.cpp)- The Fish moves in a C-type movement, deflecting towards the left. 53 | 54 | 6. The Fish operates either through the controls of the user, through the joystick, or it continuously moves in an S-type fashion, until it encounters an obstacle, thereafter which it executes a C-type movement. 55 | 56 | ### Build-log: 57 | You can check out the build-log for a detailed progress report. 58 | 59 | ### Known Issues: 60 | 61 | 1. Occasionally, the Bluetooth module on-board losses communication link with the Bluetooth on the PC. When this happens, close the pygame dialog and rerun the Joystick_Code.py script to establish control once again (this issue has now been resolved by connecting the Bluetooth module to a 3.3V voltage supply.) 62 | 63 | 2. The Arduino will reboot, if sufficient power is not provided. Thus, we suggest the use of LiPo batteries to provide a more reliable and lasting power source. We are currently using 12V, 2000mAh LiPo batteries (testing this right now). 64 | 65 | 3. Communication link between the UNO and the computer will not be active until the `EEPROM_Flush_Code.cpp` has been executed (approx 5 seconds), thereafter which the LED on the UNO associated with GPIO pin 13 will glow a bright orange (depending on the make of the Arduino board). -------------------------------------------------------------------------------- /build-log.md: -------------------------------------------------------------------------------- 1 | ### Progress Log: 2 | 3 | - Date: 28/05/2018 4 | - Just wrote code. 5 | - Yet to implement on Arduino. 6 | - Will be doing that tomorrow. 7 | - Need to add a README. 8 | 9 | - Date: 29/05/2018 10 | - Code now works with sensor. 11 | - Added a piece of code to convert volts to distance. 12 | 13 | - Date: 60/05/2018 14 | - Updated Bluetooth Code. 15 | - Bluetooth now works over COM4 port. 16 | - ```println()``` statements look much cleaner now 17 | 18 | - Date: 31/05/2018 19 | - Added EEPROM flush. Not much of an improvement. 20 | - Bluetooth has not been integrated here. 21 | - Bluetooth code has been introduced, albeit very buggy as of now. 22 | 23 | - Date: 08/05/2018 24 | - Joystick can be used to control the fish now. Attempting on a wired controller though. 25 | - Interference. Need to upload a SLAVE communication. 26 | 27 | - Date: 09/06/2018 28 | - DualShock3 replaced with XBox 360 Wireless knockoff controller. 29 | - Works much better now. 30 | - SLAVE protocol has been established. Works much better. 31 | 32 | - Date: 10/06/2018 33 | - BLuetooth module has been converted into a one-way system, i.e. slave communication 34 | - RX/TX can be connected simultaneously, no obstruction to communication from controller. 35 | 36 | - Date: 13/06/2018 37 | - Code has been successfully tested on fish. 38 | - This code has been converted into a ```.cpp``` library, to make the Arduino code cleaner. 39 | 40 | - Date: 15/06/2018 41 | - The thermocol has ripped. Adhesive applied and trying to fix it. 42 | - Code seems to be working well. Angles seem to be too big though. 43 | 44 | - Date: 03/07/2018 45 | - Embargo due to mechanical issues. 46 | - A polythene wrapper has been used as a final layer for waterproofing the structure. 47 | - The issue is with fit. Almost fixed it. 48 | - Should have a great Fish by this weekend. Fingers crossed. 49 | - Try to code a more harmonic motion of Fish body. 50 | 51 | - Date: 09/07/2018 52 | - Movement seems to work well, even without harmonic motion integration. 53 | - Important:```ICSP``` pins should not be used for power supply. ```V(in)``` pin solely supports 5V. ```V(in)``` should be used, along with corresponding ```GND``` pin. 54 | - Looking forward to 3D printing some of the components. 55 | 56 | - Date: 14/07/2018 57 | - Plastic has been bound. 58 | - Compensations have been provided. 59 | - Waiting for adhesive to dry up. 60 | 61 | - Date: 15/07/2018 62 | - Rubber based adhesive used to fill the last remaining holes. 63 | - Adhesive also used to coat the battery. Multiple times. 64 | - Tail fin and fish design updated. Looks less like a kayaking paddle now. 65 | 66 | - Date: 16/07/2018 67 | - Fish works great with plastic binding now. 68 | - Movements are unforced. Feels smooth. Finally this works. 69 | - Filled the last remaining slots and gaps in the plastic. Will cut out a cover for the Sharp sensor. 70 | - 3D printing of fin underway. We're almost there. 71 | 72 | - Date: 17/07/2018 73 | - Solved the great repository debacle. 74 | - Almost done. 3D printing yet to be completed. 75 | 76 | - Date: 13/08/2018 77 | - Waterproofing works (almost; 90%ish). 78 | - Fin has been 3D printed. Works great. 79 | - Had a buoyancy debacle. Almost sorted. 80 | - If waterproofing is fixed, then we can begin the actual testing. 81 | 82 | - Date: 22/08/2018 83 | - Iterated through at least 8 skins designs for waterproofing. 84 | - Currently testing the 9th one. This should work. 85 | - To vary buoyancy, cast iron blocks of different weights can be used. 86 | - Currently using a 660 grams one that provides a above surface height of about 8mm. 87 | - Just about right for the antennae to pop up from the surface. 88 | 89 | Date: 17/09/2018 90 | - Skin is mostly impenetrable and sealed. 91 | - An average height of 3 cm penetrates the skin. 92 | - Weight has been optimized to 498gm. Buoyancy is just right. 93 | - Will test with air-tight enclosure for switch next. Should be ready by Thursday. --------------------------------------------------------------------------------