Skip to content

Lab assignments of Artificial Life Simulation course (Robotics)

Notifications You must be signed in to change notification settings

himanshub16/robot-motion-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

ALS Lab assignments

This repository contains code written for the lab of Artificial Life Simulation course (part of Robotics, my masters specialization).

ros/als contains the code written for ROS based assignments for Artificial Life Simulation Course.

Table of Contents

1. Setup pub-sub connections as per a given graph

code

Given a graph as shown in image below, setup talker and subscriber nodes such that they transfer messages so that the connection graph appears as the image. pub-sub-graph

The solution reads the config graph from a json file and for each node prepares a list of nodes the current one will talk to and listen to.

After this, it starts each node in a different process, using Python's multiprocessing.

cd scripts
# Update the graph in connection-graph.json, if you want a different setup
python 1-start-talking.py

# To view the graph, run below cmd in another shell
rosrun rqt_graph rqt_graph

2. Move a robot in MobileSim to a fixed goal

code

Given a goal, say (0, 5), a robot in MobileSim needs to move from one point to another.

The solution models the velocity (linear and angular) of the robot as a p-controller. Linear velocity is proportional to the distance from goal with upper cap as 1.0 and same for angular velocity with upper cap as 1.0.

A goal is said to be reached if the distance from the goal is less than a lower bound (here, 1.0).

gif_here

# Run these commands in different shells/windows
# Start roscore service
roscore

# Start MobileSim
MobileSim -r pioneer-lx --nomap

# Start RosAria
rosrun rosaria RosAria

# Start the required script
python scripts/2-move-to-goal.py

3. Move a MobileSim robot in a square loop

code

The vertices of the square are at (0, 0), (0, 5), (5, 5), (5, 0). The robot runs in a loop in the square. The solution to this is similar to the previous problem, with the fact that the goal variable updates after one goal is reached.

gif_here

# Run these commands in different shells/windows
# Start roscore service
roscore

# Start MobileSim
MobileSim -r pioneer-lx --nomap

# Start RosAria
rosrun rosaria RosAria

# Start the required script
python scripts/3-move-square-loop.py

4. Make a robot follow another which is controlled from keyboard

code

There are two robots - r1 and r2. r1 is controlled from keyboard via teleop package, while r2 is controlled from program. r2 follows r1.

gif_here

MobileSim -r pioneer-lx -r pioneer-lx --nomap

# To simplify, we'll now use a launch file instead of individual commands
roslaunch launchfiles/fourth.launch

# Control r1 from keyboard
rosrun teleop_twist_keyboard teleop_twist_keyboard /cmd_vel:=/r1/cmd_vel

5. Make a chain of bots following each other with leader controlled from keyboard

code

There are five robots, with the first one being controlled from keyboard, the second one following the first, the third follows the second, and so on.

gif_here

MobileSim -r pioneer-lx -r pioneer-lx -r pioneer-lx -r pioneer-lx -r pioneer-lx --nomap

# To simplify, we'll now use a launch file instead of individual commands
roslaunch launchfiles/fifth.launch

# Control r1 from keyboard
rosrun teleop_twist_keyboard teleop_twist_keyboard /cmd_vel:=/r1/cmd_vel

6. Move robots from corner of a square to opposite with collision avoidance

code Four robots placed on the corner of a square have to moved to the opposite side along the diagonal, making path adjustments for collision avoidance. The gif shows the desired path.

Collision avoidance has been done by considering socio-potential field (applying a specific attraction force towards the goal and replusion from other robots).

Initial position of robots on MobileSim is done by dragging them to approximately the position we want (mentioned in the launch file as well). The positions were transformed to world coordinate frame for calculating the net force due to socio-potential field.

gif_here

MobileSim -r pioneer-lx -r pioneer-lx -r pioneer-lx -r pioneer-lx --nomap

# To simplify, we'll now use a launch file instead of individual commands
roslaunch launchfiles/sixth.launch

7. Move bots in a grid as shown with no collision

To start two robots from the ends of an "S", with other two following one each. See gif to get a better idea. code

gif_here

MobileSim -r pioneer-lx -r pioneer-lx -r pioneer-lx -r pioneer-lx --nomap

# To simplify, we'll now use a launch file instead of individual commands
roslaunch launchfiles/sixth.launch

NOTE: The gifs have been made by exporting frames from MobileSim at interval of 0.2s and combining to a gif using ImageMagick.

About

Lab assignments of Artificial Life Simulation course (Robotics)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published