|
| 1 | +#!/bin/bash |
| 2 | +################################################################# |
| 3 | +##\file |
| 4 | +# |
| 5 | +# \note |
| 6 | +# Copyright (c) 2010 \n |
| 7 | +# Fraunhofer Institute for Manufacturing Engineering |
| 8 | +# and Automation (IPA) \n\n |
| 9 | +# |
| 10 | +################################################################# |
| 11 | +# |
| 12 | +# \note |
| 13 | +# Project name: care-o-bot |
| 14 | +# \note |
| 15 | +# ROS stack name: setup |
| 16 | +# \note |
| 17 | +# ROS package name: setup |
| 18 | +# |
| 19 | +# \author |
| 20 | +# Author: Nadia Hammoudeh Garcia, email:[email protected] |
| 21 | +# \author |
| 22 | +# Supervised by: Nadia Hammoudeh Garcia, email:[email protected] |
| 23 | +# |
| 24 | +# \date Date of creation: Dec 2012 |
| 25 | +# |
| 26 | +# \brief |
| 27 | +# Implements helper script for working with git and the care-o-bot stacks. |
| 28 | +# |
| 29 | +# copy this executable into /etc/init.d |
| 30 | +# chmod +x udev_cob.sh |
| 31 | +# sudo cp udev_cob.sh /etc/init.d/ |
| 32 | +# sudo update-rc.d udev_cob.sh defaults |
| 33 | +# |
| 34 | +################################################################# |
| 35 | +# |
| 36 | +# Redistribution and use in source and binary forms, with or without |
| 37 | +# modification, are permitted provided that the following conditions are met: |
| 38 | +# |
| 39 | +# - Redistributions of source code must retain the above copyright |
| 40 | +# notice, this list of conditions and the following disclaimer. \n |
| 41 | +# - Redistributions in binary form must reproduce the above copyright |
| 42 | +# notice, this list of conditions and the following disclaimer in the |
| 43 | +# documentation and/or other materials provided with the distribution. \n |
| 44 | +# - Neither the name of the Fraunhofer Institute for Manufacturing |
| 45 | +# Engineering and Automation (IPA) nor the names of its |
| 46 | +# contributors may be used to endorse or promote products derived from |
| 47 | +# this software without specific prior written permission. \n |
| 48 | +# |
| 49 | +# This program is free software: you can redistribute it and/or modify |
| 50 | +# it under the terms of the GNU Lesser General Public License LGPL as |
| 51 | +# published by the Free Software Foundation, either version 3 of the |
| 52 | +# License, or (at your option) any later version. |
| 53 | +# |
| 54 | +# This program is distributed in the hope that it will be useful, |
| 55 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 56 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 57 | +# GNU Lesser General Public License LGPL for more details. |
| 58 | +# |
| 59 | +# You should have received a copy of the GNU Lesser General Public |
| 60 | +# License LGPL along with this program. |
| 61 | +# If not, see <http://www.gnu.org/licenses/>. |
| 62 | +# |
| 63 | +################################################################# |
| 64 | + |
| 65 | +## Scan1 ## |
| 66 | +Scan1Attr1='ATTRS{bInterfaceNumber}=="01"' |
| 67 | +Scan1Attr2='ATTRS{serial}=="FT7IGCRK"' |
| 68 | + |
| 69 | +## Scan2 ## |
| 70 | +Scan2Attr1='ATTRS{bInterfaceNumber}=="00"' |
| 71 | +Scan2Attr2='ATTRS{serial}=="FT7IGCRK"' |
| 72 | + |
| 73 | +## Scan3 ## |
| 74 | +Scan3Attr1='ATTRS{bInterfaceNumber}=="00"' |
| 75 | +Scan3Attr2='ATTRS{serial}=="FTDGE9HC"' |
| 76 | + |
| 77 | +## Joystick ## |
| 78 | +JoyAttr1='ATTRS{idVendor}=="046d"' |
| 79 | +#JoyAttr2='ATTRS{idProduct}=="c21f"' |
| 80 | + |
| 81 | +sleep 10 |
| 82 | + |
| 83 | +sudo chmod 666 /dev/ttyUSB0 |
| 84 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) > /tmp/usb0 |
| 85 | +if grep -qs $Scan1Attr1 /tmp/usb0 && grep -qs $Scan1Attr2 /tmp/usb0 |
| 86 | +then |
| 87 | + sudo ln -s ttyUSB0 /dev/ttyScanLeft |
| 88 | +fi |
| 89 | +if grep -qs $Scan2Attr1 /tmp/usb0 && grep -qs $Scan2Attr2 /tmp/usb0 |
| 90 | +then |
| 91 | + sudo ln -s ttyUSB0 /dev/ttyScanFront |
| 92 | +fi |
| 93 | +if grep -qs $Scan3Attr1 /tmp/usb0 && grep -qs $Scan3Attr2 /tmp/usb0 |
| 94 | +then |
| 95 | + sudo ln -s ttyUSB0 /dev/ttyScanRight |
| 96 | +fi |
| 97 | + |
| 98 | +sudo chmod 666 /dev/ttyUSB1 |
| 99 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB1) > /tmp/usb1 |
| 100 | +if grep -qs $Scan1Attr1 /tmp/usb1 && grep -qs $Scan1Attr2 /tmp/usb1 |
| 101 | +then |
| 102 | + sudo ln -s ttyUSB1 /dev/ttyScanLeft |
| 103 | +fi |
| 104 | +if grep -qs $Scan2Attr1 /tmp/usb1 && grep -qs $Scan2Attr2 /tmp/usb1 |
| 105 | +then |
| 106 | + sudo ln -s ttyUSB1 /dev/ttyScanFront |
| 107 | +fi |
| 108 | +if grep -qs $Scan3Attr1 /tmp/usb1 && grep -qs $Scan3Attr2 /tmp/usb1 |
| 109 | +then |
| 110 | + sudo ln -s ttyUSB1 /dev/ttyScanRight |
| 111 | +fi |
| 112 | + |
| 113 | +sudo chmod 666 /dev/ttyUSB2 |
| 114 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB2) > /tmp/usb2 |
| 115 | +if grep -qs $Scan1Attr1 /tmp/usb2 && grep -qs $Scan1Attr2 /tmp/usb2 |
| 116 | +then |
| 117 | + sudo ln -s ttyUSB2 /dev/ttyScanLeft |
| 118 | +fi |
| 119 | +if grep -qs $Scan2Attr1 /tmp/usb2 && grep -qs $Scan2Attr2 /tmp/usb2 |
| 120 | +then |
| 121 | + sudo ln -s ttyUSB2 /dev/ttyScanFront |
| 122 | +fi |
| 123 | +if grep -qs $Scan3Attr1 /tmp/usb2 && grep -qs $Scan3Attr2 /tmp/usb2 |
| 124 | +then |
| 125 | + sudo ln -s ttyUSB2 /dev/ttyScanRight |
| 126 | +fi |
| 127 | + |
| 128 | +sudo chmod 666 /dev/ttyUSB3 |
| 129 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB3) > /tmp/usb3 |
| 130 | +if grep -qs $Scan1Attr1 /tmp/usb3 && grep -qs $Scan1Attr2 /tmp/usb3 |
| 131 | +then |
| 132 | + sudo ln -s ttyUSB3 /dev/ttyScanLeft |
| 133 | +fi |
| 134 | +if grep -qs $Scan2Attr1 /tmp/usb3 && grep -qs $Scan2Attr2 /tmp/usb3 |
| 135 | +then |
| 136 | + sudo ln -s ttyUSB3 /dev/ttyScanFront |
| 137 | +fi |
| 138 | +if grep -qs $Scan3Attr1 /tmp/usb3 && grep -qs $Scan3Attr2 /tmp/usb3 |
| 139 | +then |
| 140 | + sudo ln -s ttyUSB3 /dev/ttyScanRight |
| 141 | +fi |
| 142 | + |
| 143 | +sudo chmod 666 /dev/input/js0 |
| 144 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/input/js0) > /tmp/js0 |
| 145 | +if grep -qs $JoyAttr1 /tmp/js0 |
| 146 | +then |
| 147 | + sudo ln -s input/js0 /dev/joypad |
| 148 | +fi |
| 149 | + |
| 150 | +sudo chmod 666 /dev/input/js1 |
| 151 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/input/js1) > /tmp/js1 |
| 152 | +if grep -qs $JoyAttr1 /tmp/js1 |
| 153 | +then |
| 154 | + sudo ln -s input/js1 /dev/joypad |
| 155 | +fi |
| 156 | + |
| 157 | +sudo chmod 666 /dev/input/js2 |
| 158 | +sudo udevadm info -a -p $(udevadm info -q path -n /dev/input/js2) > /tmp/js2 |
| 159 | +if grep -qs $JoyAttr1 /tmp/js2 |
| 160 | +then |
| 161 | + sudo ln -s input/js2 /dev/joypad |
| 162 | +fi |
0 commit comments