diff --git a/README.md b/README.md index 7387c70..39a5255 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Canopy Cloud Robotics Framework -This is the ROS node for the client-side application. +# Canopy Client +This is the ROS node for the client-side application of Canopy. ## Installation ``` @@ -7,9 +7,49 @@ cd /src git clone https://github.com/baalexander/rospy_message_converter git clone https://github.com/canopy-ros/canopy_client cd canopy_client -pip install -r requirements.txt +. ./canopy_client_install.sh +``` + +## Clock Synchronization +This section describes the _client-side_ instructions for synchronizing the clocks of your Canopy clients and the Canopy server using `chrony`. + +### Setting up chrony +Modify the chrony configuration file `/etc/chrony/chrony_canopy_client.conf` to reflect your Canopy server's IP address: +``` +# /etc/chrony/chrony_canopy_client.conf +server 128.31.37.168 +... +``` +Disable and stop the default chrony service: +``` +sudo systemctl stop chrony +sudo systemctl disable chrony +``` -cd -catkin_make -. ./devel/setup.bash +Enable and start the Canopy chrony service: +``` +sudo systemctl enable chrony_canopy_client +sudo systemctl start chrony_canopy_client ``` + +### Checking chrony setup +To check whether the service is running correctly, run `systemctl status chrony_canopy_client` which should show an active running status: +``` +chrony_canopy_client.service - chrony service for canopy client +Loaded: loaded (/lib/systemd/system/chrony_canopy_client.service; static; vendor preset: enabled) +Active: active (running) +... +``` + +To check whether the chrony daemon `chronyd` is working correctly, first setup chrony on the [Canopy server](https://github.com/canopy-ros/canopy_server_startup/) and ensure that it is running correctly. Then run `chronyc activity` on the client which should return the following: +``` +200 OK +1 sources online +0 sources offline +0 sources doing burst (return to online) +0 sources doing burst (return to offline) +0 sources with unknown address +``` +If you see the message `506 Cannot talk to daemon`, then `chronyd` is not running properly. + +Finally run `chronyc sources` and you should see your Canopy server's IP address listed. If you are connecting the chrony client to the chrony server for the first time, it may take several minutes before the correct IP is listed under sources. diff --git a/canopy_client_install.sh b/canopy_client_install.sh new file mode 100755 index 0000000..c8eeef7 --- /dev/null +++ b/canopy_client_install.sh @@ -0,0 +1,27 @@ +#!/bin/sh +CANOPY_CLIENT_DIR=$(pwd) + +# trap errors +function err_fn() { + echo 'ERROR - aborting script.' + cd $CANOPY_CLIENT_DIR + trap - ERR +} +trap "err_fn; return" ERR + +# install python packages +pip install -r requirements.txt + +# setup chrony +sudo apt-get update +sudo apt-get install chrony +sudo cp chrony_canopy_client.service /lib/systemd/system +sudo cp chrony_canopy_client.conf /etc/chrony + +# make ros package +cd ../.. +catkin_make +. ./devel/setup.bash +cd $CANOPY_CLIENT_DIR +trap - ERR +echo "SUCCESS - script successfully installed." diff --git a/chrony_canopy_client.conf b/chrony_canopy_client.conf new file mode 100644 index 0000000..88b9151 --- /dev/null +++ b/chrony_canopy_client.conf @@ -0,0 +1,15 @@ +# To synchronize client to server, uncomment line below and replace IP with server's IP: +# server 123.123.12.12 iburst + +maxupdateskew 5 + +driftfile /var/lib/chrony/chrony.drift + +dumponexit +dumpdir /var/log/chrony + +rtcsync + +keyfile /etc/chrony.keys +commandkey 1 +generatecommandkey diff --git a/chrony_canopy_client.service b/chrony_canopy_client.service new file mode 100644 index 0000000..7a01e98 --- /dev/null +++ b/chrony_canopy_client.service @@ -0,0 +1,12 @@ +[Unit] +Description = chrony service for canopy client +Conflicts = ntpd.service + +[Service] +Type = forking +Restart = always +PIDFile = /var/run/chronyd.pid +ExecStart = /usr/sbin/chronyd -f /etc/chrony/chrony_canopy_client.conf -r -s + +[Install] +WantedBy = default.target \ No newline at end of file