Project tutorial
Swarm Bots: Assembly and Co-operative Transport

Swarm Bots: Assembly and Co-operative Transport

Objective of the Swarm-bots project is to study controlling the bot so assemble themselves, avoid obstacle and synchronization between bots.

  • 9,146 views
  • 13 comments
  • 40 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
The master and slave are two arduino based bots, which cooperate together to carry out the desired task- in our case transportation of heavy objects. The master controls the movement and actions of the slave through the RF module.
×1
Screen shot 2019 03 20 at 2 38 27 pm fqndazqcx1
1Sheeld
Gamepad control application in 1sheeld is use to control master bot.
×1
nRF24 module
The communication between the master and the slave takes place through the RF module. The Master sends the desired command through the transmitter module, which is received and followed by the Slave through the receiver module attached to it.
×1
Photodiode+LED
This is the eye of the bots. Obstacle avoider helps the bots to avoid unwanted obstacles and also prevents collision against each other. It comprises of a system of photodiodes and LEDs, which are placed on the master and the slave respectively
×1
LV-MaxSonar
Ultrasonic sensors are in air, non-contact object detection and ranging sensors that detect objects within an area. These sensors are not affected by the color or other visual characteristics of the detected object. Ultrasonic sensors use high frequency sound to detect and localize objects in a variety of environments.
×1

About this project

What is your project about?

Swarm robotics is a field of multi-robotics in which large number of robots is coordinated in a distributed and decentralized way. The main scientific objective of the Swarm-bots project is to study and aim at controlling the s-bots assemble into structures.Swarm-bot is made of master and slave whereby the master controls the slave using RF module to carry out the desired task.

One Swarm-bot is composed of number of similar robots, called s-bots, physically interconnected. The Swarm-bot is provided with self-assembling capabilities. This project introduces the Swarm-bot with a master and two slaves and describes its application as transportation bot.

The robots in the swarm should have some basic functions-

1) Communication between swarm bots: The Robots in the swarm exchange the information with each other and propagate the information to the whole swarm through autonomous behaviors resulting in the swarm-level cooperation.

2) Avoid collision between swarm robots

3) Synchronization between bots

Master and Slave robot

Why did you decide to make it?

As an emerging research area, the swarm intelligence has attracted many researchers’ attention since the concept was proposed in 1980s. It has now become an interdisciplinary frontier and focus of many disciplines including artificial intelligence, economics, sociology, biology, etc. It has been observed a long time ago that some species survive in the cruel nature taking the advantage of the power of swarms, rather than the wisdom of individuals.

Origin of Swarm

How does it work?  

 Videos of Working prototype


Code

Swarm TransmitterC/C++
/*
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 9
   4 - CSN to Arduino pin 10
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED
   - 
   Analog Joystick or two 10K potentiometers:
   GND to Arduino GND
   VCC to Arduino +5V
   X Pot to Arduino A0
   Y Pot to Arduino A1
   
 - V1.00 11/26/13
   Based on examples at http://www.bajdi.com/
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <OneSheeld.h>

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
int LeftMotorForward = 7; // Pin 10 has Left
int LeftMotorReverse = 6; // Pin 9 has Left Motor
int RightMotorForward = 5; // Pin 12 has Right
int RightMotorReverse = 4; // Pin 13 has Right
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
float Inch=0.00;
float cm=0.00;
int SonarPin=A5;
int  sensorValue;

/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int joystick[1];  // 2 element array holding Joystick readings


void setup()   /****** SETUP: RUNS ONCE ******/
{
    OneSheeld.begin();

//  Serial.begin(57600  );
 pinMode(LeftMotorForward, OUTPUT); //initialize the pin as an output.
pinMode(RightMotorForward, OUTPUT); //initialize the pin as an output.
pinMode(LeftMotorReverse, OUTPUT); // initializethe pin as an output.
pinMode(RightMotorReverse, OUTPUT); //initialize the pin as an output.
    
    pinMode(SonarPin,INPUT);
//Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{


 /* Blink the cursor and for 5 seconds. */
    sensorValue=analogRead(SonarPin);
Inch= (sensorValue*0.497);
cm=Inch*2.54;


 if(GamePad.isUpPressed())
  {
   // forward();
   if(cm<30)
  {
    //for(int i=0;i<1000;i++)
    {
      joystick[0]=3;
    left();
   
    delay(1500);
    }


   // Serial.println("p=0");
  }
  else
  {
    forward();
    joystick[0]=8;
    
   // Serial.println("forward");

  }
  }
  /* If down is pressed, move the car backwards. */
  else if (GamePad.isDownPressed())
  {
   if(cm<30)
  {
  
    {
    left();

        joystick[0]=3;

    delay(1500);
    }


   // Serial.println("p=0");
  }
  else
  {back();
  
        joystick[0]=2;
}
    // Serial.println("back");
}
    
  
  /* If right is pressed, turn the car to the right. */
  else if (GamePad.isRightPressed())
  {
    if(cm<30)
  {
  
    {
              joystick[0]=3;

    left();

    delay(1500);
    }


   // Serial.println("p=0");
  }
  else
  {
            joystick[0]=6;

    right();
   
  }
  }
    /* If left is pressed, turn the car to the left. */
  else if(GamePad.isLeftPressed())
  {
    if(cm<30)
  {
  
    {
              joystick[0]=3;

    left();
 
    delay(1500);
    }


   // Serial.println("p=0");
  }
  else
  {
            joystick[0]=3;

   left();
  
  }
  }
  /* If nothing is pressed stop all motors. */
  else 
  {
  // forward();
          joystick[0]=5;

   Stop();
  
  }

  
 radio.write( joystick, sizeof(joystick) );
 Serial.println(joystick[0]); 


}
//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//NONE
//*********( THE END )***********
void forward()
{
digitalWrite(RightMotorForward, HIGH); // turnthe Right Motor ON
digitalWrite(LeftMotorForward, HIGH); 
}

