ROBOTIS-GIT / ros2arduino

This library helps the Arduino board communicate with the ROS2 using XRCE-DDS.
Apache License 2.0
219 stars 43 forks source link

ESP32 Serial Communication & Build Error #60

Closed bekirbostanci closed 2 years ago

bekirbostanci commented 3 years ago

Hi Firstly I am trying serial commication with esp32 however when I try to build it gives this error.

Building in release mode
Compiling .pio/build/esp32doit-devkit-v1/lib346/ros2arduino/uxr/client/profile/transport/transport_arduino_internal.cpp.o
lib/ros2arduino/src/uxr/client/profile/transport/transport_arduino_internal.cpp:68:20: fatal error: WiFi.h: No such file or directory

**************************************************************
* Looking for WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:WiFi.h
*
**************************************************************

compilation terminated.
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/Print.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/WString.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/base64.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/cbuf.cpp.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/esp32-hal-bt.c.o
*** [.pio/build/esp32doit-devkit-v1/lib346/ros2arduino/uxr/client/profile/transport/transport_arduino_internal.cpp.o] Error 1

I tried to change transport_arduino_internal.cpp file I deleted these lines in transport_arduino_internal.cpp file. Note : I dont need UDP or TCP so that it is not important for me.

#if defined(ESP_PLATFORM)
  #include <WiFi.h>
  #include <WiFiUdp.h>
#endif
#if defined(ESP_PLATFORM)
  WiFiUDP *p_wifi_udp = (WiFiUDP*)udp_instance;
  p_wifi_udp->begin(WiFi.localIP(), local_port);
#else
  p_udp->begin(local_port);
#endif  

Aftert this process it worked and upload to esp32 but when I checked it from Serial Monitor I saw nothing was shared. only after the first reset a few lines of characters appear to be shared

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀�X�␀␀XXa␀��~␀�␀␀␀␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��~␀␀␘␀�␀␀␀␀␁␐␀XRCE␁␀␁␏���݁␀�␇��da�␀␀ce></␀pk␀t␀v::x␇�␌���:_
␁␅␀␂␀␀
bekirbostanci commented 3 years ago

I controlled publishString function but it looks like not working. I added pinMode(2, OUTPUT); at setup

void publishString(std_msgs::String* msg, void* arg)
{
  digitalWrite(2,HIGH);   
  delay(200);
  digitalWrite(2,LOW);   
  delay(200);

  (void)(arg);

  static int cnt = 0;

  sprintf(msg->data, "Hello ros2arduino %d", cnt++);

}