Code Monkey home page Code Monkey logo

reynoldsswarmsim's Introduction

Controlling a Swarm of Robots in a Simulator Stage using Reynolds’ Rules

ROS Python Stage Simulator Project Website Paper

This project focuses on implementing and evaluating Craig Reynolds’ behavioral rules—separation, alignment, and cohesion within a Robot Operating System (ROS) framework and the Stage simulator. The project aims to enhance the capabilities of robotic swarms by adding Navigation and Obstacle Avoidance behaviors to allow the swarm to move towards specific points and stop, while Obstacle Avoidance enables them to detect and evade obstacles, thus preventing collisions. The robots are tested in various scenarios to assess their collective behavior, adaptability, and robustness.

Two Lines Three Lines

Note: This project combines theoretical concepts with practical applications, shedding light on the dynamics of robotic swarms and their potential in simulated environments. Video results are provided to illustrate the findings. here and here.

Table of Contents

Installation

  1. Dependencies: Ensure ROS (Robot Operating System) and Python 3 are installed on your system.
  2. Clone the Repository: Clone this repository into your ROS workspace's src directory.
    cd ~/catkin_ws/src
    git clone [email protected]:KhAlamdar11/mrs-r1.git
  3. Build the Package: From the root of your ROS workspace, build the package using catkin_make.
    cd ~/catkin_ws
    catkin_make
  4. Source the Workspace: Source your ROS workspace to make the package available.
    source devel/setup.bash

How To Run

To run a simulation, use the provided launch files. For instance, to start a simulation with the default configuration:

  1. Go to the stage_simulator launch yaml file and change the number of robots to the desired value.

  2. Go to the params.yaml file and change the number of boids (i.e., n) to the same value as the above.

  3. Spawn the robots in the Stage Simulator:

    rosrun sphero_stage start.py
  4. The robots will be spawned in Stage in the predefined formation (as defined in the launch yaml file of the simulator).

  5. Launch the formation control node:

    roslaunch mrs-r1 part1.launch
    

Configuration Guide

The params.yaml file serves as the primary means to customize your simulation's settings. This section provides an in-depth look at each parameter within the configuration file, ensuring you can tailor the package to your specific needs.

General Structure

The configuration file is organized into several sections, each pertaining to different aspects of the simulation:

  • Visualization: Configure visual output and trajectory tracking for the simulation.
  • Number of Boids: Defines the total number of boids (agents) in the simulation.
  • Behavior Weights: Adjust the weights for various boid behaviors including alignment, cohesion, separation, arrival, and steer-to-avoid.
  • Neighborhood Parameters: Sets the parameters defining each boid's perception of its neighbors.
  • Goal Parameters: Configure the primary goal and optional multiple goal settings.
  • Kinematic Parameters: Sets the maximum speed and acceleration for the boids.
  • Leadership Configuration: Determines the selection and behavior of leaders within the swarm.
  • Prioritized Acceleration: Enables and configures prioritized acceleration to manage multiple behaviors.
  • Obstacle Parameters: Configure obstacle detection and avoidance settings.
  • Arrival-specific Parameters: Customizes behavior when approaching the goal.

Visualization

Configure visual output and trajectory tracking for the simulation.

  • Visualize via RViz: Enables real-time visualization in RViz.
    • visualize: Set to True to enable visualization.
  • Truncate Trajectories: Limits the length of trajectory history for display.
    • truncate_trajectories: Maximum number of points to display. Set to 10000000 for virtually no limit.
visualize: True
truncate_trajectories: 10000000

Number of Boids

Defines the total number of boids (agents) in the simulation.

  • n_boids: Total number of boids participating.
    n_boids: 10

Behavior Weights

Adjust the weights for various boid behaviors including alignment, cohesion, separation, arrival, and steer-to-avoid.

  • Alignment (w_a): Adjusts alignment with nearby boids.
  • Cohesion (w_c): Pulls boid towards the center of mass of neighbors.
  • Separation (w_s): Keeps boid away from close neighbors to avoid crowding.
  • Arrival (w_arrival): Controls the effort to reach the goal position.
  • Steer-to-Avoid (w_steer_to_avoid): Influences avoidance maneuvers around obstacles.