void back()
{
  digitalWrite(RightMotorReverse, HIGH); // turnthe Right Motor ON
digitalWrite(LeftMotorReverse, HIGH); 

}
void Stop()
{
 digitalWrite(RightMotorForward,LOW); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, LOW);  
}

void left()
{
  digitalWrite(RightMotorForward,LOW); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, HIGH);  
}

void right()
{
  digitalWrite(RightMotorForward,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, LOW);  
}

void softright()
{
digitalWrite(RightMotorForward,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorReverse, HIGH);   
}
void softleft()
{
digitalWrite(RightMotorReverse,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, HIGH);   
}
Swarm ReceiverC/C++
/* YourDuinoStarter Example: nRF24L01 Receive Joystick values

 - WHAT IT DOES: Receives data from another transceiver with
   2 Analog values from a Joystick or 2 Potentiometers
   Displays received values on Serial Monitor
 - SEE the comments after "//" on each line below
 - CONNECTIONS: nRF24L01 Modules See:
 http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 9
   4 - CSN to Arduino pin 10
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED
   
 - V1.00 11/26/13
   Based on examples at http://www.bajdi.com/
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10
int LeftMotorForward = 7; // Pin 10 has Left
int LeftMotorReverse = 6; // Pin 9 has Left Motor
int RightMotorForward = 5; // Pin 12 has Right
int RightMotorReverse = 4; // Pin 13 has Right
int p = 3;

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int joystick[1];  // 2 element array holding Joystick readings

void setup()   /****** SETUP: RUNS ONCE ******/
{
   pinMode(LeftMotorForward, OUTPUT); //initialize the pin as an output.
pinMode(RightMotorForward, OUTPUT); //initialize the pin as an output.
pinMode(LeftMotorReverse, OUTPUT); // initializethe pin as an output.
pinMode(RightMotorReverse, OUTPUT); //initialize the pin as an output.
pinMode(p, INPUT);

  Serial.begin(9600);
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
    {
      // Fetch the data payload
      done = radio.read( joystick, sizeof(joystick) );
      //Serial.println("X = ");
     /* if(joystick[0]==10)
      {
        digitalWrite(2,HIGH);
      }*/
      Serial.println(joystick[0]);
      //Serial.print(" Y = ");      
      //Serial.println(joystick[1]);*/
      
      
      
       if(joystick[0]==8)
  {
     forward();
  
  if(digitalRead(p)==0)
{
  left();
}
   
  }
  /* If down is pressed, move the car backwards. */
  else if (joystick[0]==2)
  {
   back();
        
}
    // Serial.println("back");

    
  
  /* If right is pressed, turn the car to the right. */
  else if (joystick[0]==6)
  {
   

   // Serial.println("p=0");
         

    right();
  
  }
    /* If left is pressed, turn the car to the left. */
  else if(joystick[0]==4)
  {
            

   left();
  
  }
  else if (joystick[0]==3)
  {
   left();
        
}
  /* If nothing is pressed stop all motors. */
  else 
  {
  // forward();

   Stop();
  }


      
      
      
      
    }
  }
  else
  {    
      Serial.println("No radio available");
              digitalWrite(2,LOW);

  }

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//NONE
//*********( THE END )***********
void forward()
{
digitalWrite(RightMotorForward, HIGH); // turnthe Right Motor ON
digitalWrite(LeftMotorForward, HIGH); 
}

void back()
{
  digitalWrite(RightMotorReverse, HIGH); // turnthe Right Motor ON
digitalWrite(LeftMotorReverse, HIGH); 

}
void Stop()
{
 digitalWrite(RightMotorForward,LOW); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, LOW);  
}

void left()
{
  digitalWrite(RightMotorForward,LOW); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, HIGH);  
}

void right()
{
  digitalWrite(RightMotorForward,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, LOW);  
}

void softright()
{
digitalWrite(RightMotorForward,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorReverse, HIGH);   
}
void softleft()
{
digitalWrite(RightMotorReverse,HIGH); // turn Right Motor OFF
 digitalWrite(LeftMotorForward, HIGH);   
}

Schematics

PCB shield: Interfaced all component in pcb
All components are interfaced in one pcb
Bottom

Comments

Similar projects you might like

Bluetooth Steering wheel for a robot using 1Sheeld

Project tutorial by Kristian Blåsol

  • 2,543 views
  • 1 comment
  • 13 respects

Super Easy to Build 1Sheeld 2 Wheel Drive Robot

Project tutorial by Garry Gerwer and Ahmed Hamdy

  • 16,686 views
  • 3 comments
  • 32 respects

Control Robot Arm with your Android Phone

Project tutorial by Ammar Atef Ali

  • 12,012 views
  • 0 comments
  • 24 respects

Universal Remote Control using Arduino, 1Sheeld and Android

Project tutorial by Ashraf Nabil

  • 8,145 views
  • 5 comments
  • 12 respects

Swarm Robot Using NRF Chat Application

Project tutorial by 3 developers

  • 2,899 views
  • 2 comments
  • 16 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 35,259 views
  • 4 comments
  • 55 respects
Add projectSign up / Login