-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_pdu_ctypes.bash
64 lines (50 loc) · 2.41 KB
/
create_pdu_ctypes.bash
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
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage: $0 <search_path> <ros_msg_pkg/ros_msg_type>"
exit 1
fi
CURR_DIR=`pwd`
TOOL_DIR=utils
JSON_DIR=${TOOL_DIR}/ros_json
TYPES_DIR=${TOOL_DIR}/ros_types
OUT_DIR=pdu/types
CSHARP_OUT_DIR=pdu/csharp
OUT_JSON_DIR=pdu/json
SEARCH_PATH=${CURR_DIR}/${1}
PKG_MSG=${2}
PKG_NAME=`echo ${PKG_MSG} | awk -F/ '{print $1}'`
MSG_NAME=`echo ${PKG_MSG} | awk -F/ '{print $2}'`
#find dependent types
cd ${TYPES_DIR}
bash find_deptypes.bash ${SEARCH_PATH} ${PKG_MSG} > ${CURR_DIR}/dep_types.txt
cd ${CURR_DIR}
#create json file
cd ${JSON_DIR}
bash convert_rosmsg2json.bash ${SEARCH_PATH} ${PKG_MSG} ${CURR_DIR}/${OUT_JSON_DIR}
cd ${CURR_DIR}
#convert json file to c type header
python3 utils/template_engine/generate.py ./template/pdu_ctypes_h.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_header.txt
python3 utils/template_engine/generate.py ./template/pdu_csharp_class.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_csharp.txt
python3 utils/template_engine/generate.py ./template/pdu_ctypes_conv_cpp.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_cpp.txt
python3 utils/template_engine/generate.py ./template/pdu_cpptypes_hpp.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_cpp_header.txt
python3 utils/template_engine/generate.py ./template/pdu_cpptypes_conv_cpp.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_cpp_cpp.txt
# for mavlink only
#python3 utils/template_engine/generate.py ./template/pdu_ctypes_conv_mavlink_cpp.tpl ./${OUT_JSON_DIR}/${PKG_MSG}.json ${CURR_DIR}/dep_types.txt ./config/varray_size.json > tmp_mavlink_cpp.txt
if [ -d ${OUT_DIR}/${PKG_NAME} ]
then
:
else
mkdir -p ${OUT_DIR}/${PKG_NAME}
fi
if [ ! -e ${CSHARP_OUT_DIR}/${PKG_NAME} ]
then
mkdir -p ${CSHARP_OUT_DIR}/${PKG_NAME}
fi
mv tmp_header.txt ${OUT_DIR}/${PKG_NAME}/pdu_ctype_${MSG_NAME}.h
mv tmp_csharp.txt ${CSHARP_OUT_DIR}/${PKG_NAME}/${MSG_NAME}.cs
mv tmp_cpp_header.txt ${OUT_DIR}/${PKG_NAME}/pdu_cpptype_${MSG_NAME}.hpp
mv tmp_cpp.txt ${OUT_DIR}/${PKG_NAME}/pdu_ctype_conv_${MSG_NAME}.hpp
mv tmp_cpp_cpp.txt ${OUT_DIR}/${PKG_NAME}/pdu_cpptype_conv_${MSG_NAME}.hpp
# for mavlink only
#mv tmp_mavlink_cpp.txt ${OUT_DIR}/${PKG_NAME}/pdu_ctype_conv_mavlink_${MSG_NAME}.hpp