generated from dotX-Automation/dua-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: library generation and extra packages
- Loading branch information
Showing
4 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"names": { | ||
"tracetools": { | ||
"cmake-args": [ | ||
"-DTRACETOOLS_DISABLED=ON", | ||
"-DTRACETOOLS_STATUS_CHECKING_TOOL=OFF" | ||
] | ||
}, | ||
"rosidl_typesupport": { | ||
"cmake-args": [ | ||
"-DROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT=ON" | ||
] | ||
}, | ||
"rcl": { | ||
"cmake-args": [ | ||
"-DBUILD_TESTING=OFF", | ||
"-DRCL_COMMAND_LINE_ENABLED=OFF", | ||
"-DRCL_LOGGING_ENABLED=OFF" | ||
] | ||
}, | ||
"rcutils": { | ||
"cmake-args": [ | ||
"-DENABLE_TESTING=OFF", | ||
"-DRCUTILS_NO_FILESYSTEM=ON", | ||
"-DRCUTILS_NO_THREAD_SUPPORT=ON", | ||
"-DRCUTILS_NO_64_ATOMIC=ON", | ||
"-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON" | ||
] | ||
}, | ||
"microxrcedds_client": { | ||
"cmake-args": [ | ||
"-DUCLIENT_PIC=OFF", | ||
"-DUCLIENT_PROFILE_UDP=OFF", | ||
"-DUCLIENT_PROFILE_TCP=OFF", | ||
"-DUCLIENT_PROFILE_DISCOVERY=OFF", | ||
"-DUCLIENT_PROFILE_SERIAL=OFF", | ||
"-UCLIENT_PROFILE_STREAM_FRAMING=ON", | ||
"-DUCLIENT_PROFILE_CUSTOM_TRANSPORT=ON" | ||
] | ||
}, | ||
"rmw_microxrcedds": { | ||
"cmake-args": [ | ||
"-DRMW_UXRCE_MAX_NODES=1", | ||
"-DRMW_UXRCE_MAX_PUBLISHERS=10", | ||
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=5", | ||
"-DRMW_UXRCE_MAX_SERVICES=1", | ||
"-DRMW_UXRCE_MAX_CLIENTS=1", | ||
"-DRMW_UXRCE_MAX_HISTORY=4", | ||
"-DRMW_UXRCE_TRANSPORT=custom" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Controlla se il numero di argomenti è corretto | ||
if [ "$#" -ne 1 ]; then | ||
echo "Uso: $0 <directory>" | ||
exit 1 | ||
fi | ||
|
||
#sudo rosdep init | ||
#rosdep update | ||
#sudo apt update | ||
|
||
export BASE_PATH=/$1/$MICROROS_LIBRARY_FOLDER | ||
#export BASE_PATH=$1 | ||
|
||
######## Init ######## | ||
|
||
source /opt/ros/$ROS_DISTRO/setup.bash | ||
source install/local_setup.bash | ||
|
||
ros2 run micro_ros_setup create_firmware_ws.sh generate_lib | ||
|
||
######## Adding extra packages ######## | ||
pushd firmware/mcu_ws > /dev/null | ||
|
||
# Import user defined packages | ||
mkdir extra_packages | ||
pushd extra_packages > /dev/null | ||
USER_CUSTOM_PACKAGES_DIR=../../../config/extra_packages | ||
if [ -d "$USER_CUSTOM_PACKAGES_DIR" ]; then | ||
cp -R $USER_CUSTOM_PACKAGES_DIR/* . | ||
fi | ||
if [ -f $USER_CUSTOM_PACKAGES_DIR/extra_packages.repos ]; then | ||
vcs import --input $USER_CUSTOM_PACKAGES_DIR/extra_packages.repos | ||
fi | ||
cp -R ../../../config/extra_packages/* . | ||
vcs import --input extra_packages.repos | ||
popd > /dev/null | ||
|
||
popd > /dev/null | ||
|
||
######## Trying to retrieve CFLAGS ######## | ||
pushd $1 > /dev/null | ||
export RET_CFLAGS=$(make print_cflags) | ||
RET_CODE=$? | ||
|
||
if [ $RET_CODE = "0" ]; then | ||
echo "Found CFLAGS:" | ||
echo "-------------" | ||
echo $RET_CFLAGS | ||
echo "-------------" | ||
read -p "Do you want to continue with them? (y/n)" -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]] | ||
then | ||
echo "Continuing..." | ||
else | ||
echo "Aborting" | ||
exit 0; | ||
fi | ||
else | ||
echo "Please read README.md to update your Makefile" | ||
exit 1; | ||
fi | ||
popd > /dev/null | ||
|
||
######## Build ######## | ||
export TOOLCHAIN_PREFIX=arm-none-eabi- | ||
ros2 run micro_ros_setup build_firmware.sh /home/neo/workspace/bin/library-generation/toolchain.cmake /home/neo/workspace/bin/library-generation/colcon.meta | ||
|
||
find firmware/build/include/ -name "*.c" -delete | ||
rm -rf $BASE_PATH/libmicroros | ||
mkdir -p $BASE_PATH/libmicroros/microros_include | ||
cp -R firmware/build/include/* $BASE_PATH/libmicroros/microros_include/ | ||
cp -R firmware/build/libmicroros.a $BASE_PATH/libmicroros/libmicroros.a | ||
|
||
######## Fix include paths ######## | ||
pushd firmware/mcu_ws > /dev/null | ||
INCLUDE_ROS2_PACKAGES=$(colcon list | awk '{print $1}' | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}') | ||
popd > /dev/null | ||
|
||
for var in ${INCLUDE_ROS2_PACKAGES}; do | ||
if [ -d "$BASE_PATH/libmicroros/microros_include/${var}/${var}" ]; then | ||
rsync -r $BASE_PATH/libmicroros/microros_include/${var}/${var}/* $BASE_PATH/libmicroros/microros_include/${var} | ||
rm -rf $BASE_PATH/libmicroros/microros_include/${var}/${var} | ||
fi | ||
done | ||
|
||
######## Generate extra files ######## | ||
find firmware/mcu_ws/ros2 \( -name "*.srv" -o -name "*.msg" -o -name "*.action" \) | awk -F"/" '{print $(NF-2)"/"$NF}' > $BASE_PATH/libmicroros/available_ros2_types | ||
find firmware/mcu_ws/extra_packages \( -name "*.srv" -o -name "*.msg" -o -name "*.action" \) | awk -F"/" '{print $(NF-2)"/"$NF}' >> $BASE_PATH/libmicroros/available_ros2_types | ||
|
||
cd firmware | ||
echo "" > $BASE_PATH/libmicroros/built_packages | ||
for f in $(find $(pwd) -name .git -type d); do pushd $f > /dev/null; echo $(git config --get remote.origin.url) $(git rev-parse HEAD) >> $BASE_PATH/libmicroros/built_packages; popd > /dev/null; done; | ||
|
||
######## Fix permissions ######## | ||
sudo chmod -R 777 $BASE_PATH/libmicroros/ | ||
sudo chmod -R 777 $BASE_PATH/libmicroros/microros_include/ | ||
sudo chmod -R 777 $BASE_PATH/libmicroros/libmicroros.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SET(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_CROSSCOMPILING 1) | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
||
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_PREFIX}gcc) | ||
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_PREFIX}g++) | ||
|
||
SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") | ||
|
||
set(FLAGS $ENV{RET_CFLAGS} CACHE STRING "" FORCE) | ||
set(MICROROSFLAGS "-DCLOCK_MONOTONIC=0 -D'__attribute__(x)='" CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_C_FLAGS_INIT "-std=c11 ${FLAGS} ${MICROROSFLAGS} " CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_INIT "-std=c++14 ${FLAGS} -fno-rtti ${MICROROSFLAGS} " CACHE STRING "" FORCE) | ||
|
||
set(__BIG_ENDIAN__ 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repositories: | ||
control_msgs: | ||
type: git | ||
url: https://github.com/ros-controls/control_msgs | ||
version: humble |