Skip to content

The DeepRacer Web Server ROS package creates the web_publisher_node which launches a Flask application as a background thread and creates service clients and subscribers for all the services and topics that are required by the APIs called from the DeepRacer vehicle console.

License

Notifications You must be signed in to change notification settings

jsspric/aws-deepracer-webserver-pkg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepRacer Web Server Package

Overview

The DeepRacer Web Server ROS package creates the webserver_publisher_node which is part of the core AWS DeepRacer application and will be launched from the deepracer_launcher. More details about the application and the components can be found here.

This node launches a Flask application as a background thread and creates service clients and subscribers for all the services and topics that are required by the APIs called from the DeepRacer vehicle console. This node acts as an interface between the AWS DeepRacer device console and the backend ROS services.

License

The source code is released under Apache 2.0 (https://aws.amazon.com/apache-2-0/).

Installation

Prerequisites

The DeepRacer device comes with all the pre-requisite packages and libraries installed to run the webserver_pkg. More details about pre installed set of packages and libraries on the DeepRacer, and installing required build systems can be found in the Getting Started section of the AWS DeepRacer Opensource page.

The webserver_pkg specifically depends on the following ROS2 packages as build and execute dependencies:

  1. deepracer_interfaces_pkg - This packages contains the custom message and service type definitions used across the AWS DeepRacer core application.
  2. ctrl_pkg - The DeepRacer Control ROS package creates the ctrl_node which is part of the core AWS DeepRacer application.
  3. sensor_fusion_pkg - The DeepRacer Sensor Fusion ROS package creates the sensor_fusion_node which is part of the core AWS DeepRacer application.
  4. deepracer_systems_pkg - The DeepRacer Systems ROS package creates the software_update_node, model_loader_node, network_monitor_node and otg_control_node which is part of the core AWS DeepRacer application.
  5. device_info_pkg - The DeepRacer Device Info ROS package creates the device_info_node which is part of the core AWS DeepRacer application.
  6. i2c_pkg - The DeepRacer I2C ROS package creates the battery_node which is part of the core AWS DeepRacer application.

Downloading and Building

Open up a terminal on the DeepRacer device and run the following commands as root user.

  1. Switch to root user before you source the ROS2 installation:

     sudo su
    
  2. Source the ROS2 Foxy setup bash script:

     source /opt/ros/foxy/setup.bash 
    
  3. Create a workspace directory for the package:

     mkdir -p ~/deepracer_ws
     cd ~/deepracer_ws
    
  4. Clone the webserver_pkg on the DeepRacer device:

     git clone https://github.com/aws-deepracer/aws-deepracer-webserver-pkg.git
    
  5. Fetch unreleased dependencies:

     cd ~/deepracer_ws/aws-deepracer-webserver-pkg
     rosws update
    
  6. Resolve the webserver_pkg dependencies:

     cd ~/deepracer_ws/aws-deepracer-webserver-pkg && rosdep install -i --from-path . --rosdistro foxy -y
    
  7. Build the webserver_pkg, ctrl_pkg, sensor_fusion_pkg, deepracer_systems_pkg, device_info_pkg, i2c_pkg and deepracer_interfaces_pkg:

     cd ~/deepracer_ws/aws-deepracer-webserver-pkg && colcon build --packages-select webserver_pkg ctrl_pkg sensor_fusion_pkg deepracer_systems_pkg device_info_pkg i2c_pkg deepracer_interfaces_pkg
    

Usage

The webserver_publisher_node provide basic system level functionality for the AWS DeepRacer application to work. Although the node is built to work with the AWS DeepRacer application, it can be run independently for development/testing/debugging purposes.

Run the node

To launch the built webserver_publisher_node as root user on the DeepRacer device open up another terminal on the DeepRacer device and run the following commands as root user:

  1. Switch to root user before you source the ROS2 installation:

     sudo su
    
  2. Source the ROS2 Foxy setup bash script:

     source /opt/ros/foxy/setup.bash 
    
  3. Source the setup script for the installed packages:

     source ~/deepracer_ws/aws-deepracer-webserver-pkg/install/setup.bash 
    
  4. Launch the webserver_publisher_node using the launch script:

     ros2 launch webserver_pkg webserver_pkg_launch.py
    

Launch Files

The webserver_publisher_node provides the core functionality to launch the FLASK server and respond to the FLASK API calls. The webserver_pkg_launch.py is also included in this package that gives an example of how to launch the nodes independently from the core application.

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='webserver_pkg',
            namespace='webserver_pkg',
            executable='webserver_publisher_node',
            name='webserver_publisher_node'
        )
    ])

