getFile
Get file from device
Description
getFile(
copies the specified file from the ROS or ROS 2 device to the MATLAB® current folder. Wildcards are supported.device
,remoteSource
)
getFile(
copies
the remote file to a destination path. Specify a file name at the
end of the destination path to copy with a custom file name.device
,remoteSource
,localDestination
)
Examples
Put, Get, and Delete Files on ROS Device
Put a file from your host computer onto a ROS device, get it back, and then delete it.
Connect to a ROS device. Specify the device address, user name, and password of your ROS device.
d = rosdevice('192.168.17.128','user','password');
Put a new text file that is in the MATLAB(R) current folder onto the ROS device. The destination folder must exist.
putFile(d,'test_file.txt','/home/user/test_folder')
Get a text file from the ROS device. You can get any file, not just ones added from MATLAB(R). By default, the file is added to the MATLAB current folder.
getFile(d,'/home/user/test_folder/test_file.txt')
Delete the text file on the ROS device.
deleteFile(d,'/home/user/test_folder/test_file.txt')
Put, Get, and Delete Files on ROS Device Using Wildcards
Put a file from your host computer onto a ROS device, get it back, and then delete it. Use wildcards to search for all matching files.
Note: You must have a valid ROS device to connect to at the IP address specified in the example.
Connect to a ROS device. Specify the device address, user name, and password of your ROS device.
d = rosdevice('192.168.17.128','user','password');
Put all text files at the specified path onto the ROS device. The destination folder must exist.
putFile(d,'C:/MATLAB/*.txt','/home/user/test_folder')
Get all text files from the ROS device. You can get any files, not just ones added from MATLAB(R). By default, the files are added to the MATLAB current folder.
getFile(d,'/home/user/test_folder/*.txt')
Delete all text files on the ROS device at the specified folder.
deleteFile(d,'/home/user/test_folder/*.txt')
Input Arguments
device
— ROS or ROS 2 device
rosdevice
object | ros2device
object
ROS or ROS 2 device, specified as a rosdevice
or ros2device
object, respectively.
remoteSource
— Path and name of file on the device
source path
Path and name of the file on the device. Specify the path as a character vector. You can use an absolute path or a relative path from the MATLAB current folder. Use the path and file naming conventions of the operating system on your host computer.
Example: '/home/user/test_folder/test_file.txt'
Data Types: char
localDestination
— Destination folder path and optional file name
character vector
Destination folder path and optional file name, specified as a character vector. Specify a file name at the end of the destination path to copy with a custom file name. Use the host computer path and file naming conventions.
Example: 'C:/User/username/test_folder'
Data Types: char
Version History
Introduced in R2019b
See Also
rosdevice
| ros2device
| putFile
| deleteFile
| dir
| openShell
| system
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)