/Robatics

Implementation of Controllers for e-puck in Webots enviroment using popular Localization,Planning and Navigation Algorithms.

Primary LanguagePython

Controllers for GCTronic' e-puck in webots

For better understanding of the codes, please first check webots documents regarding GCTronic' e-puck

Basic Controllers

In the first section we shall implement a series of basic controllers for e-puck.

Applying diffrent Angular velocity

In order to better understand the concepts of e-puck movement we code a simple controller in which by changing values of parameters ' max_speed_left ' and ' max_speed_right ' we can access and adjust angular velocity of each wheel. we use ' GPS ' and ' Compass ' sensors to plot the movement of our robot. x-y of robot movement and time-teta plot of robot heading in each time plot is avaiable for 3 diffrent set of angular velocity values :

Part 1 : φ˙ 1 = 1rad/s, φ˙ 2 = 1rad/s

Part 2 : φ˙ 1 = 1rad/s, φ˙ 2 = −1rad/s

Part 3 : φ˙ 1(t) = sin t rad/s, φ˙ 2(t) = −cos t rad/s

Forward Cinematic Function

To calculate the final position and orientation of the robot after each command, we will use the following kinematic equations for a differential drive robot:

Kinematic Equations: Given the initial position (𝑥,𝑦,𝜃) and the velocities of the left and right wheels 𝑣1 and 𝑣2, along with the time duration 𝑡, and the distance between the two wheels 𝑙, the following equations are used: If 𝑣1=𝑣2 (Straight motion):The robot moves in a straight line. Δ𝑥=𝑣1⋅𝑡⋅cos(𝜃) Δ𝑦=𝑣1⋅𝑡⋅sin(𝜃) 𝜃𝑛=θ (no change in orientation) If 𝑣1≠𝑣2(Turning motion):The robot follows an arc of a circle. Angular velocity: 𝜔=(𝑣2−𝑣1)/𝑙 Radius of the turn: 𝑅=𝑙/2⋅((𝑣1+𝑣2)/(𝑣2−𝑣1)) Change in orientation: Δθ=ω⋅t Position change:Δx=R⋅(sin(θ+Δθ)−sin(θ)) , Δy=−R⋅(cos(θ+Δθ)−cos(θ)) Final orientation: 𝜃𝑛=θ+Δθ Initial Conditions: x=1.5m , y=2m , 𝜃=𝜋/2 rad ,l=0.5m Commands: 𝑐1=(𝑣1=0.3 m/s,𝑣2=0.3 m/s,𝑡=3s):Since v1=v2, the robot moves straight. c2 = the robot turns in place. c3 =The robot turns with a radius.

robot's positions and orientations after executing each command:

After Command 1: Final position: (x1,y1)=(1.5,2.9)m Final orientation: θ1=2πrad≈1.57rad After Command 2: Final position: (x2,y2)=(1.5,2.9)m (No change in position) Final orientation: 𝜃2≈1.17rad After Command 3: Final position: (𝑥3,𝑦3)≈(1.64,3.04)m Final orientation: 𝜃3≈0.37 rad

we can check the correctness of our function with plots generated after each command.

Inverse cinematic model of a diffrential driven robot

we model a function which calculates angular velocity of each wheel of epoch robot using its linear speed and angular speed , for example for the following cases : Case 1: v=3m/s,ω=0.1rad/s The robot moves in a curved trajectory. The orientation (𝜃) increases gradually over time.

Case 2: v=0m/s,ω=0.5rad/s The robot rotates in place without any translational movement, resulting in a circular path with no change in 𝑋 or 𝑌 position. The orientation (𝜃) increases more rapidly over time.

guiding GCTronic' e-puck towards the center of a circle

We want to design a controller that guides our robot towards the center of a circle with a random heading degree .The robot starts at a certain point on the circle's perimeter, and the circle has a radius of 0.5 meters. We need to consider different initial positions of the robot and simulate its movement towards the center using the designed controller. A sample plot initial position = 10:

Collosion Detection

In this section we have a simple forward movement but its toward a box which we aim to measure the input force to our robot using TouchSensor

Calculate the robot's path using PositionSensor

calculate the robot's path using three different sensors: GPS, Compass, and PositionSensor. For each case, we follow these steps:

Use Compass and the GPS sensor to determine the robot's path. Plot the robot's position (X-Y) and its orientation angle (θ) over time.
Use only the PositionSensor to determine the robot's path. Plot the X-Y position and the orientation angle (θ) over time.
Finally, compare the plots generated by each method. You should analyze how similar or different the paths are when using different sensors.

For each scenario, consider the following angular velocity profiles for the robot's wheels:

ϕ1˙=1 rad/s,ϕ2˙=1 rad/sϕ1​˙​=1 rad/s,ϕ2​˙​=1 rad/s
ϕ1˙=1 rad/s,ϕ2˙=−1 rad/sϕ1​˙​=1 rad/s,ϕ2​˙​=−1 rad/s
ϕ1˙(t)=sin⁡(t) rad/s,ϕ2˙(t)=−cos⁡(t) rad/sϕ1​˙​(t)=sin(t) rad/s,ϕ2​˙​(t)=−cos(t) rad/s

The term "time step tt" refers to the simulation's time intervals. You can check the plots under related directory plot directory for each three of the scenario's.

Split and Merge

In this section we shall create a map of the environment shown below using Split and Merge algorithm as explained :

Environment:

Gathered maps :