Node Details

webserver_publisher_node

Subscribed Topics

Topic Name Message Type Description
/deepracer_systems_pkg/software_update_pct SoftwareUpdatePctMsg Message with the latest software update percentage and status.

Published Topics

Topic Name Message Type Description
/webserver_pkg/calibration_drive ServoCtrlMsg Publish a message with raw pwm values for steering angle and throttle data sent to the servo package to calibrate the car.
/webserver_pkg/manual_drive ServoCtrlMsg Publish a message with steering angle and throttle data sent to the servo package to move the car.

Service Clients

Service Name Service Type Description
/ctrl_pkg/vehicle_state ActiveStateSrv Client to the vehicle state service to deactivate the current vehicle state and prepare the new mode.
/ctrl_pkg/enable_state EnableStateSrv Client to the enable state service to activate and deactivate the current vehicle mode.
/ctrl_pkg/get_car_cal GetCalibrationSrv Client to the get calibration service to get the current calibration value for the steering or throttle.
/ctrl_pkg/set_car_cal SetCalibrationSrv Client to the set calibration service to set the current calibration value for the steering or throttle.
/device_info_pkg/get_device_info GetDeviceInfoSrv Client to the get device info service to get the hardware and software version of DeepRacer device and packages.
/i2c_pkg/battery_level BatteryLevelSrv Client to the battery level service to get the current vehicle battery level ranging from [0 to 11].
/sensor_fusion_pkg/sensor_data_status SensorStatusCheckSrv Client to the sensor data status service to get the sensor connection status for single camera/stereo camera and LiDAR.
/ctrl_pkg/set_car_led SetLedCtrlSrv Client to set car led service to set the tail light LED values.
/ctrl_pkg/get_car_led GetLedCtrlSrv Client to get car led service to get the tail light LED values.
/ctrl_pkg/get_ctrl_modes GetCtrlModesSrv Client to get the available modes of operation for vehicle.
/deepracer_systems_pkg/verify_model_ready VerifyModelReadySrv Client to verify model service to validate if the extraction and installation of the model was successful.
/sensor_fusion_pkg/configure_lidar LidarConfigSrv Client to configure lidar service to dynamically configure the preprocessing details for the LiDAR data before publishing as part of sensor message.
/ctrl_pkg/model_state ModelStateSrv Client to model state service to execute the load model services in background thread.
/ctrl_pkg/is_model_loading GetModelLoadingStatusSrv Client to is model loading service to know if there is load model operation going on right now on the device.
/deepracer_systems_pkg/console_model_action ConsoleModelActionSrv Client to trigger the upload/delete models action from device console.
/deepracer_systems_pkg/software_update_check SoftwareUpdateCheckSrv Client to the software update check service to find out if there is a software update available for the aws-deepracer packages.
/deepracer_systems_pkg/begin_update BeginSoftwareUpdateSrv Client to the begin update service to trigger the update of the aws-deepracer debian packages to the latest software version available.
/deepracer_systems_pkg/software_update_state SoftwareUpdateStateSrv Client to software update state service to get the current software update state from the states [ UPDATE_UNKNOWN, UP_TO_DATE, UPDATE_AVAILABLE, UPDATE_PENDING, UPDATE_IN_PROGRESS ].
/ctrl_pkg/autonomous_throttle NavThrottleSrv Client to autonomous throttle service to set the scale value to multiply to the throttle during autonomous navigation.
/deepracer_systems_pkg/get_otg_link_state OTGLinkStateSrv Client to the get otg link state service to get the current connection status of micro-USB cable to the DeepRacer device.

Resources

About

The DeepRacer Web Server ROS package creates the web_publisher_node which launches a Flask application as a background thread and creates service clients and subscribers for all the services and topics that are required by the APIs called from the DeepRacer vehicle console.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%