Skip to content

4.9 File Manager

Overview

FileManager is used to upload, download, delete, or search resources such as robot programs, trajectories, and temporary files between the host computer and the robot controller, supporting management and operations for multiple file types.

Core Features

  • Support for uploading local files to the robot controller
  • Support for downloading robot files to local directories
  • Support for deleting files from the robot controller
  • Support searching files by filename pattern
  • Support for managing multiple file types (USER_PROGRAM, BLOCK_PROGRAM, TRAJECTORY, ROBOT_TMP)
  • Support for overwrite control during upload/download

Use Cases

  • Deploy programs to the robot controller
  • Back up programs and trajectory files on the robot
  • Synchronize debug data from production lines
  • Batch manage and query robot files
  • Upload temporary data files to the robot
  • Download robot logs or output files to local

4.9.1 Upload a Local File to the Robot

Method Namefile_manager.upload( file_path : str, file_type : str, overwriting : bool = False) -> StatusCodeEnum
DescriptionUploads a local file to the robot controller.
Request Parametersfile_path : str Local file absolute path.
file_type : str File type (USER_PROGRAM: file_path is the program name path; uploads json / xml from the same directory; BLOCK_PROGRAM: file_path is the block program name path; uploads block / json / xml from the same directory; TRAJECTORY: file_path is full trajectory file path; ROBOT_TMP: file_path is full temp file path).
overwriting : bool Overwrite same-name file (default False ).
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+
NoteFor USER_PROGRAM and BLOCK_PROGRAM , specify only the program name (i.e., filename without extension).

4.9.2 Download a Robot File to Local

Method Namefile_manager.download( file_name : str, file_path : str, file_type : str, overwriting : bool=False) -> StatusCodeEnum
DescriptionDownloads a file from the robot to a local directory.
Request Parametersfile_name : str File name.
file_path : str Local save directory.
file_type : str File type ( BLOCK_PROGRAM not supported for download).
overwriting : bool Overwrite same-name file.
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+
NoteFor USER_PROGRAM , specify only the program name (i.e., filename without extension); the system downloads the matching .json / .xml . For TRAJECTORY , provide the full filename with .trajectory . For ROBOT_TMP , provide the full filename with suffix (e.g., .csv ).

4.9.3 Delete a File on the Robot

Method Namefile_manager.delete( file_name : str, file_type : str) -> StatusCodeEnum
DescriptionDeletes a file from the robot controller.
Request Parametersfile_name : str File name.
file_type : str File type.
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+
NoteFor USER_PROGRAM / BLOCK_PROGRAM , specify only the program name (i.e., filename without extension). For TRAJECTORY / ROBOT_TMP , provide the full filename with suffix.

4.9.4 Search Files by Filename Pattern

Method Namefile_manager.search( pattern : str, file_list : list) -> StatusCodeEnum
DescriptionSearches for files on the controller that match the filename pattern.
Request Parameterspattern : str Filename match pattern.
file_list : list Output list (receives matching filenames).
Return ValueStatusCodeEnum: Result of the function execution.
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

Example Code

file_manager/file_manager.py
py
#!python
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.
Instruction: 文件操作, 上传下载示例 / Example of file operation, upload and download
"""

from pathlib import Path

from Agilebot import ROBOT_TMP, TRAJECTORY, USER_PROGRAM, FileManager, StatusCodeEnum

current_path = Path(__file__)
path = str(current_path)

# [ZH] 连接文件管理服务
# [EN] Connect to the file management service
file_manager = FileManager("10.27.1.254")

# [ZH] 上传其他文件
# [EN] Upload other files
tmp_file_path = path.replace("file_manager.py", "test.csv")
ret = file_manager.upload(tmp_file_path, ROBOT_TMP, True)
if ret == StatusCodeEnum.OK:
    print("文件上传成功 / File upload successful")
else:
    print(f"文件上传失败,错误代码 / File upload failed, error code: {ret.errmsg}")
    exit(1)

# [ZH] 上传程序
# [EN] Upload a program
prog_file_path = path.replace("file_manager.py", "test_prog")
ret = file_manager.upload(prog_file_path, USER_PROGRAM, True)
if ret == StatusCodeEnum.OK:
    print("程序上传成功 / Program upload successful")
else:
    print(f"程序上传失败,错误代码 / Program upload failed, error code: {ret.errmsg}")
    exit(1)

# [ZH] 上传轨迹
# [EN] Upload a trajectory
trajectory_file_path = path.replace("file_manager.py", "test_torque.trajectory")
ret = file_manager.upload(trajectory_file_path, TRAJECTORY, True)
if ret == StatusCodeEnum.OK:
    print("轨迹上传成功 / Trajectory upload successful")
else:
    print(f"轨迹上传失败,错误代码 / Trajectory upload failed, error code: {ret.errmsg}")
    exit(1)

# [ZH] 搜索文件
# [EN] Search for files
file_list = list()
ret = file_manager.search("test.csv", file_list)
if ret == StatusCodeEnum.OK:
    print("文件搜索成功 / File search successful")
else:
    print(f"文件搜索失败,错误代码 / File search failed, error code: {ret.errmsg}")
    exit(1)
print("搜索文件:", file_list)

# [ZH] 下载文件
# [EN] Download a file
download_file_path = path.replace("file_manager.py", "download")
ret = file_manager.download("test_torque", download_file_path, file_type=TRAJECTORY)
if ret == StatusCodeEnum.OK:
    print("文件下载成功 / File download successful")
else:
    print(f"文件下载失败,错误代码 / File download failed, error code: {ret.errmsg}")
    exit(1)

# [ZH] 删除文件
# [EN] Delete a file
ret = file_manager.delete("test_torque.trajectory", TRAJECTORY)
if ret == StatusCodeEnum.OK:
    print("文件删除成功 / File delete successful")
else:
    print(f"文件删除失败,错误代码 / File delete failed, error code: {ret.errmsg}")
    exit(1)