Skip to content

effedib/mars-attack

Repository files navigation

shieldsshields

mars-attack

project-image

Project developed for the Mars exploration mission through the deployment of remotely controlled vehicles on the planet's surface. The API translates commands sent from Earth into instructions executable by the rover.

👷 How It works

The Rover accepts the commands as chars:

  • 'f': forward
  • 'b': backward
  • 'l': turn left
  • 'r': turn right

You can concatenate the chars as you want in a string to pass to the key "commands" in the Json to put in the body request. Every other char will be ignored by the Rover, so if you send:

  • "fff": Rover goes forward for 3 points
  • "aaa": Rover ignore commands
  • "123456": Rover ignore commands
  • "": Rover ignore commands

🧐 Features

Here're some of the project's best features:

  • Sends commands remotely using Json format
  • Report if obstacles have been encountered
  • Report current position.
  • Report current direction.

🛠️ Installation Steps:

1. Clone the repository

cd C:\path\to\mars-attack-folder
git clone https://github.com/effedib/mars-attack.git
cd mars-attack\RoverCommandService

2. Install the dependencies

dotnet restore

3. Build the project

dotnet build

4. Run the project only http

dotnet run

5. Run the project http and https

dotnet run --launch-profile https

6. How Run Tests

cd C:\path\to\mars-attack-folder\mars-attack\RoverCommandService.Tests
dotnet test --no-build

API Reference

Send Commands

POST /commandrover
Body Request
type data type key value
required object (JSON ) commands string
Response
http code content-type response
200 text/plain;charset=UTF-8 obstacle detection, current position, current location
400 text/plain;charset=UTF-8 No commands received

cURL Examples

curl -X POST https://localhost:7015/commandrover
      -H 'Content-Type:application/json'
      -d "{'commands': 'fff'}"

curl -X POST http://localhost:5197/commandrover
      -H 'Content-Type:application/json'
      -d "{'commands': 'fff'}"

Response Example

Obstacle detected at position: (0, 1)
Current position: (0, 2)
Current direction: N

No obstacle detected!
Current position: (0, 9)
Current direction: N

Bad cURL Examples

curl -X POST https://localhost:7015/commandrover
      -H 'Content-Type:application/json'
      -d "{'': 'fff'}"

curl -X POST http://localhost:5197/commandrover
      -H 'Content-Type:application/json'
      -d "{'commands': ''}"

Response Example

No commands received

📝 TODO

  • Add logger per request
  • Replace Console.Writeline with logger
  • Report every Rover movement in the response
  • Add 400 Bad Request
  • Add Authentication/Authorization

💻 Built with

Technologies used in the project:

  • C#
  • .NET 8.0
  • xUnit.net

🛡️ License:

This project is licensed under the MIT License

About

Mars Rover remote control

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages