├── readmeimages ├── ros_app.png ├── dcv_setup.png ├── webrtc_after.png ├── webrtc_before.png ├── attach_ec2_role.png ├── create_ec2_role.png ├── kvs_screenshot.png └── kvs_webrtc_live.png ├── CODE_OF_CONDUCT.md ├── user_scripts ├── rtsp_command.txt ├── setup_with_sudo.bash ├── setup_as_user.bash └── utility_bash_functions ├── LICENSE ├── CONTRIBUTING.md └── README.md /readmeimages/ros_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/ros_app.png -------------------------------------------------------------------------------- /readmeimages/dcv_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/dcv_setup.png -------------------------------------------------------------------------------- /readmeimages/webrtc_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/webrtc_after.png -------------------------------------------------------------------------------- /readmeimages/webrtc_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/webrtc_before.png -------------------------------------------------------------------------------- /readmeimages/attach_ec2_role.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/attach_ec2_role.png -------------------------------------------------------------------------------- /readmeimages/create_ec2_role.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/create_ec2_role.png -------------------------------------------------------------------------------- /readmeimages/kvs_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/kvs_screenshot.png -------------------------------------------------------------------------------- /readmeimages/kvs_webrtc_live.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/HEAD/readmeimages/kvs_webrtc_live.png -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /user_scripts/rtsp_command.txt: -------------------------------------------------------------------------------- 1 | pipeline = gst_parse_launch( 2 | "rtspsrc location=rtsp://0.0.0.0:8554/back short-header=TRUE ! rtph264depay ! " 3 | "video/x-h264,stream-format=byte-stream,alignment=au,profile=baseline ! " 4 | "appsink sync=TRUE emit-signals=TRUE name=appsink-video", 5 | &error); 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /user_scripts/setup_with_sudo.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install gstreamer libraries used by kvs, ros-rtsp 4 | apt-get install -y libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev libgstrtspserver-1.0-dev 5 | apt-get install -y libssl-dev libcurl4-openssl-dev liblog4cplus-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-bad gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-tools 6 | 7 | # Install VLC 8 | snap install vlc 9 | 10 | # Install jq utility for json parsin 11 | apt-get install -y jq 12 | 13 | # Misc software and initialize rosdep 14 | apt install -y git tar terminator 15 | apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common 16 | pip install --upgrade pip 17 | apt install -y python-rosdep python-rosinstall-generator python-wstool build-essential unzip 18 | rosdep init 19 | 20 | # Install aws cli 21 | curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 22 | unzip awscliv2.zip 23 | ./aws/install 24 | 25 | # Install ros related packages 26 | apt install -y ros-melodic-gazebo-ros ros-melodic-gazebo-ros-pkgs ros-melodic-gazebo-ros-control 27 | apt install -y ros-melodic-controller-manager ros-melodic-lms1xx ros-melodic-velodyne-description 28 | apt install -y ros-melodic-robot-localization ros-melodic-interactive-marker-twist-server ros-melodic-twist-mux 29 | apt install -y ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-pointcloud-to-laserscan 30 | apt install -y ros-melodic-map-server ros-melodic-amcl ros-melodic-move-base ros-melodic-realsense2-description 31 | apt install -y ros-melodic-hector-gazebo ros-melodic-joint-state-controller ros-melodic-diff-drive-controller 32 | apt install -y ros-melodic-dwa-local-planner -------------------------------------------------------------------------------- /user_scripts/setup_as_user.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | APP_DIRECTORY=/home/ubuntu/environment 4 | touch ~/.bash_aliases 5 | echo "source $APP_DIRECTORY/utility_bash_functions" >> ~/.bash_aliases 6 | echo "source ~/.bash_aliases" >> ~/.bashrc 7 | # Setup sample ros application 8 | if [ -d $APP_DIRECTORY ]; then 9 | mkdir -p $APP_DIRECTORY 10 | fi 11 | cd $APP_DIRECTORY 12 | git clone https://github.com/aws-samples/multi-robot-fleet-sample-application.git 13 | cd $APP_DIRECTORY/multi-robot-fleet-sample-application/simulation_ws 14 | git checkout 270da92 15 | source /opt/ros/melodic/setup.sh 16 | echo "source /opt/ros/melodic/setup.bash" >> ~/.bash_aliases 17 | rosws update 18 | 19 | # clone ros images to rtsp stream rospackage. This needs gstreamer plugins setup in root script 20 | git clone https://github.com/konduri/ros_rtsp.git $APP_DIRECTORY/multi-robot-fleet-sample-application/simulation_ws/src/deps/ros_rtsp 21 | 22 | # Install dependencies 23 | pip install roslibpy 24 | rosdep install --from-paths $APP_DIRECTORY/multi-robot-fleet-sample-application/simulation_ws/src -r -y --skip-keys roslibpy-pip 25 | catkin_make 26 | 27 | # Setup sourcing in the bash aliases 28 | source $APP_DIRECTORY/multi-robot-fleet-sample-application/simulation_ws/devel/setup.bash 29 | echo "source $APP_DIRECTORY/multi-robot-fleet-sample-application/simulation_ws/devel/setup.bash" >> ~/.bash_aliases 30 | 31 | 32 | 33 | ## Setup webrtc here 34 | cd $APP_DIRECTORY 35 | #git clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git 36 | 37 | git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git 38 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c;git checkout 54c4138; git submodule update --recursive 39 | 40 | mkdir $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 41 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 42 | cmake .. 43 | make 44 | 45 | 46 | 47 | # Setup KVS sink 48 | cd $APP_DIRECTORY 49 | git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git 50 | mkdir $APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/build 51 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/build 52 | cmake .. -DBUILD_GSTREAMER_PLUGIN=TRUE 53 | make 54 | 55 | export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/build 56 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/open-source/local/lib 57 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /user_scripts/utility_bash_functions: -------------------------------------------------------------------------------- 1 | ros_app_launch() { 2 | export START_X=0 # start location of robot 3 | export START_Y=0 4 | export START_YAW=0 5 | export HUSKY_REALSENSE_ENABLED=true 6 | export HUSKY_LMS1XX_ENABLED=true 7 | roslaunch robot_fleet husky_app_with_rtsp.launch 8 | } 9 | 10 | build_and_run_webrtc() { 11 | # build code again 12 | echo "building webrtc code" 13 | APP_DIRECTORY=/home/ubuntu/environment 14 | mkdir $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 15 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 16 | cmake .. 17 | make 18 | 19 | export AWS_KVS_LOG_LEVEL=3 20 | 21 | # run the binary 22 | echo "launching webrtc app" 23 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build/samples 24 | 25 | echo "create signalling channel, in case it doesnt exist" 26 | aws kinesisvideo create-signaling-channel --channel-name robot_webrtc_stream 27 | sleep 3 28 | ./kvsWebrtcClientMasterGstSample robot_webrtc_stream 29 | } 30 | 31 | 32 | run_kinesis_stream() { 33 | # set env vars to recognize the kvs plugin 34 | APP_DIRECTORY=/home/ubuntu/environment 35 | export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/build 36 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/open-source/local/lib 37 | 38 | export AWS_KVS_LOG_LEVEL=3 39 | 40 | # Make create stream api everytime for simplicity. It just fails if it already exists. 41 | echo "Creating a new stream if it doesnt exist" 42 | aws kinesisvideo create-stream --stream-name "robot_kvs_stream" --data-retention-in-hours "120" 43 | sleep 3 44 | echo "setting up kvs streaming" 45 | gst-launch-1.0 -v rtspsrc location=rtsp://0.0.0.0:8554/back drop-on-latency=true use-pipeline-clock=true do-retransmission=false latency=0 ! rtph264depay ! h264parse ! kvssink stream-name="robot_kvs_stream" storage-size=512 aws-region=$AWS_REGION 46 | } 47 | 48 | # For role attached to ec2 EC2 only 49 | creds_from_role_attached() { 50 | export AWS_ACCESS_KEY_ID=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.AccessKeyId'` 51 | export AWS_SECRET_ACCESS_KEY=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.SecretAccessKey'` 52 | export AWS_SESSION_TOKEN=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.Token'` 53 | export ACCESS_KEY_ENV_VAR=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.AccessKeyId'` 54 | export SECRET_KEY_ENV_VAR=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.SecretAccessKey'` 55 | export SESSION_TOKEN_ENV_VAR=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$1 | jq -r '.Token'` 56 | export AWS_REGION=`aws configure get default.region` 57 | export AWS_DEFAULT_REGION=$AWS_REGION 58 | } 59 | 60 | # Pull creds from .aws/credentials/default 61 | creds_from_default_file() { 62 | export AWS_ACCESS_KEY_ID=`aws configure get default.aws_access_key_id` 63 | export AWS_SECRET_ACCESS_KEY=`aws configure get default.aws_secret_access_key` 64 | export AWS_SESSION_TOKEN=`aws configure get default.aws_session_token` 65 | export AWS_REGION=`aws configure get default.region` 66 | 67 | export ACCESS_KEY_ENV_VAR=$AWS_ACCESS_KEY_ID 68 | export SECRET_KEY_ENV_VAR=$AWS_SECRET_ACCESS_KEY 69 | export SESSION_TOKEN_ENV_VAR=$AWS_SESSION_TOKEN 70 | export AWS_DEFAULT_REGION=$AWS_REGION 71 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Objective: 2 | 3 | This workshop showcases video solutions for robotics using [Amazon Kinesis Video Streams](https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/what-is-kinesis-video.html), and [Amazon Kinesis Video Streams with WebRTC](https://docs.aws.amazon.com/kinesisvideostreams-webrtc-dg/latest/devguide/what-is-kvswebrtc.html). The image/video data from the robot is setup using a [simulation application](https://github.com/aws-samples/multi-robot-fleet-sample-application) in **Gazebo/ROS**. We convert the Image ROS-topic to and RTSP stream using the [ROS-RTSP ROS-package](https://github.com/CircusMonkey/ros_rtsp) 4 | 5 | **NOTE:** 6 | - You can skip the simulation setup if you already have an IP Camera with an RTSP URL 7 | - This demo uses Gstreamer based examples, primarily for ease of use. Please evaulate official SDK's and [documentation](https://docs.aws.amazon.com/kinesis/index.html) for production use case 8 | 9 | 10 | 11 | ## Setup 12 | Have an Ubuntu 18.04 machine with ROS Melodic installed and AWS credential setup as env variables on the local machine. Specifically 13 | * AWS_REGION 14 | * AWS_ACCESS_KEY_ID 15 | * AWS_SECRET_ACCESS_KEY 16 | * AWS_SESSION_TOKEN (optional) 17 | 18 | For this workshop, we recommend using the AWS RoboMaker development environment, for which these instructions have been tested against 19 | 20 | ### AWS RoboMaker development environment setup 21 | 22 | 1. Setup a Melodic Ubuntu 18.04 instance by selecting the corresponding AWS RoboMaker development environment as shown in image below 23 | ![image](readmeimages/dcv_setup.png) 24 | 25 | 26 | 2. Create a role with 'AmazonKinesisVideoStremsFullAccess' managed policy as shown in the image below. Name the role as `ec2_kinesis_video_role` 27 | ![image](readmeimages/create_ec2_role.png) 28 | 29 | **NOTE: This policy gives access to all kinesis API's. In production, you should [create custom policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html) specific to your requirements** 30 | 31 | 3. Attach it to your EC2 instance following the instructions [here](https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/) , as shown below 32 | ![image](readmeimages/attach_ec2_role.png) 33 | 34 | 35 | ## Application setup 36 | 37 | Clone this [repository](https://github.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/) onto the development environment, preferably under "/home/ubuntu/environment location" 38 | 39 | 40 | ``` 41 | cd /home/ubuntu/environment 42 | git clone https://github.com/aws-samples/robot-camera-streaming-demo-with-aws-kvswebrtc-kvs.git 43 | ``` 44 | 45 | Run the following command to install corresponding [libararies, software](setup_with_sudo.bash) and the [robot and kvs applications](user_scripts/setup_as_user.bash) 46 | 47 | ``` 48 | cd robot-camera-streaming-demo-with-aws-kvswebrtc-kvs/user_scripts 49 | sudo bash setup_with_sudo.bash; bash setup_as_user.bash 50 | ``` 51 | 52 | Once the above command is completed, change the sample application code present in the sample application source code present in your environment. You can open the file with the following commands if you used the default setup 53 | ``` 54 | cd /home/ubuntu/environment/amazon-kinesis-video-streams-webrtc-sdk-c/samples/ 55 | vim kvsWebRTCClientMasterGstreamerSample.c 56 | ``` 57 | 58 | The code is change is shown in before and after pictures below 59 | ![before_image](readmeimages/webrtc_before.png) 60 | ![after_image](readmeimages/webrtc_after.png) 61 | 62 | You can find the file with the code to copy [here](user_scripts/rtsp_command.txt) , with the end code as 63 | ``` 64 | pipeline = gst_parse_launch( 65 | "rtspsrc location=rtsp://0.0.0.0:8554/back short-header=TRUE ! rtph264depay ! " 66 | "video/x-h264,stream-format=byte-stream,alignment=au,profile=baseline ! " 67 | "appsink sync=TRUE emit-signals=TRUE name=appsink-video", 68 | &error); 69 | ``` 70 | 71 | ## Launch Applications 72 | 73 | ### Launch ROS Application 74 | Click `Launch Desktop` button on cloud9 to access the GUI on the browser. Access the terminal via `Activities -> terminator` 75 | Once you have a terminal setup, run the ros appication by running the following command 76 | ``` 77 | export START_X=0 # start location of robot 78 | export START_Y=0 79 | export START_YAW=0 80 | export HUSKY_REALSENSE_ENABLED=true 81 | export HUSKY_LMS1XX_ENABLED=true 82 | roslaunch robot_fleet husky_app_with_rtsp.launch 83 | ``` 84 | 85 | This should setup a ros and gazebo setup like the following ![image](readmeimages/ros_app.png) 86 | 87 | ### Launch Webrtc application 88 | While the ROS application is running, open another new terminal set the credentials on the env variables using 89 | ``` 90 | creds_from_role_attached ec2_kinesis_video_role #Or name you have provided to the ec2 role 91 | ``` 92 | 93 | Once the credentials are setup, you can setup the webrtc application by running the following commands *IN THE SAME TERMINAL WHERE YOU SETUP CREDENTIALS* 94 | ``` 95 | # build code again since we modified it with new gst-pipeline 96 | 97 | echo "building webrtc code" 98 | APP_DIRECTORY=/home/ubuntu/environment 99 | mkdir $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 100 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build 101 | cmake .. 102 | make 103 | 104 | # Set environment variable for log level 105 | export AWS_KVS_LOG_LEVEL=3 106 | 107 | # move to location of built code 108 | echo "launching webrtc app" 109 | cd $APP_DIRECTORY/amazon-kinesis-video-streams-webrtc-sdk-c/build/samples 110 | 111 | # Create signalling channel 112 | echo "create signalling channel, in case it doesnt exist" 113 | aws kinesisvideo create-signaling-channel --channel-name robot_webrtc_stream 114 | sleep 3 115 | 116 | # Launch the application 117 | ./kvsWebrtcClientMasterGstSample robot_webrtc_stream 118 | ``` 119 | 120 | This will create a KVS webrtc connection between the robot and your browser. You can view it on the Console page by selecting the corresponding signaling channel as following. ![kvs_webrc_image](readmeimages/kvs_webrtc_live.png) 121 | 122 | ### Launch KVS video stream application 123 | 124 | Setup the credentials in the new terminal using the command 125 | ``` 126 | creds_from_role_attached ec2_kinesis_video_role #Or name you have provided to the ec2 role 127 | ``` 128 | 129 | Setup the KVS stream from the same terminal from which you have the credentials using the following commands 130 | ``` 131 | # set env vars to recognize the kvs plugin 132 | APP_DIRECTORY=/home/ubuntu/environment 133 | export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/build 134 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_DIRECTORY/amazon-kinesis-video-streams-producer-sdk-cpp/open-source/local/lib 135 | 136 | export AWS_KVS_LOG_LEVEL=3 137 | 138 | # Make create stream api everytime for simplicity. It just fails if it already exists. 139 | echo "Creating a new stream if it doesnt exist" 140 | aws kinesisvideo create-stream --stream-name "robot_kvs_stream" --data-retention-in-hours "120" 141 | sleep 3 142 | echo "setting up kvs streaming" 143 | gst-launch-1.0 -v rtspsrc location=rtsp://0.0.0.0:8554/back drop-on-latency=true use-pipeline-clock=true do-retransmission=false latency=0 ! rtph264depay ! h264parse ! kvssink stream-name="robot_kvs_stream" storage-size=512 aws-region=$AWS_REGION 144 | ``` 145 | 146 | You can then view the current and historical data that is streamed from the robot on the AWS console by selecting the corresponding video stream on the kvs page, as show in the image below. 147 | ![kvs_image](readmeimages/kvs_screenshot.png) 148 | 149 | 150 | All the commands for launching applications are available from this [file](user_scripts/utility_bash_functions) 151 | 152 | ## Clean up 153 | 154 | You can kill the processes by running `Ctrl + c` on all the tabs. The webrtc process does not die untill the ROS application is killed. 155 | 156 | - Delete the cloud9 environment from `AWS RoboMaker -> Development environment -> Delete` 157 | - Delete the webrt signalling channel from `KVS Video Streams -> Signaling Channels -> Delete` 158 | - Delete the KVS video stream from `KVS Video Streams -> Video Streams -> Delete` 159 | - Delete the EC2 role from `IAM -> Roles -> ec2_kinesis_video_role -> Delete Role` 160 | 161 | 162 | ## Security 163 | 164 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 165 | 166 | ## License 167 | 168 | This library is licensed under the MIT-0 License. See the LICENSE file. 169 | 170 | --------------------------------------------------------------------------------