/usr/bin/faust2ros is in faust 0.9.95~repack1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | #! /bin/bash -e
#####################################################################
# #
# Compiles Faust programs to ROS packages #
# (c) Grame, 2014 #
# #
#####################################################################
. /usr/share/faust/utils/faustpath
ARCHFILE="jack-ros.cpp"
path=$(pwd)
CURRENT_DIR=$(pwd)
# Dispatch command arguments
WORKSPACES=''
NEW_NAMES=''
params=("$@")
n=0
for p in $@; do
n=$(($n+1))
# install option, get workspace's name
if [ "$p" = "-install" ]; then
WORKSPACES="$WORKSPACES ${params[$n]}"
# o option, get the new application's name
elif [ "$p" = "-o" ]; then
NEW_NAMES="$NEW_NAMES ${params[$n]}"
elif [ "$p" = "--help" ] || [ "$p" = "-h" ] ; then
HELP=true
elif [ ${p:0:1} = "-" ]; then
OPTIONS="$OPTIONS $p ${params[$n]}"
elif [[ -f "$p" ]]; then
FILES="$FILES $p"
fi
done
# Puts option parameters in tables
NEW_NAMES=($NEW_NAMES)
WORKSPACES=($WORKSPACES)
# Get parameters tables size
NAMES_LENGTH=${#NEW_NAMES[@]}
WS_LENGTH=${#WORKSPACES[@]}
if [ $HELP ]
then
############ BEGIN HELP MESSAGE ############
echo -e "####################################################################################################
######################################## FAUST2ROS HELP ############################################
####################################################################################################
################################################################################################
This command allows you to compile a FAUST DSP file into a ROS package,
compressed or ready to be used in a workspace.
################################################################################################
USAGE:
faust2ros ~/path/to/mydsp.dsp
Output : mydsp.zip, a compressed package
OPTIONS :
-install
faust2ros -install ~/path/to/my/workspace ~/other/path/to/mydsp.dsp
Output : mydsp.cpp, a C++ file in a package, in a workspace,
ready to be run
-o
faust2ros -o mynewname ~/path/to/mydsp.dsp
Output : mynewname.zip
For more options and informations, type faust -h or faust --help
####################################################################################################
"
############ END HELP MESSAGE ############
else
# Check if packages exist ; if not, create them
i=0
for (( i = 0 ; i < $WS_LENGTH ; i=$i+1 ))
do
if [ ! -d ${WORKSPACES[${i}]} ]
then
mkdir -p ${WORKSPACES[${i}]}/src
else
cd ${WORKSPACES[${i}]}
if [ ! -d src ]
then
mkdir src
fi
fi
cd ${WORKSPACES[${i}]}/src
if [ ! CMakeLists.txt ] || [ -w CMakeLists.txt ]
then
rm -f CMakeLists.txt
catkin_init_workspace > /dev/null
fi
done
# if there is only one workspace specified, no need to run a loop
if [ $WS_LENGTH = 1 ]
then WORKSPACE_PATH="${WORKSPACES[$1]}"/src
fi
#-------------------------------------------------------------------
# compile the *.dsp files
#
i=0
for p in $FILES
do
# Check .dsp path ; if there is no path, file should be in current directory
temp=$(basename "$p")
temp_path=$(dirname ${p})
if [ ! $temp_path = '.' ]
then
p=$temp
path=$temp_path
fi
# Create dsp package depending on options
if [ "$NEW_NAMES" = "" ]
then
f=$(basename "$p")
name="${f%.dsp}"
else
name="${NEW_NAMES[${i}]}"
fi
# zip file
if [ $WS_LENGTH = 0 ]
then
cd $CURRENT_DIR
temp_dir=$(mktemp -d ROS.XXXXXX)
cd $temp_dir
mkdir src
cd src
catkin_create_pkg $name roscpp std_msgs > /dev/null
PACKAGE_PATH=$CURRENT_DIR/$temp_dir/src/$name
else
# install in workspace
if [ $WS_LENGTH = 1 ]
then
cd $WORKSPACE_PATH
if [[ -d $WORKSPACE_PATH/$name ]]
then
rm -r $WORKSPACE_PATH/$name
fi
catkin_create_pkg $name roscpp std_msgs > /dev/null
PACKAGE_PATH=$WORKSPACE_PATH/$name
else
WORKSPACE_PATH="${WORKSPACES[${i}]}"/src
cd $WORKSPACE_PATH
if [ -d $WORKSPACE_PATH/$name ]
then
rm - r $WORKSPACE_PATH/$name
fi
catkin_create_pkg $name roscpp std_msgs > /dev/null
PACKAGE_PATH=$WORKSPACE_PATH/$name
fi
fi
cd $PACKAGE_PATH
# Set CMakeLists.txt to fit to the faust package
############## CMAKELISTS ############################
echo -e "cmake_minimum_required(VERSION 2.8.3)
project($name)
SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -O3 -mfpmath=sse -msse -msse2 -msse3 -ffast-math\")
include_directories(\${catkin_INCLUDE_DIRS})
catkin_package()
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
)
add_executable(\${PROJECT_NAME} src/\${PROJECT_NAME}.cpp)
target_link_libraries(\${PROJECT_NAME} jack \${catkin_LIBRARIES})" > CMakeLists.txt
############# END CMAKELISTS #########################
# double compilation
cd src
faust -i -a ros-callbacks.cpp -o "$PACKAGE_PATH/src/$name.cpp" $path/$p || exit
g++ $name.cpp -o $name || exit
faust -i -a $ARCHFILE $OPTIONS "$path/$p" -o "$PACKAGE_PATH/src/$name.cpp" $path/$p > /dev/null || exit
./$name # adds the callbacks declaration to the generated c++ file
rm $name
# zip file
if [ $WS_LENGTH = 0 ]
then
cd $CURRENT_DIR/$temp_dir/src/$name
############ BEGIN README ###########################
echo -e " README : Using Faust with ROS
Grame, Centre National de Creation Musicale
###########################################
This file was automatically generated with faust2ros or faust2rosgtk
To run your new application :
1) unzip this package into a ROS workspace.
2) source this workspace :
a) go in your workspace's root
b) type 'source devel/setup.bash'
3) run with 'rosrun myapp myapp'
For more informations, check the documentation :
https://sourceforge.net/p/faudiostream/code/ci/master/tree/documentation" > README.txt
############ END README #############################
cd $CURRENT_DIR/$temp_dir/src
zip -r $name.zip $name > /dev/null
cd $CURRENT_DIR
cp $temp_dir/src/$name.zip $CURRENT_DIR
rm -r $temp_dir
OUTPUT="$OUTPUT $name.zip;"
# package installation
else
cd ${WORKSPACES[${i}]}
############ BEGIN README ###########################
echo -e " README : Using Faust with ROS
Grame, Centre National de Creation Musicale
###########################################
This file was automatically generated with faust2ros or faust2rosgtk
To run your new application :
1) source this workspace :
a) go in your workspace's root
b) type 'source devel/setup.bash'
3) run with 'rosrun myapp myapp'
For more informations, check the documentation :
https://sourceforge.net/p/faudiostream/code/ci/master/tree/documentation" > README.txt
############ END README #############################
catkin_make > /dev/null || exit
OUTPUT="$OUTPUT $name.cpp;"
fi
i=$((i+1))
done
echo $OUTPUT
fi
|