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.
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
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.
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
POST
/commandrover
type data type key value required object (JSON ) commands string
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 -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'}"
Obstacle detected at position: (0, 1)
Current position: (0, 2)
Current direction: N
No obstacle detected!
Current position: (0, 9)
Current direction: N
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': ''}"
No commands received
- Add logger per request
- Replace Console.Writeline with logger
- Report every Rover movement in the response
- Add 400 Bad Request
- Add Authentication/Authorization
Technologies used in the project:
- C#
- .NET 8.0
- xUnit.net
This project is licensed under the MIT License