diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4349be2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +build +*.tar.gz +*.so + +# system config; these are all files generated by dpkg-buildpackage +*.deb +*.debhelper +*.substvars +*.log +*.dsc +*.changes +fetch-melodic-config +freight-melodic-config +files diff --git a/fetch_binary_drivers/CMakeLists.txt b/fetch_binary_drivers/CMakeLists.txt new file mode 100644 index 0000000..a147cab --- /dev/null +++ b/fetch_binary_drivers/CMakeLists.txt @@ -0,0 +1,98 @@ +cmake_minimum_required(VERSION 3.5) +project(fetch_drivers) + +### +# +# This is the public version of fetch_drivers. +# +# This is a binary only release of our dirvers and firmware. +# The drivers and firmware have been compiled for our research robots, inside of Docker containers on our TeamCity build servers. +# +# The resulting output of that build job a tar.gz, where the build job should only copy in what is required for the research robots. +# This public repository, just pulls in that tar.gz and extracts installs it into ROS/catkin paths. +## + +find_package(catkin REQUIRED + COMPONENTS + mk +) + +## System dependencies are found with CMake's conventions +find_package(Boost REQUIRED + COMPONENTS + chrono + filesystem + program_options + regex + system + thread +) +find_package(CURL REQUIRED) +find_package(PythonLibs REQUIRED) +find_package(yaml-cpp REQUIRED) + +add_custom_target( + binary_driver ALL + COMMAND cmake -E chdir ${PROJECT_SOURCE_DIR} $(MAKE) -f Makefile.tarball + COMMAND cmake -E make_directory ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_LIB_DESTINATION}/${PROJECT_NAME} + COMMAND cmake -E copy_if_different ${PROJECT_SOURCE_DIR}/build/output/lib/libfetch_drivers.so ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_LIB_DESTINATION}/libfetch_drivers.so + COMMAND cmake -E copy_if_different ${PROJECT_SOURCE_DIR}/build/output/lib/libfetch_drivers_odva.so ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_LIB_DESTINATION}/libfetch_drivers_odva.so + COMMAND cmake -E copy ${PROJECT_SOURCE_DIR}/build/output/lib/${PROJECT_NAME}/* ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_LIB_DESTINATION}/${PROJECT_NAME}/ + COMMAND cmake -E make_directory ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_SHARE_DESTINATION}/${PROJECT_NAME} + COMMAND cmake -E copy_if_different ${PROJECT_SOURCE_DIR}/build/output/share/${PROJECT_NAME}/firmware.tar.gz ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_SHARE_DESTINATION}/${PROJECT_NAME}/ +) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( + LIBRARIES fetch_drivers + CATKIN_DEPENDS + actionlib + actionlib_msgs + diagnostic_msgs + fetch_driver_msgs + fetch_auto_dock_msgs + nav_msgs + power_msgs + robot_calibration_msgs + roscpp + sensor_msgs + DEPENDS + Boost + CURL + PYTHON + YAML_CPP +) + +########### +## Build ## +########### + +############# +## Install ## +############# + +install( + FILES build/output/lib/libfetch_drivers.so build/output/lib/libfetch_drivers_odva.so + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +) + +install( + DIRECTORY build/output/lib/fetch_drivers + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + PATTERN "build/output/lib/fetch_drivers/*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ +) + +install( + FILES build/output/share/${PROJECT_NAME}/firmware.tar.gz build/output/share/${PROJECT_NAME}/laser_filters.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) diff --git a/fetch_binary_drivers/Makefile.tarball b/fetch_binary_drivers/Makefile.tarball new file mode 100644 index 0000000..1988c2f --- /dev/null +++ b/fetch_binary_drivers/Makefile.tarball @@ -0,0 +1,19 @@ +all: binary_driver + +# TODO: There are some more things to automate. +DRIVER_VERSION = 0.8.0 +TARBALL = build/fetch-drivers-0.8.0.tar.gz +TARBALL_URL = http://packages.fetchrobotics.com/binaries/fetch-drivers-0.8.0.tar.gz +SOURCE_DIR = build/output +MD5SUM_FILE = fetch-drivers-0.8.0.tar.gz.md5sum +UNPACK_CMD = tar zxvf +include $(shell rospack find mk)/download_unpack_build.mk + +binary_driver: $(SOURCE_DIR)/unpacked + echo "binary driver built in: " $(SOURCE_DIR) + +clean: + -rm -rf $(SOURCE_DIR) + +wipe: clean + -rm -rf build diff --git a/fetch_binary_drivers/README.md b/fetch_binary_drivers/README.md new file mode 100644 index 0000000..a8014d9 --- /dev/null +++ b/fetch_binary_drivers/README.md @@ -0,0 +1,43 @@ +# Fetch Binary Drivers + +This is a public binary version of our drivers and firmware for the Fetch Research Platforms. + +https://fetchrobotics.com/robotics-platforms/ + +We have two Fetch Research Platforms. Commonly known as Fetch and Freight. Fetch is the one with the arm. +The drivers and firmware in this package are for both. + +https://docs.fetchrobotics.com/ + +# Fetch Drivers + +The catkin package inside of this folder is called `fetch_drivers`, not `fetch_binary_drivers`. +This is because we've previously been releasing packages which depend on `fetch_drivers`. +We're just changing how we distribute our drivers. + +# About + +This package should only be needed if you're using one of the Fetch Research Platforms. + +Our goal is to better support our our Fetch Research Platform customers through an improved, more automated build and release process. This will get enable us to get updates out faster. + +We discussed at [ROSCon 2018](https://roscon.ros.org/2018/) in a talk "Hermetic Robot Deployment Using Multi-Stage Dockers" +by @levavakian & @bluryi some of our internal way of doing build/test/deployment using Docker: +[Video](https://vimeo.com/293626218), +[Slides](https://roscon.ros.org/2018/presentations/ROSCon2018_multistage_docker_for_robot_deployment.pdf). + +This public repository, is designed to consume the output of our private `fetch_drivers` repository and enable +Fetch Research Platform users access to the drivers/firmware faster via the official ros packages. + +To create the output of our private package, we have a special build job which runs inside of a docker container to ensure we don't accidentally +pull in any private dependencies, and also doesn't output any of the additional commercial robot drivers. + +Previously, we built our drivers on a private buildbot, and hosted them on our own packages site. +We also had a manually synced mirror of the ros packages. This allowed us to ensure we tested the versions of dependancies which were on our mirror. +The old process was not as automated as we would like. + +We're in the process of testing ROS Melodic, and setting up our hosted stable mirror, and documenting the upgrade process to ensure Fetch Research Platform customers have a smooth transition. + +We will announce to our customers when we're officially ready and supporting ROS Melodic. + +See https://docs.fetchrobotics.com for more information. diff --git a/fetch_binary_drivers/fetch-drivers-0.8.0.tar.gz.md5sum b/fetch_binary_drivers/fetch-drivers-0.8.0.tar.gz.md5sum new file mode 100644 index 0000000..d9b95ba --- /dev/null +++ b/fetch_binary_drivers/fetch-drivers-0.8.0.tar.gz.md5sum @@ -0,0 +1 @@ +1d283854b2406e1945319a57e660c5ec /tmp/fetch-drivers-0.8.0.tar.gz diff --git a/fetch_binary_drivers/package.xml b/fetch_binary_drivers/package.xml new file mode 100644 index 0000000..6585e13 --- /dev/null +++ b/fetch_binary_drivers/package.xml @@ -0,0 +1,66 @@ + + + fetch_drivers + 0.0.0 + + The public fetch_drivers package is a binary only release. + + fetch_drivers contains both the drivers and firmware for the fetch and freight research robots. + There should be no reason to use these drivers unless you're running on a fetch or a freight research robot. + This package, is a cmake/make only package which installs the binaries for the drivers and firmware. + + + + Alexander Moriarty + Fetch Robotics Open Source Team + + + Proprietary + + + + https://wiki.ros.org/fetch_drivers + https://docs.fetchrobotics.com + https://fetchrobotics.com/robotics-platforms/ + + + + Alexander Moriarty + + + catkin + + + mk + + + boost + curl + python + yaml-cpp + + + actionlib_msgs + diagnostic_msgs + fetch_driver_msgs + fetch_auto_dock_msgs + nav_msgs + power_msgs + robot_calibration_msgs + sensor_msgs + + + actionlib + robot_controllers + robot_controllers_interface + rosconsole + roscpp_serialization + roscpp + rostime + urdf + + + + + + diff --git a/fetch_system_config/README.md b/fetch_system_config/README.md new file mode 100644 index 0000000..7dbc423 --- /dev/null +++ b/fetch_system_config/README.md @@ -0,0 +1,22 @@ +# Fetch System Config + +This is the Git Build Package (GBP) repo for Research versions of Fetch/Freight. +All other tools (iso installer, documentation, etc), and the commercial version +of this package, are on the 'master' branch. + +# How to Manually Build + +```bash +git clone git@github.com:fetchrobotics/fetch_ros.git # -b melodic-devel +cd fetch_ros/fetch_system_config +dpkg-buildpackage -us -uc +# Debians are placed in the parent directory +cd .. +ls *system*.deb +``` + +# TODO: catkin/standardize + +This isn't a GBP anymore, it will be published to: + +https://github.com/fetchrobotics-gbp/fetch_robots-release diff --git a/fetch_system_config/debian/changelog b/fetch_system_config/debian/changelog new file mode 100644 index 0000000..1a51d12 --- /dev/null +++ b/fetch_system_config/debian/changelog @@ -0,0 +1,5 @@ +fetch-system-config (0.1-0) bionic; urgency=medium + + * initial release of melodic packages + + -- Eric Relson Fri, 01 Feb 2019 10:50:25 -0800 diff --git a/fetch_system_config/debian/compat b/fetch_system_config/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/fetch_system_config/debian/compat @@ -0,0 +1 @@ +9 diff --git a/fetch_system_config/debian/control b/fetch_system_config/debian/control new file mode 100644 index 0000000..b4fb0bf --- /dev/null +++ b/fetch_system_config/debian/control @@ -0,0 +1,34 @@ +Source: fetch-system-config +Section: main +Priority: optional +Maintainer: Eric Relson +Build-Depends: debhelper (>= 9.0.0), + dh-systemd (>= 1.5) +Standards-Version: 3.9.4 +Homepage: www.fetchrobotics.com + +Package: fetch-melodic-config +Architecture: any +Depends: ${misc:Depends}, + adduser, + chrony, + openssh-server, + ros-melodic-ros +Description: Configuration for Fetch on Melodic + This package will start ROS Melodic at bootup +Conflicts: fetch-system-config, + freight-melodic-config, + freight-system-config + +Package: freight-melodic-config +Architecture: any +Depends: ${misc:Depends}, + adduser, + chrony, + openssh-server, + ros-melodic-ros +Description: Configuration for Freight on Melodic + This package will start ROS Melodic at bootup +Conflicts: fetch-melodic-config, + fetch-system-config, + freight-system-config diff --git a/fetch_system_config/debian/copyright b/fetch_system_config/debian/copyright new file mode 100644 index 0000000..ac25376 --- /dev/null +++ b/fetch_system_config/debian/copyright @@ -0,0 +1,36 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: * +Copyright: 2015-2018 Fetch Robotics Inc + 2013 I Heart Engineering +License: BSD-3-clause + Copyright (c) 2015-2018, Fetch Robotics Inc. + Copyright (c) 2013, I Heart Engineering + All rights reserved. + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + . + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the I Heart Engineering nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. diff --git a/fetch_system_config/debian/docs b/fetch_system_config/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/fetch_system_config/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/fetch_system_config/debian/fetch-melodic-config.install b/fetch_system_config/debian/fetch-melodic-config.install new file mode 100644 index 0000000..ed2cb38 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.install @@ -0,0 +1 @@ +root/* . \ No newline at end of file diff --git a/fetch_system_config/debian/fetch-melodic-config.postinst b/fetch_system_config/debian/fetch-melodic-config.postinst new file mode 100755 index 0000000..18e4676 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.postinst @@ -0,0 +1,141 @@ +#!/bin/bash + +set -e + +case "$1" in + "configure") + # Add ROS user, give access to audio/hardware + if ! getent passwd ros >/dev/null; then + adduser --disabled-password --quiet --system \ + --no-create-home --home=/var/lib/ros --shell /bin/bash \ + --gecos "ROS system user" --group ros + fi + adduser --quiet ros audio + adduser --quiet ros dialout + adduser --quiet ros plugdev + if ! getent group ros > /dev/null 2>&1; then + addgroup --system ros --quiet + fi + if [ "$(id -gn ros)" = "nogroup" ]; then + usermod -g ros ros + fi + + # Setup /var/lib/ros as home directory + if [ ! -e "/var/lib/ros" ]; then + mkdir /var/lib/ros + fi + chown -R ros:ros /var/lib/ros + chmod 2775 /var/lib/ros + + # Setup /var/log/ros for logging + if [ ! -e "/var/log/ros" ]; then + mkdir /var/log/ros + fi + chown -R ros:ros /var/log/ros + chmod 2775 /var/log/ros + + # Copy the robot.launch if not already existent + if [ ! -e "/etc/ros/melodic/robot.launch" ]; then + mkdir -p /etc/ros/melodic + cp /opt/ros/melodic/share/fetch_bringup/launch/fetch.launch /etc/ros/melodic/robot.launch + fi + + # Workaround for gnome-settings-daemon not enabling immediate shutdown + # https://unix.stackexchange.com/a/416569 + hostnamectl set-chassis vm + + # Do not wait for GRUB (we're headless) + sed -i "s/GRUB_TIMEOUT=.*\"\"/GRUB_TIMEOUT=5/" /etc/default/grub + echo "GRUB_RECORDFAIL_TIMEOUT=\$GRUB_TIMEOUT" >> /etc/default/grub + + # Disable apport + if [ -e "/etc/default/apport" ]; then + sed -i "s/enabled=1/enabled=0/g" /etc/default/apport + fi + + # Run logrotation cron job hourly + if [ ! -e "/etc/cron.hourly/logrotate" ]; then + cp /etc/cron.daily/logrotate /etc/cron.hourly/logrotate + fi + + # Probalby null-op; We replace the update-rc.d with upstart job so that sixad starts properly + update-rc.d -f sixad remove + + ### Set up ethernet to ensure static network for internal robot communications. + # Reboot required for changes to take effect. + # Modify default/grub to not use new-style network device naming + sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/" /etc/default/grub + update-grub + # Determine which device to map to eth0 and eth1 and update /etc/udev/rules.d/70-persistent-net.rules + declare -a x=() + lines=$(udevadm info -e | grep -e "ID_NET_NAME_MAC=e.*[a-f0-9]\{12\}$") + regexmac="ID_NET_NAME_MAC=e.*([a-f0-9]{12})$" + for f in $lines + do + if [[ $f =~ $regexmac ]]; then + macs+="$(echo ${BASH_REMATCH[1]} | sed -r 's/.{2}/&:/g' | sed -r 's/://g6') " + fi + done + + # Make a backup, then remove any existing entries for eth0, eth1 from udev rules + if [[ -f /etc/udev/rules.d/70-persistent-net.rules ]]; then + if [[ ! -f /etc/udev/rules.d/70-persistent-net.rules.bak ]]; then + cp -n /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.bak + fi + cp -f /etc/udev/rules.d/70-persistent-net.rules /tmp/70-persistent-net.rules + grep -v -E "eth0|eth1" /tmp/70-persistent-net.rules > /etc/udev/rules.d/70-persistent-net.rules | true + fi + + # Add our new udev rules for eth0, eth1 + mac_array=($macs) + udev_line='SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="MAC_ADDRESS", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME=' + if [[ ${mac_array[0]} > ${mac_array[1]} ]]; then + echo ${udev_line/MAC_ADDRESS/${mac_array[0]}}'"eth0"' >> /etc/udev/rules.d/70-persistent-net.rules + echo ${udev_line/MAC_ADDRESS/${mac_array[1]}}'"eth1"' >> /etc/udev/rules.d/70-persistent-net.rules + else + echo ${udev_line/MAC_ADDRESS/${mac_array[1]}}'"eth0"' >> /etc/udev/rules.d/70-persistent-net.rules + echo ${udev_line/MAC_ADDRESS/${mac_array[0]}}'"eth1"' >> /etc/udev/rules.d/70-persistent-net.rules + fi + # Add netplan to set static IPs + if [[ ! -f /etc/netplan/99-fetch-ethernet.yaml ]]; then + cat << EOF > /etc/netplan/99-fetch-ethernet.yaml +# Fetch research robots require the below configuration for eth1. +# The configuration for eth0 is left to DHCP by default, but can be set to +# another static IP by uncommenting the block below and running `sudo netplan try`. +network: + version: 2 + ethernets: + #eth0: + # addresses: [172.42.42.1/24] + # gateway4: 172.42.42.1 + eth1: + addresses: [10.42.42.1/24] + gateway4: 10.42.42.1 +EOF + fi + + # Setup chrony to allow time jumps on start + if [ ! `grep makestep /etc/chrony/chrony.conf >/dev/null && echo $?` ]; then + echo ' +# This lets the time jump at startup +makestep 1.0 100' >>/etc/chrony/chrony.conf + fi + + # Disable wifi power management in 18.04 + # https://gist.github.com/jcberthon/ea8cfe278998968ba7c5a95344bc8b55 + sed -i "s/wifi.powersave = 3/wifi.powersave = 2/" /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/fetch_system_config/debian/fetch-melodic-config.ps3joy.service b/fetch_system_config/debian/fetch-melodic-config.ps3joy.service new file mode 100644 index 0000000..5d7f241 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.ps3joy.service @@ -0,0 +1,16 @@ +[Unit] +Description=Job that launches the ps3joy node once roscore has started +After=roscore.service +BindsTo=roscore.service + +[Install] +WantedBy=roscore.service + +[Service] +Environment="ROS_LOG_DIR=/var/log/ros" +Restart=on-failure +StandardOutput=file:/var/log/ros/ps3joy.log +StandardError=file:/var/log/ros/ps3joy.log + +ExecStart=/bin/bash -c ". /opt/ros/melodic/setup.bash && rosrun ps3joy ps3joy.py --inactivity-timeout=3600" + diff --git a/fetch_system_config/debian/fetch-melodic-config.robot.service b/fetch_system_config/debian/fetch-melodic-config.robot.service new file mode 100644 index 0000000..1e89641 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.robot.service @@ -0,0 +1,16 @@ +[Unit] +Description=Job that launches the robot drivers once roscore has started +After=roscore.service +BindsTo=roscore.service + +[Install] +WantedBy=roscore.service + +[Service] +Environment="ROS_LOG_DIR=/var/log/ros" +Restart=on-failure +StandardOutput=file:/var/log/ros/robot.log +StandardError=file:/var/log/ros/robot.log + +User=ros +ExecStart=/bin/bash -c ". /opt/ros/melodic/setup.bash && roslaunch /etc/ros/melodic/robot.launch --wait" diff --git a/fetch_system_config/debian/fetch-melodic-config.ros.logrotate b/fetch_system_config/debian/fetch-melodic-config.ros.logrotate new file mode 100644 index 0000000..a318be8 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.ros.logrotate @@ -0,0 +1,73 @@ +compress + +/var/log/ros/*/*.log { + # Run scripts once per set of logs + sharedscripts + firstaction + . /opt/ros/melodic/setup.sh + # get run_id of ROS if it is running + RUN_ID=`rosparam get /run_id 2>/dev/null` + # Create a tarball if ROS is no longer using a given log subdirectory + for i in $( ls /var/log/ros | grep -v \.gz$ ); do + if [ $i != "$RUN_ID" ] && [ -d $i ]; then + cd /var/log/ros && tar -zpcf $i.tar.gz $i + fi + done + endscript + postrotate + . /opt/ros/melodic/setup.sh + RUN_ID=`rosparam get /run_id 2>/dev/null` + # Remove log subdirectory after tarball has been created + for i in $( ls /var/log/ros | grep -v \.gz$ ); do + if [ $i != "$RUN_ID" ] && [ -e /var/log/ros/$i.tar.gz ]; then + rm -r /var/log/ros/$i + fi + done + # Delete tarballs after a week + for i in $( find /var/log/ros -mtime 7 | grep \.gz$ ); do + rm $i + done + endscript + # Do not report errors if ROS has not created logs + missingok + # Rotate logs daily + daily + # Keep 1 weeks worth of logs for active processes + rotate 6 + # ROS continues to write to the old log + # 01 Jan 2013 - BUG: Sending SIGHUP to the ROS does not cause it to write to a new log. + copytruncate + # Compress old logs + delaycompress +} + +/var/log/ros/roscore.log { + maxsize=50M + rotate 3 + missingok + delaycompress + # 01 Jan 2013 - BUG: Sending SIGHUP to the ROS does not cause it to write to a new log. + copytruncate +} + +/var/log/ros/robot.log { + maxsize=50M + rotate 7 + missingok + delaycompress +} + +/var/log/ros/sixad.log { + maxsize=50M + rotate 3 + missingok + delaycompress +} + +/var/log/ros/robot_log.csv { + maxsize 100M + weekly + rotate 8 + missingok + compress +} diff --git a/fetch_system_config/debian/fetch-melodic-config.roscore.service b/fetch_system_config/debian/fetch-melodic-config.roscore.service new file mode 100644 index 0000000..120d401 --- /dev/null +++ b/fetch_system_config/debian/fetch-melodic-config.roscore.service @@ -0,0 +1,18 @@ +[Unit] +Description=Job that launches roscore once the system has started +After=multi-user.target + +[Install] +WantedBy=multi-user.target + +[Service] +Environment="ROS_LOG_DIR=/var/log/ros" +Restart=on-failure +StandardOutput=file:/var/log/ros/roscore.log +StandardError=file:/var/log/ros/roscore.log + +ExecStartPre=/bin/bash /opt/ros/roscore_prestart.bash +ExecStartPost=/bin/bash /opt/ros/roscore_poststart.bash +User=ros +ExecStart=/bin/bash -c ". /opt/ros/melodic/setup.bash && roscore" + diff --git a/fetch_system_config/debian/freight-melodic-config.install b/fetch_system_config/debian/freight-melodic-config.install new file mode 100644 index 0000000..ed2cb38 --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.install @@ -0,0 +1 @@ +root/* . \ No newline at end of file diff --git a/fetch_system_config/debian/freight-melodic-config.postinst b/fetch_system_config/debian/freight-melodic-config.postinst new file mode 100755 index 0000000..e368f70 --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.postinst @@ -0,0 +1,141 @@ +#!/bin/bash + +set -e + +case "$1" in + "configure") + # Add ROS user, give access to audio/hardware + if ! getent passwd ros >/dev/null; then + adduser --disabled-password --quiet --system \ + --no-create-home --home=/var/lib/ros --shell /bin/bash \ + --gecos "ROS system user" --group ros + fi + adduser --quiet ros audio + adduser --quiet ros dialout + adduser --quiet ros plugdev + if ! getent group ros > /dev/null 2>&1; then + addgroup --system ros --quiet + fi + if [ "$(id -gn ros)" = "nogroup" ]; then + usermod -g ros ros + fi + + # Setup /var/lib/ros as home directory + if [ ! -e "/var/lib/ros" ]; then + mkdir /var/lib/ros + fi + chown -R ros:ros /var/lib/ros + chmod 2775 /var/lib/ros + + # Setup /var/log/ros for logging + if [ ! -e "/var/log/ros" ]; then + mkdir /var/log/ros + fi + chown -R ros:ros /var/log/ros + chmod 2775 /var/log/ros + + # Copy the robot.launch if not already existent + if [ ! -e "/etc/ros/melodic/robot.launch" ]; then + mkdir -p /etc/ros/melodic + cp /opt/ros/melodic/share/freight_bringup/launch/freight.launch /etc/ros/melodic/robot.launch + fi + + # Workaround for gnome-settings-daemon not enabling immediate shutdown + # https://unix.stackexchange.com/a/416569 + hostnamectl set-chassis vm + + # Do not wait for GRUB (we're headless) + sed -i "s/GRUB_TIMEOUT=.*\"\"/GRUB_TIMEOUT=5/" /etc/default/grub + echo "GRUB_RECORDFAIL_TIMEOUT=\$GRUB_TIMEOUT" >> /etc/default/grub + + # Disable apport + if [ -e "/etc/default/apport" ]; then + sed -i "s/enabled=1/enabled=0/g" /etc/default/apport + fi + + # Run logrotation cron job hourly + if [ ! -e "/etc/cron.hourly/logrotate" ]; then + cp /etc/cron.daily/logrotate /etc/cron.hourly/logrotate + fi + + # Probalby null-op; We replace the update-rc.d with upstart job so that sixad starts properly + update-rc.d -f sixad remove + + ### Set up ethernet to ensure static network for internal robot communications. + # Reboot required for changes to take effect. + # Modify default/grub to not use new-style network device naming + sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/" /etc/default/grub + update-grub + # Determine which device to map to eth0 and eth1 and update /etc/udev/rules.d/70-persistent-net.rules + declare -a x=() + lines=$(udevadm info -e | grep -e "ID_NET_NAME_MAC=e.*[a-f0-9]\{12\}$") + regexmac="ID_NET_NAME_MAC=e.*([a-f0-9]{12})$" + for f in $lines + do + if [[ $f =~ $regexmac ]]; then + macs+="$(echo ${BASH_REMATCH[1]} | sed -r 's/.{2}/&:/g' | sed -r 's/://g6') " + fi + done + + # Make a backup, then remove any existing entries for eth0, eth1 from udev rules + if [[ -f /etc/udev/rules.d/70-persistent-net.rules ]]; then + if [[ ! -f /etc/udev/rules.d/70-persistent-net.rules.bak ]]; then + cp -n /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.bak + fi + cp -f /etc/udev/rules.d/70-persistent-net.rules /tmp/70-persistent-net.rules + grep -v -E "eth0|eth1" /tmp/70-persistent-net.rules > /etc/udev/rules.d/70-persistent-net.rules | true + fi + + # Add our new udev rules for eth0, eth1 + mac_array=($macs) + udev_line='SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="MAC_ADDRESS", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME=' + if [[ ${mac_array[0]} > ${mac_array[1]} ]]; then + echo ${udev_line/MAC_ADDRESS/${mac_array[0]}}'"eth0"' >> /etc/udev/rules.d/70-persistent-net.rules + echo ${udev_line/MAC_ADDRESS/${mac_array[1]}}'"eth1"' >> /etc/udev/rules.d/70-persistent-net.rules + else + echo ${udev_line/MAC_ADDRESS/${mac_array[1]}}'"eth0"' >> /etc/udev/rules.d/70-persistent-net.rules + echo ${udev_line/MAC_ADDRESS/${mac_array[0]}}'"eth1"' >> /etc/udev/rules.d/70-persistent-net.rules + fi + # Add netplan to set static IPs + if [[ ! -f /etc/netplan/99-fetch-ethernet.yaml ]]; then + cat << EOF > /etc/netplan/99-fetch-ethernet.yaml +# Fetch research robots require the below configuration for eth1. +# The configuration for eth0 is left to DHCP by default, but can be set to +# another static IP by uncommenting the block below and running `sudo netplan try`. +network: + version: 2 + ethernets: + #eth0: + # addresses: [172.42.42.1/24] + # gateway4: 172.42.42.1 + eth1: + addresses: [10.42.42.1/24] + gateway4: 10.42.42.1 +EOF + fi + + # Setup chrony to allow time jumps on start + if [ ! `grep makestep /etc/chrony/chrony.conf >/dev/null && echo $?` ]; then + echo ' +# This lets the time jump at startup +makestep 1.0 100' >>/etc/chrony/chrony.conf + fi + + # Disable wifi power management in 18.04 + # https://gist.github.com/jcberthon/ea8cfe278998968ba7c5a95344bc8b55 + sed -i "s/wifi.powersave = 3/wifi.powersave = 2/" /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/fetch_system_config/debian/freight-melodic-config.ps3joy.service b/fetch_system_config/debian/freight-melodic-config.ps3joy.service new file mode 120000 index 0000000..0b39e58 --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.ps3joy.service @@ -0,0 +1 @@ +fetch-melodic-config.ps3joy.service \ No newline at end of file diff --git a/fetch_system_config/debian/freight-melodic-config.robot.service b/fetch_system_config/debian/freight-melodic-config.robot.service new file mode 120000 index 0000000..a43db3b --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.robot.service @@ -0,0 +1 @@ +fetch-melodic-config.robot.service \ No newline at end of file diff --git a/fetch_system_config/debian/freight-melodic-config.ros.logrotate b/fetch_system_config/debian/freight-melodic-config.ros.logrotate new file mode 100644 index 0000000..c6ef4e0 --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.ros.logrotate @@ -0,0 +1 @@ +fetch-melodic-config.ros.logrotate diff --git a/fetch_system_config/debian/freight-melodic-config.roscore.service b/fetch_system_config/debian/freight-melodic-config.roscore.service new file mode 120000 index 0000000..b5f828a --- /dev/null +++ b/fetch_system_config/debian/freight-melodic-config.roscore.service @@ -0,0 +1 @@ +fetch-melodic-config.roscore.service \ No newline at end of file diff --git a/fetch_system_config/debian/rules b/fetch_system_config/debian/rules new file mode 100755 index 0000000..4e4f827 --- /dev/null +++ b/fetch_system_config/debian/rules @@ -0,0 +1,15 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Grab the following .service files +override_dh_systemd_enable: + dh_systemd_enable --name=roscore + dh_systemd_enable --name=robot + dh_systemd_enable --name=ps3joy + #dh_systemd_enable --name=soundplay # TBD + +override_dh_installlogrotate: + dh_installlogrotate --name=ros + +%: + dh $@ --with=systemd diff --git a/fetch_system_config/debian/source/format b/fetch_system_config/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/fetch_system_config/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/fetch_system_config/debian/triggers b/fetch_system_config/debian/triggers new file mode 100644 index 0000000..7d2a1cc --- /dev/null +++ b/fetch_system_config/debian/triggers @@ -0,0 +1 @@ +interest /var/lib/ros diff --git a/fetch_system_config/root/etc/asound.conf b/fetch_system_config/root/etc/asound.conf new file mode 100644 index 0000000..6df3fe9 --- /dev/null +++ b/fetch_system_config/root/etc/asound.conf @@ -0,0 +1,2 @@ +defaults.pcm.card 1 +defaults.pcm.device 0 diff --git a/fetch_system_config/root/etc/modprobe.d/blacklist-intel-audio.conf b/fetch_system_config/root/etc/modprobe.d/blacklist-intel-audio.conf new file mode 100755 index 0000000..90b1718 --- /dev/null +++ b/fetch_system_config/root/etc/modprobe.d/blacklist-intel-audio.conf @@ -0,0 +1,3 @@ +# Blacklisting Intel sound devices to prevent those devices enumerating on top of +# the audio device on the main board. +blacklist snd_hda_intel diff --git a/fetch_system_config/root/lib/udev/rules.d/40-libopenni2-0609.rules b/fetch_system_config/root/lib/udev/rules.d/40-libopenni2-0609.rules new file mode 100644 index 0000000..378378f --- /dev/null +++ b/fetch_system_config/root/lib/udev/rules.d/40-libopenni2-0609.rules @@ -0,0 +1,2 @@ +# Make primesense device mount with writing permissions (default is read only for unknown devices) +SUBSYSTEM=="usb", ATTR{idProduct}=="0609", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" \ No newline at end of file diff --git a/fetch_system_config/root/lib/udev/rules.d/99-logitechF710.rules b/fetch_system_config/root/lib/udev/rules.d/99-logitechF710.rules new file mode 100644 index 0000000..152a0db --- /dev/null +++ b/fetch_system_config/root/lib/udev/rules.d/99-logitechF710.rules @@ -0,0 +1,2 @@ +KERNEL=="js?", SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c219", SYMLINK+="logitechF710" +KERNEL=="js?", SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c21f", SYMLINK+="logitechF710" diff --git a/fetch_system_config/root/lib/udev/rules.d/99-ps3joy.rules b/fetch_system_config/root/lib/udev/rules.d/99-ps3joy.rules new file mode 100644 index 0000000..d01b9ff --- /dev/null +++ b/fetch_system_config/root/lib/udev/rules.d/99-ps3joy.rules @@ -0,0 +1 @@ +KERNEL=="js?", SUBSYSTEM=="input", ATTRS{name}=="PLAYSTATION(R)3 Controller *", SYMLINK+="ps3joy" \ No newline at end of file diff --git a/fetch_system_config/root/opt/ros/roscore_poststart.bash b/fetch_system_config/root/opt/ros/roscore_poststart.bash new file mode 100644 index 0000000..3c892f4 --- /dev/null +++ b/fetch_system_config/root/opt/ros/roscore_poststart.bash @@ -0,0 +1,9 @@ +# This script is used by the roscore systemd service unit +echo "waiting for roscore to come up" +. /opt/ros/melodic/setup.sh +ret=`rosnode list` +while [ "$ret" = '' ] +do + ret=`rosnode list` + sleep 1; +done diff --git a/fetch_system_config/root/opt/ros/roscore_prestart.bash b/fetch_system_config/root/opt/ros/roscore_prestart.bash new file mode 100644 index 0000000..6d2f8da --- /dev/null +++ b/fetch_system_config/root/opt/ros/roscore_prestart.bash @@ -0,0 +1,3 @@ +# This script is used by the roscore systemd service unit +mkdir -p /var/log/ros/ +chown ros:ros /var/log/ros/