├── .github └── workflows │ └── manual.yml ├── CODEOWNERS ├── LICENSE ├── README.md ├── images └── output.png └── src ├── main.cpp ├── tcp.h └── terminal.h /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | # Workflow to ensure whenever a Github PR is submitted, 2 | # a JIRA ticket gets created automatically. 3 | name: Manual Workflow 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on pull request events but only for the master branch 8 | pull_request_target: 9 | types: [opened, reopened] 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | jobs: 15 | test-transition-issue: 16 | name: Convert Github Issue to Jira Issue 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@master 21 | 22 | - name: Login 23 | uses: atlassian/gajira-login@master 24 | env: 25 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 26 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 27 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 28 | 29 | - name: Create NEW JIRA ticket 30 | id: create 31 | uses: atlassian/gajira-create@master 32 | with: 33 | project: CONUPDATE 34 | issuetype: Task 35 | summary: | 36 | Github PR [Assign the ND component] | Repo: ${{ github.repository }} | PR# ${{github.event.number}} 37 | description: | 38 | Repo link: https://github.com/${{ github.repository }} 39 | PR no. ${{ github.event.pull_request.number }} 40 | PR title: ${{ github.event.pull_request.title }} 41 | PR description: ${{ github.event.pull_request.description }} 42 | In addition, please resolve other issues, if any. 43 | fields: '{"components": [{"name":"Github PR"}], "customfield_16449":"https://classroom.udacity.com/", "customfield_16450":"Resolve the PR", "labels": ["github"], "priority":{"id": "4"}}' 44 | 45 | - name: Log created issue 46 | run: echo "Issue ${{ steps.create.outputs.issue }} was created" 47 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @udacity/active-public-content -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Udacity 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated Repository 2 | This repository is deprecated. Currently enrolled learners, if any, can: 3 | - Utilize the https://knowledge.udacity.com/ forum to seek help on content-specific issues. 4 | - [Submit a support ticket](https://udacity.zendesk.com/hc/en-us/requests/new) if (learners are) blocked due to other reasons. 5 | 6 | 7 | [![Udacity - Robotics NanoDegree Program](https://s3-us-west-1.amazonaws.com/udacity-robotics/Extra+Images/RoboND_flag.png)](https://www.udacity.com/robotics) 8 | 9 | # RoboND-Control_Rover 10 | A C++ program designed to accept user inputs and issue commands to the rover inside a simulator over a TCP/IP socket. 11 | 12 | ## Rover Simulator 13 | Before you compile and run this program, download the rover simulator for [Windows](https://s3-us-west-1.amazonaws.com/udacity-robotics/Term+2+Prep/RoverSim_Windows.zip) or [MacOS](https://s3-us-west-1.amazonaws.com/udacity-robotics/Term+2+Prep/RoverSim_MacOS.zip). Optionally you can download it for [Linux](https://s3-us-west-1.amazonaws.com/udacity-robotics/Term+2+Prep/RoverSim_Linux.zip), note that this version will only work with native Ubuntu! 14 | 15 | ## Running the C++ Program 16 | You should consider compiling and executing this program inside an Ubuntu virtual machine! 17 | Before doing so, edit your VMWare or VMFusion network settings and make sure you are connected to the NAT network. 18 | 19 | ### Navigate to a working directory and clone the repository 20 | ```sh 21 | $ cd Desktop 22 | $ git clone https://github.com/udacity/RoboND-Control_Rover.git 23 | $ cd ~/Desktop/RoboND-Control_Rover 24 | ``` 25 | 26 | ### Now, compile the code 27 | ```sh 28 | $ mkdir build 29 | $ cd src/ 30 | $ g++ main.cpp -o ../build/app 31 | ``` 32 | 33 | ### Before your run the program, take note of the IP address of your virtual machine 34 | ```sh 35 | $ ifconfig 36 | ``` 37 | 38 | ### Finally, run the program 39 | ```sh 40 | $ ../build/app 41 | ``` 42 | 43 | ### Running the Rover Simulator 44 | 1. Leave your virtual machine and run the simulator inside Windows or MacOS. 45 | 2. Then, select your graphics settings and enter the IP address of your Ubuntu VM noted earlier! 46 | 3. Select the Autonomous mode designed to accept TCP Communication. 47 | 48 | ### Controlling the Rover 49 | Refer to this table and control your robot with keyboard commands through the Ubuntu terminal! 50 | 51 |
52 | 53 | | **Command** | **Description** 54 | | ------------- |:-------------:| 55 | | `w` |Forward | 56 | | `s` | Backward | 57 | | `a`| Left | 58 | | `d`| Right | 59 | | `b`| Brake | 60 | | `p`| Pickup Ball | 61 | 62 |
63 | 64 | ### Output 65 | ![alt text](images/output.png) 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /images/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/udacity/RoboND-Control_Rover/d66f609168d7fc6338f93f050c7cb4042adbf2b3/images/output.png -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "terminal.h" 3 | #include "tcp.h" 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | DisableTerminal(); 9 | TCPConnect(); 10 | cout << "\n=> Enter Keyboard Commands to Control the Robot:" << endl; 11 | 12 | while (1) { 13 | switch ((int)getchar()) { 14 | case 'w': 15 | cout << "Forward" << endl; 16 | ServerSend("w\n"); 17 | break; 18 | 19 | case 's': 20 | cout << "Backward" << endl; 21 | ServerSend("s\n"); 22 | break; 23 | 24 | case 'a': 25 | cout << "Left" << endl; 26 | ServerSend("a\n"); 27 | break; 28 | 29 | case 'd': 30 | cout << "Right" << endl; 31 | ServerSend("d\n"); 32 | break; 33 | 34 | case 'b': 35 | cout << "Brake" << endl; 36 | ServerSend("b\n"); 37 | break; 38 | 39 | case 'p': 40 | cout << "Pickup" << endl; 41 | ServerSend("p\n"); 42 | break; 43 | 44 | default: 45 | break; 46 | } 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/tcp.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | int server,client; 12 | char buffer[1024]; 13 | 14 | void TCPConnect() 15 | { 16 | int portNum = 1500; 17 | bool isExit = false; 18 | int bufsize = 1024; 19 | 20 | struct sockaddr_in server_addr; 21 | socklen_t size; 22 | 23 | client = socket(AF_INET, SOCK_STREAM, 0); 24 | 25 | if (client < 0) 26 | { 27 | cout << "\nError establishing socket..." << endl; 28 | exit(1); 29 | } 30 | 31 | cout << "\n=> Socket server has been created..." << endl; 32 | 33 | server_addr.sin_family = AF_INET; 34 | server_addr.sin_addr.s_addr = htons(INADDR_ANY); 35 | server_addr.sin_port = htons(portNum); 36 | 37 | if ((bind(client, (struct sockaddr*)&server_addr,sizeof(server_addr))) < 0) 38 | { 39 | cout << "=> Error binding connection, the socket has already been established..." << endl; 40 | exit(0); 41 | } 42 | 43 | size = sizeof(server_addr); 44 | cout << "=> Looking for clients..." << endl; 45 | 46 | listen(client, 1); 47 | 48 | int clientCount = 1; 49 | server = accept(client,(struct sockaddr *)&server_addr,&size); 50 | } 51 | 52 | void ServerSend(const char* msg) 53 | { 54 | strcpy(buffer, msg); 55 | send(server, buffer, strlen(buffer), 0); 56 | recv(client, buffer, 1, 0); 57 | cout << "received_data= " << buffer << endl; 58 | } 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/terminal.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | void DisableTerminal() 8 | { 9 | 10 | struct termios old_tio, new_tio; 11 | 12 | /* get the terminal settings for stdin */ 13 | tcgetattr(STDIN_FILENO,&old_tio); 14 | 15 | /* we want to keep the old setting in case we want to restore them a the end */ 16 | new_tio=old_tio; 17 | 18 | /* disable canonical mode (buffered i/o) and local echo */ 19 | new_tio.c_lflag &=(~ICANON & ~ECHO); 20 | 21 | /* set the new settings immediately */ 22 | tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); 23 | 24 | } 25 | --------------------------------------------------------------------------------