Skip to content
Snippets Groups Projects
Commit c99b131c authored by Alma Berisha's avatar Alma Berisha
Browse files

Path tracking implementation

parent b2cfc124
No related branches found
No related tags found
1 merge request!1Develop
You are a tester tasked with creating comprehensive test cases for a given usecase description.
## Usecase description
{
"name": "MissionControl Map Tracking",
"scenario": "The rover tracks all visited positions during execution so that MissionControl can recreate the path.",
"actors": "MissionControl",
"preconditions": "The rover is landed on the plateau at position (0,0)",
"steps": [
"MissionControl sends a movement command to the rover",
"Rover executes each movement command (F, B, L, R)",
"Rover records each visited position in order",
"MissionControl calls a method to retrieve the full path history",
"The system returns the sequence of all visited coordinates"
]
}
## Testcase
[
{
"name": "Path Tracking with No Obstacles",
"description": "Verify that the rover records all visited positions when no obstacles are present",
"input": {
"command": "FFRFF"
},
"expected": {
"executedCommands": "FFRFF",
"path": [
[0, 0],
[0, 1],
[0, 2],
[1, 2],
[2, 2],
[3, 2]
]
}
},
{
"name": "Path Tracking Stops at Obstacle",
"description": "Verify that the rover records the path until just before an obstacle is detected",
"input": {
"command": "FFRFF"
},
"expected": {
"executedCommands": "FFR",
"path": [
[0, 0],
[0, 1],
[0, 2],
[1, 2]
]
}
},
{
"name": "Path Tracking with Backward Movement",
"description": "Verify that backward movements are correctly added to the path",
"input": {
"command": "FFLBB"
},
"expected": {
"executedCommands": "FFLBB",
"path": [
[0, 0],
[0, 1],
[0, 2],
[-1, 2],
[-2, 2]
]
}
}
]
README.md 0 → 100644
RoverMovement
You are a tester tasked with creating comprehensive test cases for a given usecase description.
Usecase descpription
{
"name": "Driving the Rover on Mars",
"scenario": "MissionControl sends drive commands to move the rover across the plateau.",
"actors": "MissionControl",
"preconditions": "Rover is landed on the plateau at position (0,0)",
"steps": [
"MissionControl sends command string (e.g. 'FFRLF') to the rover",
"Rover interprets each character and updates position/heading accordingly",
"Before each move, Rover checks for obstacles or plateau boundaries",
"If an obstacle or edge is detected, Rover stops and ignores remaining commands",
"Rover returns the string of successfully executed commands"
]
}
Testcase
[
{
"name": "Rover Moves Successfully with No Obstacles",
"description": "Verify that the rover moves as expected with valid input and no obstacles",
"input": {
"command": "FFRFF"
},
"expected": {
"outcome": "Rover moved successfully",
"executedCommands": "FFRFF"
}
},
{
"name": "Rover Stops at Obstacle",
"description": "Verify that the rover stops when an obstacle is detected and remaining commands are ignored",
"input": {
"command": "FFRFF"
},
"expected": {
"outcome": "Rover stopped due to obstacle",
"executedCommands": "FFR"
}
},
{
"name": "Invalid Command Input",
"description": "Verify that the rover handles invalid commands gracefully",
"input": {
"command": "FXZ"
},
"expected": {
"outcome": "Invalid command encountered",
"executedCommands": "F"
}
}
]
ObstacleDetection
You are a tester tasked with creating comprehensive test cases for a given usecase description.
Usecase description
{
"name": "Rover Obstacle Detection",
"scenario": "The rover must stop when it detects an obstacle in its path.",
"actors": "MissionControl",
"preconditions": "Rover is landed on the plateau at position (0,0)",
"steps": [
"MissionControl sends a movement command to the rover",
"Rover checks each step for obstacles using its obstacle detection system (ODS)",
"If an obstacle is detected, the rover stops before moving into it",
"Remaining commands in the sequence are ignored",
"Rover returns only the successfully executed commands"
]
}
Testcase
[
{
"name": "Rover Stops at First Obstacle",
"description": "Verify that the rover stops immediately when the first obstacle is detected",
"input": {
"command": "FFRFF"
},
"expected": {
"outcome": "Obstacle detected; rover stopped",
"executedCommands": "FF"
}
},
{
"name": "Rover Avoids Obstacle and Continues",
"description": "Verify that rover only moves until just before the obstacle",
"input": {
"command": "FRFRF"
},
"expected": {
"outcome": "Obstacle detected mid-sequence",
"executedCommands": "FRF"
}
},
{
"name": "Rover Encounters No Obstacles",
"description": "Verify that the rover executes all commands when no obstacles are present",
"input": {
"command": "FFLFF"
},
"expected": {
"outcome": "Rover moved successfully",
"executedCommands": "FFLFF"
}
}
]
ControlMap
You are a tester tasked with creating comprehensive test cases for a given usecase description.
Use description
{
"name": "MissionControl Map Tracking",
"scenario": "The rover tracks all visited positions during execution so that MissionControl can recreate the path.",
"actors": "MissionControl",
"preconditions": "The rover is landed on the plateau at position (0,0)",
"steps": [
"MissionControl sends a movement command to the rover",
"Rover executes each movement command (F, B, L, R)",
"Rover records each visited position in order",
"MissionControl calls a method to retrieve the full path history",
"The system returns the sequence of all visited coordinates"
]
}
Testcase
[
{
"name": "Path Tracking with No Obstacles",
"description": "Verify that the rover records all visited positions when no obstacles are present",
"input": {
"command": "FFRFF"
},
"expected": {
"executedCommands": "FFRFF",
"path": [
[0, 0],
[0, 1],
[0, 2],
[1, 2],
[2, 2],
[3, 2]
]
}
},
{
"name": "Path Tracking Stops at Obstacle",
"description": "Verify that the rover records the path until just before an obstacle is detected",
"input": {
"command": "FFRFF"
},
"expected": {
"executedCommands": "FFR",
"path": [
[0, 0],
[0, 1],
[0, 2],
[1, 2]
]
}
},
{
"name": "Path Tracking with Backward Movement",
"description": "Verify that backward movements are correctly added to the path",
"input": {
"command": "FFLBB"
},
"expected": {
"executedCommands": "FFLBB",
"path": [
[0, 0],
[0, 1],
[0, 2],
[-1, 2],
[-2, 2]
]
}
}
]
# adds missionconrtoll to rover2.py
DIRECTIONS = ['N', 'E', 'S', 'W']
MOVES = {
'N': (0, 1),
'E': (1, 0),
'S': (0, -1),
'W': (-1, 0)
}
class Rover:
def __init__(self, obstacles=None):
self.x = 0
self.y = 0
self.heading = 0
self.obstacles = obstacles if obstacles else set()
self.path = [(0, 0)]
def drive(self, command_string):
executed = ""
for cmd in command_string:
if cmd in ['F', 'B']:
dx, dy = MOVES[DIRECTIONS[self.heading]]
if cmd == 'B':
dx, dy = -dx, -dy
next_x = self.x + dx
next_y = self.y + dy
if (next_x, next_y) in self.obstacles:
break
self.x = next_x
self.y = next_y
self.path.append((self.x, self.y))
elif cmd == 'L':
self.heading = (self.heading - 1) % 4
elif cmd == 'R':
self.heading = (self.heading + 1) % 4
else:
break
executed += cmd
return executed
def get_position(self):
return (self.x, self.y)
def get_heading(self):
return DIRECTIONS[self.heading]
def get_path(self):
return self.path
from my_rover import Rover
def test_path_tracking_no_obstacles():
rover = Rover()
rover.drive("FFRFF")
assert rover.get_path() == [(0,0), (0,1), (0,2), (1,2), (2,2)]
assert rover.get_position() == (2,2)
def test_path_tracking_stops_at_obstacle():
rover = Rover(obstacles={(1, 2)})
rover.drive("FFRFF")
assert rover.get_path() == [(0,0), (0,1), (0,2)]
assert rover.get_position() == (0,2)
def test_backward_path_tracking():
rover = Rover()
rover.drive("FFLFFBB")
assert rover.get_path() == [(0,0), (0,1), (0,2), (-1,2), (-2,2), (-1,2), (0,2)]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment