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

Modifications to run microROS on NuttX RTOS #31

Open
robertobucher opened this issue Dec 2, 2022 · 5 comments
Open

Modifications to run microROS on NuttX RTOS #31

robertobucher opened this issue Dec 2, 2022 · 5 comments

Comments

@robertobucher
Copy link

robertobucher commented Dec 2, 2022

Issue template

microROS on NuttX target runs correctly again, but there are some corrections required to correctly compile the example.

  • Hardware description: nucelo-144 board
  • RTOS: NuttX
  • Installation type: microROS for NuttX (this example)
  • Version or commit hash: galactic

Steps to reproduce the issue

The file micro_ros_src/src/rcutils/src/filesystem.c contains a redefinition of "DIR" (which is already defined in the dirent.h" file in NuTTX).

A test is required such

#ifdef DIR or #ifndef DIR....

Expected behavior

the nuttx application compile again

Actual behavior

There is the error about redefining DIR. To get the compilaton correctly I've commented the line

#ifdef RCUTILS_NO_FILESYSTEM
//typedef int DIR; <=======
#endif // _RCUTILS_NO_FILESYSTEM
typedef struct rcutils_dir_iter_state_t
{
#ifdef _WIN32
HANDLE handle;
WIN32_FIND_DATA data;
#else
DIR * dir;
#endif
} rcutils_dir_iter_state_t;

but it is not the correct solution.

Additional information

I've modified also the microros_main.c file in the microros/example_app

@robertobucher
Copy link
Author

It is not possible to check if the typedef already exists, but a possible solution can be:

....
#ifdef _WIN32
# define RCUTILS_PATH_DELIMITER "\\"
#else
# define RCUTILS_PATH_DELIMITER "/"
#endif  // _WIN32

#ifdef RCUTILS_NO_FILESYSTEM
#ifndef __INCLUDE_DIRENT_H                    <== Check
  typedef int DIR;
#endif                                        <==
#endif  // _RCUTILS_NO_FILESYSTEM
typedef struct rcutils_dir_iter_state_t
{
#ifdef _WIN32
  HANDLE handle;
  WIN32_FIND_DATA data;
#else
  DIR * dir;
#endif
} rcutils_dir_iter_state_t;
...

@pablogs9
Copy link
Member

pablogs9 commented Dec 5, 2022

Hello @robertobucher, please open a PR with your changes.

@pablogs9
Copy link
Member

pablogs9 commented Dec 5, 2022

I guess that related:
micro-ROS/rcutils#23
micro-ROS/rcutils#24

@robertobucher
Copy link
Author

robertobucher commented Dec 5, 2022

Exactly, but I don't know exactly the effects of this check

#ifndef __INCLUDE_DIRENT_H

on the other OS (freertos and zephyr).

For NuttX it is required that the type DIR is not redefined, and the definition is in dirent.h!

This is one of the problems related to microros that causes the failure of the generation of the libmicroros.a.

There are other things but only related to files in this repository (colcon.meta and the microros_main.c).

I tested the the app using a nucleo-144 board and UDP as communication channel under galactic.

@robertobucher
Copy link
Author

robertobucher commented Dec 7, 2022

The patches are now proposed as

micro-ROS/rcutils#25
micro-ROS/rcutils#26

I had some problems by rebasing the 2 repositorires...

With the proposed PR, micro_ros_nuttx_app is able to finish the compilation without errors.
I've tested it only under galactic yet, with my nucleo-144 board and the pysim configuration. The modified microros_main.c is working correctly ant it sends messages to a ROS2 node via UDP through the agent.

I've not tested the serial communication, but only communication via UDP.

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