Skip to content

mongodb-partners/Vehicle-Digital-Twin-Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 

Repository files navigation

Setup Instructions for MongoDB and Amazon SageMaker Integration

To configure the first 3 parts of your Digital Twin, please refer to the Vehicle-Digital-Twin-Feedback-Loop repository.

Step-by-step instructions

Setup the AWS Backend

  1. Create an AWS Account.

  2. Take note of your AWS Account ID as you'll need it to update your AWS Account ID in ./Connected-Vehicle/triggers/eventbridge_publish_battery_telemetry.json

  3. To publish battery telemetry information to Eventbridge, please follow these steps in MongoDB Atlas under the App Services tab:

    • Navigate to the "Triggers" tab

    • Click on your eventbridge_publish_battery_telemetry trigger:

    image

    • Under the "Function" Section select "EventBridge" as the Event Type

      • Update your AWS Account ID

      • Select an AWS Region

    image

    • Now expand the advanced options and copy/paste the following code into the Project Expression:
             {
                   "operationType": {
                    "$numberInt": "1"
                },
                "vin": "$fullDocument.vin",
                "read": {
                    "$map": {
                        "input": "$fullDocument.measurements",
                        "as": "item",
                        "in": [
                            "$$item.voltage",
                            "$$item.current"
                        ]
                    }
                }
            }
    • You should see the following: image

Setup SageMaker

If not already completed, please refer to the link for prerequisites and setup of SageMaker domain.

Deploy the SageMaker model "Predictive Maintenance for Vehicle Fleets" to get the end-point.

image image

Building the Code

Replace the SageMaker end-point with the one generated above here.

Lambda Functions

Create two lambda functions:

  1. For pulling the data from MongoDB cluster, refer this function.
  2. For pushing the predicted data back to MongoDB cluster, refer this function.

Please follow this guide.

Create Rules for AWS Eventbus

1. Eventbus for capturing MongoDB changes

Add the rule name, description and the eventbus from the dropdown.

image

Select the first option for Event source to pull data from MongoDB.

image

Select options for Event source, Partner and Event type as selected below.

image

Add previously created Lambda as target and create the rule.

image

2. Eventbus for capturing events sent from Lambda function

This rule is created to move data between lambda functions. image

Select other when selecting event source. image

Add below event pattern to be able to send data using python function.

{
    "source": ["user-event"],
    "detail-type": ["user-preferences"]
}

image

Sample output

On simulating the connected vehichle application the volatage and current of the vehichle are analysed for percentage of failure. The inference is stored back in MongoDB Atlas.

image

Conclusion

This gives a working template to setup an end-to-end flow for connected vehicles, to analyze its telemetric data using MongoDB Atlas and AWS Services.

Return to Part 4, if you are interested in running the Vehicle-Digital-Twin-Feedback-Loop!

For any further information, please contact [email protected]

About

MongoDB and AWS integration for connected vehicles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •