-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial * Update Fix Fix permissions
- Loading branch information
Showing
18 changed files
with
220 additions
and
63 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 |
---|---|---|
|
@@ -7,4 +7,5 @@ Makefile | |
*.s | ||
*.ld | ||
build | ||
.vscode | ||
.vscode | ||
libmicroros |
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
microros_static_library_ide/library_generation/colcon.meta
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" | ||
] | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
microros_static_library_ide/library_generation/extra_packages/extra_packages.repos
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: foxy-devel |
21 changes: 21 additions & 0 deletions
21
microros_static_library_ide/library_generation/extract_flags.py
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,21 @@ | ||
import sys | ||
|
||
text = sys.stdin.read().replace('\n', ' ').split(' ') | ||
|
||
mcpu = [x for x in text if x.startswith("-mcpu")] | ||
mfpu = [x for x in text if x.startswith("-mfpu")] | ||
mfloatabi = [x for x in text if x.startswith("-mfloat-abi")] | ||
mthumb = [x for x in text if x.startswith("-mthumb")] | ||
optimization = [x for x in text if x.startswith("-O")] | ||
|
||
out = "-ffunction-sections -fdata-sections" | ||
if len(mcpu) and len(mfpu) and len(mfloatabi): | ||
out = out + " " + mcpu[0] + " " + mfpu[0] + " " + mfloatabi[0] | ||
if len(mthumb): | ||
out = out + " " + mthumb[0] | ||
if len(optimization): | ||
out = out + " " + optimization[0] | ||
print(out) | ||
sys.exit(0) | ||
else: | ||
sys.exit(1) |
75 changes: 75 additions & 0 deletions
75
microros_static_library_ide/library_generation/library_generation.sh
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,75 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export BASE_PATH=/project/micro_ros_stm32cubemx_utils/microros_static_library_ide | ||
|
||
######## Check existing library ######## | ||
if [ -f "$BASE_PATH/libmicroros/libmicroros.a" ]; then | ||
echo "micro-ROS library found. Skipping..." | ||
echo "Delete micro_ros_stm32cubemx_utils/microros_static_library_ide/libmicroros/ for rebuild." | ||
exit 0 | ||
fi | ||
######## Trying to retrieve CFLAGS ######## | ||
export RET_CFLAGS=$(find /project -type f -name *.mk -exec cat {} \; | python3 $BASE_PATH/library_generation/extract_flags.py) | ||
RET_CODE=$? | ||
|
||
if [ $RET_CODE = "0" ]; then | ||
echo "Found CFLAGS:" | ||
echo "-------------" | ||
echo $RET_CFLAGS | ||
echo "-------------" | ||
else | ||
echo "Error retrieving croscompiler flags" | ||
exit 1; | ||
fi | ||
|
||
######## Init ######## | ||
apt update | ||
apt install -y gcc-arm-none-eabi | ||
|
||
cd /uros_ws | ||
|
||
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 | ||
|
||
# Workaround: Copy just tf2_msgs | ||
git clone -b foxy https://github.com/ros2/geometry2 | ||
cp -R geometry2/tf2_msgs ros2/tf2_msgs | ||
rm -rf geometry2 | ||
|
||
# Import user defined packages | ||
mkdir extra_packages | ||
pushd extra_packages > /dev/null | ||
cp -R $BASE_PATH/library_generation/extra_packages/* . | ||
vcs import --input extra_packages.repos | ||
popd > /dev/null | ||
|
||
popd > /dev/null | ||
|
||
######## Build ######## | ||
export TOOLCHAIN_PREFIX=/usr/bin/arm-none-eabi- | ||
ros2 run micro_ros_setup build_firmware.sh $BASE_PATH/library_generation/toolchain.cmake $BASE_PATH/library_generation/colcon.meta | ||
|
||
find firmware/build/include/ -name "*.c" -delete | ||
rm -rf $BASE_PATH/libmicroros | ||
mkdir -p $BASE_PATH/libmicroros/include | ||
cp -R firmware/build/include/* $BASE_PATH/libmicroros/include/ | ||
cp -R firmware/build/libmicroros.a $BASE_PATH/libmicroros/libmicroros.a | ||
|
||
######## 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/include/ | ||
sudo chmod -R 777 $BASE_PATH/libmicroros/libmicroros.a |
17 changes: 17 additions & 0 deletions
17
microros_static_library_ide/library_generation/toolchain.cmake
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) |