forked from n-ando/OpenRTP-aist
-
Notifications
You must be signed in to change notification settings - Fork 6
/
openrtp2
executable file
·195 lines (178 loc) · 5.57 KB
/
openrtp2
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
#!/bin/bash
# RTM_ROOT
#
# This is used to find IDL files. Default IDL file directory is
# $RTM_ROOT/rtm/idl (in Windows)
# In the generic Linux environment, IDL directory is
# $prefix/include/openrtm-x.y/rtm/idl
# Therefore RTM_ROOT should be $prefix/include/openrtm-x.y
#
cd $(cd $(dirname $(readlink -f $0 || echo $0));pwd -P)
debug_echo () {
if test "x$DEBUG" = "xTRUE"; then
echo "$*"
fi
}
#------------------------------------------------------------
# Usage
#------------------------------------------------------------
SCRIPT_NAME=$(basename $0)
tmp=$(readlink $0)
if test "x$tmp" = "x" ; then
SCRIPT_DIR=$(dirname $0)
else
SCRIPT_DIR=$(dirname $tmp)
fi
usage()
{
echo ""
echo "Usage: $SCRIPT_NAME [--help|--debug] [Eclipse options]"
echo ""
echo " --help: print this help message"
echo " --debug: Print debug message"
echo ""
}
#============================================================
# functions
#============================================================
ECLIPSE_ARGS=""
for arg in $* ; do
if test "x$arg" = "x--help" ; then
usage
exit 0
fi
if test "x$arg" = "x--debug" ; then
DEBUG="TRUE"
else
ECLIPSE_ARGS="$ECLIPSE_ARGS $arg"
fi
done
debug_echo "Debug mode enable."
debug_echo "ECLIPSE_ARGS: $ECLIPSE_ARGS"
#------------------------------------------------------------
# set_RTM_ROOT
#
# This functions set RTM_ROOT environmental variable
# 1. If RTM_ROOT is set, it checks RTM_ROOT validity.
# 2. If it is not set, find IDL file by using rtm-config
# and set valid RTM_ROOT.
#------------------------------------------------------------
set_RTM_ROOT()
{
if test "x$RTM_ROOT" = "x"; then
debug_echo "RTM_ROOT is not set."
find_RTM_ROOT
if test "x$RTM_ROOT" = "x" ; then
debug_echo "No OpenRTM-aist (C++) installed found."
debug_echo ""
return 1
fi
fi
# Now RTM_ROOT is set
check_RTM_ROOT
if test $? != 0 ; then
debug_echo ""
debug_echo "WARNING: Invalid RTM_ROOT"
debug_echo " Environmental variable RTM_ROOT = $RTM_ROOT is invalid."
debug_echo " Please check OpenRTM-aist C++ installation."
debug_echo " ex."
debug_echo " If BasicDataType.idl exists under:"
debug_echo " /usr/include/openrtm-2.0/rtm/idl/"
debug_echo " RTM_ROOT should be /usr/include/openrtm-2.0"
debug_echo ""
return 1
fi
debug_echo "Result: RTM_ROOT = " $RTM_ROOT
export RTM_ROOT=$RTM_ROOT
}
#------------------------------------------------------------
# find_RTM_ROOT
#------------------------------------------------------------
find_RTM_ROOT()
{
debug_echo "TRACE: find_RTM_ROOT"
# find RTM_ROOT by rtm2-config
rtm_config=`which rtm2-config`
if test "x$rtm_config" = "x" ; then
# rtm2-config not found
return 1
fi
debug_echo "rtm2_config: " $rtm_config
# check rtm-config version
ver=`grep rtm-idldir $rtm_config`
if test "x$var" = "x" ; then
# old version: no --rtm-idldir option
RTM_ROOT=`rtm2-config --cflags | sed -e 's/.*\-I\(\/.*\)\/rtm\/idl/\1/'`
debug_echo "RTM_ROOT: " $RTM_ROOT
return 0
else
# new version: --rtm-idldir available
RTM_ROOT=`rtm2-config --rtm-idldir | sed -e 's/\/rtm\/idl$//'`
debug_echo "RTM_ROOT: " $RTM_ROOT
return 0
fi
}
#------------------------------------------------------------
# check_RTM_ROOT
#
# This function check if RTM_ROOT environmental variable is valid.
#
#------------------------------------------------------------
check_RTM_ROOT()
{
debug_echo "TRACE: check_RTM_ROOT"
idl_files="BasicDataType.idl ExtendedDataTypes.idl InterfaceDataTypes.idl"
idl_dir=$RTM_ROOT/
debug_echo "Finding IDL files under: " $idl_dir
for idl in $idl_files; do
idl_path=`find $RTM_ROOT -name $idl`
debug_echo "idl_path: " $idl_path
if test "x$idl_path" = "x" ; then
debug_echo "IDL file: " $idl " not found under \$RTM_ROOT"
debug_echo "\$RTM_ROOT = " $RTM_ROOT
return 1
fi
done
return 0
}
find_OPENRTP_DIR()
{
openrtp_dir=`find /usr/lib /usr/lib64 -name 'openrtp' 2>/dev/null`
OPENRTP_DIR=$openrtp_dir
debug_echo "OPENRTP_DIR: $OPENRTP_DIR"
if test -f $OPENRTP_DIR/eclipse ; then
OPENRTP_EXECUTABLE=$OPENRTP_DIR/eclipse
debug_echo "OPENRTP_EXECUTABLE: $OPENRTP_EXECUTABLE"
else
echo "WARNING: No OpenRTP installation under OpenRTM libdir."
fi
eclipse_dir=`find ./ -name 'eclipse' 2>/dev/null`
if test "x$eclipse_dir" != "x" ; then
OPENRTP_DIR="./"
OPENRTP_EXECUTABLE="./eclipse"
debug_echo "OPENRTP_DIR: $OPENRTP_DIR"
debug_echo "OPENRTP_EXECUTABLE: $OPENRTP_EXECUTABLE"
return 0
elif test "x$openrtp_dir" = "x" ; then
echo "ERROR: No OpenRTP installation found. Aborting."
exit 1
fi
}
#------------------------------
# main
#------------------------------
set_RTM_ROOT
if test $? != 0 ; then
echo "WARNING: RTM_ROOT not set."
echo " This might cause failure of data type acquisition for"
echo " data ports definition in RTCBuilder."
echo " If you want use RTCBuilder, please install C++ version"
echo " of OpenRTM-aist on this system."
else
debug_echo " RTM_ROOT : " $RTM_ROOT
fi
find_OPENRTP_DIR
export SWT_GTK3=0
export GDK_NATIVE_WINDOWS=1
cd $OPENRTP_DIR
$OPENRTP_EXECUTABLE $ECLIPSE_ARGS -vmargs -Djava.util.logging.config.file=$OPENRTP_DIR/logger.properties