Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c/i2c.h is missing from Include folder #3

Open
gipaq1950 opened this issue Apr 22, 2023 · 14 comments
Open

i2c/i2c.h is missing from Include folder #3

gipaq1950 opened this issue Apr 22, 2023 · 14 comments

Comments

@gipaq1950
Copy link

I got error i2c/i2c.h missing when I try to build the ICM 20948 ros node package on jetson nano with ros2 foxy .
How to fix it?
Thanks

@polyhobbyist
Copy link
Owner

I think you might be missing libi2c-dev from the host environment. Either that or the dependency hasn't been explicitly declared on the ROS Node.

Here's a repo with a dockerfile which shows how it can be consumed - https://github.com/polyhobbyist/jetbot

@gipaq1950
Copy link
Author

Thank you for quick replay.

I have libi2c-dev installed on Jetson. I added manually i2c.h on the include folder and now I get this error:

colcon build --packages-select ros_qwiic_icm_20948
Starting >>> ros_qwiic_icm_20948
--- stderr: ros_qwiic_icm_20948
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.

Finished <<< ros_qwiic_icm_20948 [13.6s]

Summary: 1 package finished [14.6s]
1 package had stderr output: ros_qwiic_icm_20948

@polyhobbyist
Copy link
Owner

I'll take a look in a couple days - i'm not near my Jetson at the moment.
I committed a fix to the icm_20948 which explicitly adds a dependency to libi2c. This should correct the original build error.

The warning manifests on the jetson - I haven't root caused it. However, you can work around it by using --cmake-args -j1 I believe. which forces the build to use a single thread.

@gipaq1950
Copy link
Author

Did you have a look on this issue? Your last suggestion did not solve it. Thanks.

@polyhobbyist
Copy link
Owner

Thanks for checking in - I'll look at it tonight.

@polyhobbyist
Copy link
Owner

Working on this now - can you tell me more about how you are using this library? Are you using it in a container or on bare metal?

@gipaq1950
Copy link
Author

I have Ubuntu 20.04 installed on Jetson nano and ros2 foxy.

@polyhobbyist
Copy link
Owner

Can you post the full build log? (either from the logs folder, or colcon build --event-handlers=console_direct+)

I'm unable to reproduce this.

the i2c/i2c.h comes from an external cmake project:

find_program(MAKE_EXECUTABLE
    NAMES gmake mingw32-make make
    NAMES_PER_DIR
    DOC "GNU Make")
if(NOT MSVC)
include(ExternalProject)
ExternalProject_Add(libi2c
    GIT_REPOSITORY https://github.com/amaork/libi2c.git
    UPDATE_DISCONNECTED true
    BUILD_IN_SOURCE true
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ${MAKE_EXECUTABLE}
    INSTALL_COMMAND ""
)
ExternalProject_Get_property(libi2c SOURCE_DIR)

message (STATUS "*** libi2c installed to ${SOURCE_DIR}")
target_link_libraries(${PROJECT_NAME} ${SOURCE_DIR}/libi2c.so)
add_dependencies(${PROJECT_NAME}  libi2c)
else()
endif()

I suspect that this isn't being included. Maybe because make isn't found? or the network is blocked?

@gipaq1950
Copy link
Author

Logs.zip

@polyhobbyist
Copy link
Owner

Thanks for the logs.
It looks like a build order problem - wiring.cpp is getting built before libi2c is getting built.

un ros_qwiic_icm_20948 do you have the following line in the makefile?

add_dependencies(${PROJECT_NAME}  libi2c) 

which happens after these lines?

message (STATUS "*** libi2c installed to ${SOURCE_DIR}")
target_link_libraries(${PROJECT_NAME} ${SOURCE_DIR}/libi2c.so)
�[35m�[1mScanning dependencies of target libi2c�[0m
�[35m�[1mScanning dependencies of target ros_qwiic_icm_20948�[0m
[  6%] �[34m�[1mCreating directories for 'libi2c'�[0m
[ 13%] �[34m�[1mPerforming download step (git clone) for 'libi2c'�[0m
[ 26%] �[32mBuilding CXX object CMakeFiles/ros_qwiic_icm_20948.dir/src/wiring_for_ros/Wire.cpp.o�[0m
[ 26%] �[32mBuilding CXX object CMakeFiles/ros_qwiic_icm_20948.dir/src/wiring_for_ros/SPI.cpp.o�[0m
[ 33%] �[32mBuilding CXX object CMakeFiles/ros_qwiic_icm_20948.dir/src/main.cpp.o�[0m
[ 40%] �[32mBuilding CXX object CMakeFiles/ros_qwiic_icm_20948.dir/src/wiring_for_ros/Arduino.cpp.o�[0m
Your branch is up to date with 'origin/master'.
[ 53%] �[34m�[1mSkipping update step for 'libi2c'�[0m
[ 53%] �[34m�[1mNo patch step for 'libi2c'�[0m
[ 60%] �[34m�[1mNo configure step for 'libi2c'�[0m
[ 66%] �[34m�[1mPerforming build step for 'libi2c'�[0m

@gipaq1950
Copy link
Author

I added
add_dependencies(${PROJECT_NAME} libi2c) to cmakelist.txt file and now I don't have error i2c/i2c.h but now I get error:

jetson@nano:~/dev_ws$ colcon build --packages-select ros_qwiic_icm_20948
[1.369s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/jetson/dev_ws/install/ros_qwiic_icm_20948' in the environment variable AMENT_PREFIX_PATH doesn't exist
[1.371s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/jetson/dev_ws/install/ros_qwiic_icm_20948' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Starting >>> ros_qwiic_icm_20948
--- stderr: ros_qwiic_icm_20948
Cloning into 'libi2c'...
Already on 'master'
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.

Finished <<< ros_qwiic_icm_20948 [25.4s]

Summary: 1 package finished [26.7s]
1 package had stderr output: ros_qwiic_icm_20948

@gipaq1950
Copy link
Author

jetson@nano:~/dev_ws$ colcon build --packages-select ros_qwiic_icm_20948
Starting >>> ros_qwiic_icm_20948
--- stderr: ros_qwiic_icm_20948
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.

Finished <<< ros_qwiic_icm_20948 [2.80s]

Summary: 1 package finished [3.77s]
1 package had stderr output: ros_qwiic_icm_20948

@gipaq1950
Copy link
Author

jetson@nano:~/dev_ws$ ros2 launch ros_qwiic_icm_20948 qwiic.launch.py
[INFO] [launch]: All log files can be found below /home/jetson/.ros/log/2023-05-01-03-04-54-778640-nano-19167
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ros_qwiic_icm_20948-1]: process started with pid [19169]
[ros_qwiic_icm_20948-1] /home/jetson/dev_ws/install/ros_qwiic_icm_20948/lib/ros_qwiic_icm_20948/ros_qwiic_icm_20948: symbol lookup error: /home/jetson/dev_ws/install/ros_qwiic_icm_20948/lib/ros_qwiic_icm_20948/ros_qwiic_icm_20948: undefined symbol: i2c_init_device
[ERROR] [ros_qwiic_icm_20948-1]: process has died [pid 19169, exit code 127, cmd '/home/jetson/dev_ws/install/ros_qwiic_icm_20948/lib/ros_qwiic_icm_20948/ros_qwiic_icm_20948 --ros-args -r __node:=ros_qwiic_icm_20948'].

@polyhobbyist
Copy link
Owner

hmmm... it looks like the --package-select causes the issue. Not quite sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants