pablogs9 / kobuki_espidf_component

Apache License 2.0
2 stars 0 forks source link

Undefined macros problem #1

Open Vishnu-Vijay95 opened 3 years ago

Vishnu-Vijay95 commented 3 years ago

Hi @pablogs9 , i am trying to port this code to Olimex board, i have some issue with the macros defined in kobuki_platform.h such as CONFIG_KOBUKI_UART_PORT,CONFIG_KOBUKI_UART_TXD,CONFIG_KOBUKI_UART_RXD,CONFIG_KOBUKI_UART_BUFFER_SIZE etc. Kindly let me know in which reference you have used this variables to initialize the macros. Whether they are initialized during runtime or they are ESP platform oriented data. Eager for your reply :))

pablogs9 commented 3 years ago

You don't need to use these macros or these files.

If you want to port this library just modify kobuki_init_serial, kobuki_write_bytes and kobuki_read_bytes with your Olimex code and it should work.

Remove the macros that are not used or giving problems.

Vishnu-Vijay95 commented 3 years ago

Thanks @pablogs9 , i will remove these files, these are the the function which i am also making the changes, i have kept all the headers for compilation which i thought will have some dependency, one more doubt which i have is kobuki bringup part in the code. Can you point out the code used by for this purpose.

pablogs9 commented 3 years ago

Could you be more specific, I don't understand the question.

You have sample code here: https://github.com/pablogs9/kobuki_espidf_component/blob/main/examples/basic_movement/main/main.c

Vishnu-Vijay95 commented 3 years ago

Ok, sorry for that. normally while running kobuki turtlebot2 package in ROS1, we launch a script file to bring up the kobuki robot, such a code i didn't understand from your code. Can you point out that?

pablogs9 commented 3 years ago

But this is not a ROS library, this is just a C99 library that interfaces with the Kobuki serial interface, in this case in the ESP32.

So you have an API for sending and receiving messages from the Kobuki in your MCU.

Vishnu-Vijay95 commented 3 years ago

@pablogs9 , you have used mutex_lock and mutex_unlock in kubuki.c, is it necessary, i didn't got the logic behind.

pablogs9 commented 3 years ago

They are necessary since kobuki_loop is going to run in a thread and kobuki_set_speed_command is going to be called from another thread and should be synchronized.

Vishnu-Vijay95 commented 3 years ago

Ok, that resource sharing has to be done by the RTOS right? these are linux API's right?

Vishnu-Vijay95 commented 3 years ago

i included the mutex lock, but the arm cross compiler is showing an error undefined reference to `pthread_mutex_lock'

pablogs9 commented 3 years ago

This a component for ESP32 and IDF which is not an ARM architecture. I guess that you should use the mutex implementation of your RTOS.

Vishnu-Vijay95 commented 3 years ago

I removed the mutex implementation and compiled the file and i flashed the board with the elf file. connected with the microROS agent in laptop using a usb uart bridge and the listed ros2 topic list. am getting the following topics Screenshot from 2021-03-18 12-45-56 and while echoing the topic /cmd_vel its showing no msg Screenshot from 2021-03-18 12-48-25

pablogs9 commented 3 years ago

cmd vel is a should be a subscription

pablogs9 commented 3 years ago

i mean the robot will not send cmd vel, will receive cmd vel

Vishnu-Vijay95 commented 3 years ago

I connected with the robot its not getting command

Vishnu-Vijay95 commented 3 years ago

You mean this right

RCCHECK(rclc_subscription_init_best_effort(
        &cmd_vel_sub,
        &node,
        ROSIDL_GET_MSG_TYPE_SUPPORT(geometry_msgs, msg, Twist),
        "cmd_vel"));
pablogs9 commented 3 years ago

Yes, but this micro-ROS issues should be in a micro-ROS repo, not here.

Vishnu-Vijay95 commented 3 years ago

Sorry mistakenly closed the issue, i am keeping it open here

Vishnu-Vijay95 commented 3 years ago

Hi @pablogs9, i am writing a custom driver for kobuki, i tested your kobuki esp demo and the code running perfectly, i just took a frame from the esp uart and i am listing it here, AA 55 05 01 04 64 00 00 00 67, i am confused whether 67 is the CRC for the frame. Can you show which CRC algorithm is used here. i checked with XOR all the bits but didn't get 67 hex