Skip to content

A ROS actionlib interface for Rsync

License

Notifications You must be signed in to change notification settings

ascentai/rsync_ros

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rsync_ros

Build Status

Overview

This package brings Rsync operations (file transfer and syncronization) to ROS in the form of an actionlib interface. Making it convenient to transfer files from one machine to another using ROS. Progress from transfers is published as action feedback.

Potential Use Cases

An RsyncAction goal could be sent once a robot has reached a certain state. A file (e.g. a logfile or bagfile) could be then be transferred to a remote fileserver for storage.

Why Rsync?

Rsync is a fast and versatile utility for file transfer, it is widely used for backups and mirroring, as well as an improved copy command for everyday use. It can copy locally, to/from another host over any remote shell, offering a large number of options that control every aspect of its behavior. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination.

Usage

To start the action server

rosrun rsync_ros rsync_server_node.py

To start the Service server

roslaunch rsync_ros rsync_ros_node.launch

CLI Actionlib Client Example

examples/rsync_client_example.py, a simple client based on the actionlib_tutorials simple actionlib client.

CLI Service Client Example

TODO

Local transfer

rosrun rsync_ros rsync_client_example.py -avzp ~/a_file.txt ~/file_dest.txt

Remote transfer using Action

You will first need to set up ssh keys for the remote machine, see this tutorial
rosrun rsync_ros rsync_client_example.py -avzp ~/a_file.txt ssh_user@remote_host:~/file_dest.txt

Remote transfer using Action

TODO

Choosing Rysnc Arguments

The server passes all arguments listed in rsync_args to Rsync, although not all of the Rsync arguments have been tested. If you're unfamiliar with RSync, have a look at the manual to see the full list of arguments.

TL;DR The -avz argument works well for copy operations, and -avz --delete-source-files arguments for move operations. The -p argument (Partial Transfer) is particuarly useful for dealing with unreliable (wireless) connections.

Simple Python Actionlib example

#!/usr/bin/env python
import rospy
import roslib; roslib.load_manifest('rsync_ros')
import actionlib
import rsync_ros.msg
import sys

rospy.init_node('rsync_client')

source_path =  '~/a_file.txt'
dest_path = '[email protected]:~/file_dest.txt'

# Create the SimpleActionClient, passing RsyncAction to the constructor.
client = actionlib.SimpleActionClient('rsync_ros', rsync_ros.msg.RsyncAction)

# Wait until the action server has started up and started
# listening for goals.
client.wait_for_server()

# Create a goal to send to the action server.
goal = rsync_ros.msg.RsyncGoal(rsync_args=['-avzp'], source_path=source_path, destination_path=dest_path)

# Sends goal to the action server.
client.send_goal(goal)

# Waits for the server to finish performing the action.
client.wait_for_result()

# Gets the result of the action
result = client.get_result()

# Prints out the result of executing the action
rospy.loginfo("Successful Transfer: {}".format(result.sync_success))  # An RsyncResult

Rsync Action Definition

#Goal
string[] rsync_args #List of Rsync command line arguments e.g. ['-avzh', '--partial']
                    
string source_path #e.g. "/home/user/file_to_sync.txt"
string destination_path #e.g. "[email protected]:/home/user/file_destination.txt"

---
#Result
bool sync_success #returns true if the file(s) synced correctly

---
#Feedback
float32 percent_complete
int64 transfer_rate #in bytes/second

Simple Python Service example

TODO

Rsync Service Definition

string local_path
string target_user
string target_ip
string target_path
string options
---
bool success

About

A ROS actionlib interface for Rsync

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 92.9%
  • CMake 7.1%