Configure Data Capture

The data management service captures data from one or more components locally on the machine’s storage. The process runs in the background and, by default, stores data in the ~/.viam/capture directory.

If a machine restarts for any reason, capture automatically resumes.

The service can capture data from multiple components at the same or different frequencies. Viam does not impose a lower or upper limit on the frequency of data collection. However, in practice, your hardware may impose limits on the frequency of data collection.

You can change the frequency of data capture at any time for individual components. If you use fragments, you can change the frequency of data capture in real time for some or all machines in a fleet at the component or machine level.

For example, consider a tomato picking robot with a 3D camera and an arm. When you configure the robot, you may set the camera to capture point cloud data at a frequency of 30Hz. For the arm, you may want to capture joint positions at 1Hz. If your requirements change and you want to capture data from both components at 10Hz, you can change the configurations at any time by changing the number.

Data capture is frequently used with Cloud Sync. However, if you want to manage your machine’s captured data yourself, you can enable only data capture without cloud sync.

Add the data management service

To capture data from one or more machines, you must first add the data management service:

  1. Navigate to the CONFIGURE tab of your machine’s page in the Viam app.

  2. Click the + icon next to your machine part in the left-hand menu and select Service.

  3. Select the data management type, then either use the suggested name or specify a name for your data management service, for example data-manager.

  4. Click Create.

  5. On the panel that appears, you can manage the capturing and syncing functions and specify the Directory, the sync Interval and any Tags to apply to captured data.

    If the sync Interval or the Directory is not specified, the data management service captures data at the default frequency every 0.1 minutes (after every 6 second interval) in the default ~/.viam/capture directory.

  6. Click the Save button in the top right corner of the page.

data capture configuration

Click to view the JSON configuration for the data management service

Configure data capture for individual components

Once you have added the data capture service, you can specify the data you want to capture at a component level. The following components support data capture:

  • Arm
  • Board
  • Camera
  • Encoder
  • Gantry
  • Motor
  • Movement Sensor (includes GPS)
  • Sensor
  • Servo

To add data capture for a component, navigate to the CONFIGURE tab of your machine’s page in the Viam app.

For each component you can capture data for, there is a Data capture section in its panel. Click Add Method and then select the Method type and the capture Frequency.

Click the Save button in the top right corner of the page.

Now your data will be saved locally on your machine to the directory specified in the data management service.

For example, a camera has the options ReadImage and NextPointCloud and a motor has the options Position and IsPowered.

component config example

Click to view an example JSON configuration capturing data from the ReadImage method of a camera

You may capture data from one or more component methods:

  • To enable or disable data capture for a configured component or method, use the on/off toggle.
  • To change the frequency of data capture for a method, enter the number of measurements you wish to capture per second in the frequency field.

After adding configuration for the methods, click the Save button in the top right corner of the page.

If you want to remove a capture method from the configuration, click the delete icon.

Configure data capture for remote parts

Viam supports data capture from resources on remote parts. For example, if you use a part that does not have a Linux operating system or that does not have enough storage or processing power, you can still process and capture the data from that part’s components by adding it as a remote part.

Currently, you can only configure data capture from remote components in your JSON configuration. To add them to your JSON configuration you must explicitly add the remote component’s type, model, name, and additional_params to the data_manager service configuration in the remotes configuration:

KeyDescription
typeThe type tells your machine what the component is. For example, a board.
modelThe model is a colon-delimited-triplet that specifies the namespace, the type of the part, and the part itself.
nameThe name specifies the fully qualified name of the part.
additional_paramsThe additional parameters specify the data sources when you are using a board.
Click to view example JSON configuration for an ESP32 board
Click to view the JSON configuration for capturing data from two analog readers and a pin of the board's GPIO
Click to view the JSON configuration for capturing data from a camera

View captured data

To view captured data for a machine, click on the data icon next to the Save button on the top right of the app.

Data icon

To view captured data for a machine part, click on the menu in the top right of its card or the menu in the machine resources list in the Builder menu and select View captured data.

Machine menu with the options Rename, Restart part, View captured data, View setup instructions, View history, View debug configuration, and Delete machine

To view captured data for a component or service, click on the menu in the top right of its card and select View captured data.

Resource menu with the options Rename, Duplicate, View captured data, and Delete

To view all the captured data you have access to, see View Data.

Troubleshooting

Images are dim on start up

If you are capturing camera data, it can happen that the camera captures and syncs miscolored or dark images upon start up.

Next steps

To sync your captured data with the cloud, configure cloud sync.

If you have synced tabular data, such as sensor readings, you can query that data with SQL or MQL from the Viam app or a MQL-compatible client. If you have synced images, you can use those images to train machine learning models within the Viam app.

For a comprehensive tutorial on using data capture and synchronization together with the ML model service, see Capture Data and Train a Model.

To learn how to capture Performance Metrics for machines, see Performance Monitoring Data Capture.