w_a: &w_a 0.1
w_c: &w_c 0.35
w_s: &w_s 0.2
w_arrival: &w_arrival 0.1
w_steer_to_avoid: &w_steer_to_avoid 0.85

Neighborhood Parameters

Sets the parameters defining each boid's perception of its neighbors.

  • Local Radius (local_r): The distance within which other boids are considered neighbors.
  • Perception Angle (local_theta): The field of view angle for detecting neighbors.
local_r: 1.9
local_theta: 360.0

Goal Parameters

Configure the primary goal and optional multiple goal settings.

  • Goal Coordinates (goal_x, goal_y): Sets the target location for the swarm.
  • Goal Radius and Tolerance: Defines the goal area and the tolerance for reaching the goal.
  • Inter Goal Distance (inter_goal_dist): Specifies the ratio of distance between sequential goals for multi-goal paths.
  • Use Multiple Goals (use_multigoal): Enables or disables the use of a series of goals.
  • Arrival Threshold (arrival_threshold): The proportion of boids required to reach a goal before proceeding to the next.
  • Goal List (goal_list): A list of goals defined by coordinates, radius, and tolerance.
goal_x: 4.0
goal_y: 4.0
goal_radius: 0.5
goal_tolerance: 0.02
inter_goal_dist: 0.4
use_multigoal: False
arrival_threshold: 0.9
goal_list: 
  - [3.0, 2.0, 0.5, 0.02]
  - [-3.0, -4.0, 0.5, 0.02]
  - [4.0, -4.0, 0.5, 0.02]
  - [3.0, 4.0, 0.5, 0.02]
  - [-3.0, 4.0, 0.5, 0.02]

Kinematic Parameters

Sets the maximum speed and acceleration for the boids.

  • Max Speed (max_speed): The highest speed a boid can achieve.
  • Max Acceleration (max_acc): The maximum rate of change of speed.
max_speed: 3.3
max_acc: 2.2

Leadership Configuration

Determines the selection and behavior of leaders within the swarm.

  • Number of Leaders (n_leaders): Specifies how many leaders are in the swarm.
  • Leader Method (leader_method): Chooses the method for leader selection.
  • Leader Type (leader_type): Determines if leaders are dynamic or fixed.
n_leaders: 5 # Should not be greater than 7
leader_method: 0 # 0: Closest to goal, 1: ConvexHull
leader_type: 0 # 0: Dynamic, 1: Fixed

Prioritized Acceleration

Enables and configures prioritized acceleration to manage multiple behaviors.

  • Use Prioritized Acceleration (use_prioritized_acc): Toggles prioritized acceleration on or off.
  • Priority List (`

priority_list`): Orders behaviors by priority with their associated weights.

use_prioritized_acc: True
priority_list: 
  - '_arrival': *w_arrival
  - '_separation': *w_s
  - '_alignment': *w_a
  - '_cohesion': *w_c

Obstacle Parameters

Configure obstacle detection and avoidance settings.

  • Obstacle Radius (obs_r): Sets the detection radius for obstacles.
  • Step Angle (step_angle): The angle increment for obstacle scanning.
  • Max Steering Angle (max_steering_angle): Limits the steering angle for avoidance maneuvers.
obs_r:  0.8
step_angle : 0.174533
max_steering_angle : 6.28

Arrival-specific Parameters

Customizes behavior when approaching the goal.

  • Hard Arrival (hard_arrival): When enabled, boids prioritize reaching the goal over all other behaviors.
hard_arrival: True

Customizing Your Simulation

This package is designed to be highly configurable. To customize your simulation, edit the params.yaml file, adjusting the parameters as needed based on the descriptions provided above. Experimenting with different configurations can help you understand the impact of various behaviors and parameters on the multi-robot system's overall performance.

Visualizing Results

Results can be visualized in real-time using RViz. Ensure the visualize parameter is set to True and use the provided RViz configuration to observe the boids' behaviors, trajectories, and interactions with obstacles.

Contributing

We welcome contributions to the package. For more information on how to contribute, please reach out to any of the authors.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors:

reynoldsswarmsim's People

Contributors

khalamdar11 avatar nadaabbas444 avatar mosesebere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.