micro-ros / freertos_apps Goto Github PK
View Code? Open in Web Editor NEWSample applications for FreeRTOS + micro-ROS
License: Apache License 2.0
Sample applications for FreeRTOS + micro-ROS
License: Apache License 2.0
Hi, again! I'm trying to develop a code that publishes datas in a topic and, in this code, there is a subscriber too with another topic, wich name is different, to receive these same datas. I don't know if this ideia make sense, the both topic names appear when I run the command "ros2 topic list" but none receive data when I use the command "ros2 topic echo". I apreciate any help or tip.
Hardware description: ESP32S
RTOS: FreeRTOS
Installation type: micro_ros_setup
Version or commit hash: ROS Foxy
#include <stdio.h>
#include <unistd.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <std_msgs/msg/int64_multi_array.h>
#include <std_msgs/msg/multi_array_dimension.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#define BUFFER_SIZE 10
#define STRING_SIZE 30
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);vTaskDelete(NULL);}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
rcl_publisher_t publisher;
rcl_subscription_t subscriber;
std_msgs__msg__Int64MultiArray msg;
void subscription_callback(const void * msgin,rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
const std_msgs__msg__Int64MultiArray * message = (const std_msgs__msg__Int64MultiArray *)msgin;
if (timer != NULL) {
printf("Recebido: %lld\n", message->data.data[0]);
}
}
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data.data[0] = msg.data.data[0] + 2;
msg.data.data[1] = msg.data.data[1] + 4;
msg.data.data[2] = msg.data.data[2] + 7;
msg.data.data[3] = msg.data.data[3] + 12;
}
}
void appMain(void * arg)
{
rcl_allocator_t allocator = rcl_get_default_allocator();
rclc_support_t support;
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "int64_array_publisher", "", &support));
// criar noh do subscriber
rcl_node_t noh;
RCCHECK(rclc_node_init_default(&noh, "int64_array_subscriber", "", &support));
// create publisher
RCCHECK(rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int64MultiArray),
"int64_array_publisher"));
// create subscriber
RCCHECK(rclc_subscription_init_default(
&subscriber,
&noh,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int64MultiArray),
"/int64_array_subscriber"));
// create timer,
rcl_timer_t timer;
const unsigned int timer_timeout = 1000;
RCCHECK(rclc_timer_init_default(
&timer,
&support,
RCL_MS_TO_NS(timer_timeout),
timer_callback));
// create executor
rclc_executor_t executor;
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA));
RCCHECK(rclc_executor_add_timer(&executor, &timer));
// Assing memory to msg
int64_t buffer[BUFFER_SIZE] = {};
msg.data.data = buffer;
msg.data.size = 0;
msg.data.capacity = BUFFER_SIZE;
std_msgs__msg__MultiArrayDimension dim[BUFFER_SIZE] = {};
msg.layout.dim.data = dim;
msg.layout.dim.size = 0;
msg.layout.dim.capacity = BUFFER_SIZE;
char labels[BUFFER_SIZE][STRING_SIZE] = {};
for (size_t i = 0; i < BUFFER_SIZE; i++)
{
msg.layout.dim.data[i].label.data = labels[i];
msg.layout.dim.data[i].label.size = 0;
msg.layout.dim.data[i].label.capacity = STRING_SIZE;
}
// Fill the message with dummy data
for (size_t i = 0; i < BUFFER_SIZE; i++)
{
msg.data.data[i] = i;
msg.data.size++;
}
msg.layout.data_offset = 42;
for (size_t i = 0; i < BUFFER_SIZE; i++)
{
snprintf(msg.layout.dim.data[i].label.data, STRING_SIZE, "label_%u", i);
msg.layout.dim.data[i].label.size = strlen(msg.layout.dim.data[i].label.data);
msg.layout.dim.data[i].size = 42;
msg.layout.dim.data[i].stride = 42;
}
while(1){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
usleep(100000);
}
// free resources
RCCHECK(rcl_publisher_fini(&publisher, &node));
RCCHECK(rcl_subscription_fini(&subscriber, &noh));
RCCHECK(rcl_node_fini(&node));
vTaskDelete(NULL);
}
app-colcon.meta:
{
"names": {
"rmw_microxrcedds": {
"cmake-args": [
"-DRMW_UXRCE_MAX_NODES=2",
"-DRMW_UXRCE_MAX_PUBLISHERS=1",
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=1",
"-DRMW_UXRCE_MAX_SERVICES=0",
"-DRMW_UXRCE_MAX_CLIENTS=0",
"-DRMW_UXRCE_MAX_HISTORY=1",
]
}
}
}
the ethernet communication is available even if the ethernet is not connected when the application starts, basically the need is to have a behavior that seems to the ethernet in a ubuntu or windows device in which you could connect the ethernet in any moment and still it's going to work.
Just if the ethernet is from the beginning connected you can unplug the ethernet and when you reconnect it is still working the communication with the agent, but if you don't plugin in the beginning you will never be able to get communication with this.
I believe this a problem related with the initialization of the ethernet, I have tried to read the code related with this but I could be able to find the piece of code that control this behavior, additionally I would like to have the DHCP client working in a task looking all the time for changes in the network, in this way in any moment of the application when I connect the ethernet the microcontroller would be able to get an IP and all the network stuff.
i would really appreciate i anyone know how to make this working and can help me. thanks.
https://github.com/ZhenshengLee/ros2_mcu/tree/master/libs/custom_stm32f767zi
compile and flash with udp configuration.
colcon.meta is https://github.com/ZhenshengLee/ros2_mcu/blob/master/mcu_ws/colcon.meta
app-colcol.meta is https://github.com/ZhenshengLee/ros2_mcu/blob/master/apps/int32_publisher/app-colcon.meta
udp connectiong success, with agent output info.
ping 192.168.1.110 success.
but agent output nothing with
ros2 run micro_ros_agent micro_ros_agent udp4 -p 8000 -v6
[1646914947.040102] info | UDPv4AgentLinux.cpp | init | running... | port: 8000
[1646914947.040316] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
serial output the follow
IP is got, but Failed status on line 37: 1. Aborting.
which is
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
Follow Tutorial at https://micro-ros.github.io/docs/tutorials/core/first_application_rtos/freertos/
Build completes with no errors...
Results in this errors
/home/ubu/microros_ws/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/rmw_init.c:280:8: error: too many arguments to function 'uxr_init_serial_transport'
if (!uxr_init_serial_transport(
^~~~~~~~~~~~~~~~~~~~~~~~~
It also fails when configured for transport UDP with similar error message
I isolated the issue when removing commits
eProsima/Micro-XRCE-DDS-Client#184
eProsima/Micro-XRCE-DDS-Client#183
from eProsima/Micro-XRCE-DDS-Client
With these commits removed the build completes without error.
Note: I could not remove 183 without removing 184.
Hello,
I'm trying to do the tutorial 'First micro-ROS Application on FreeRTOS' using vivado with C language. But I have no idea how to translate the terminal-instructions to a program, or how to realize the functions of porting micro-ROS on FreeRTOS in code. Could anyone give me some suggestions? Keywords and documentations?
Thank you.
Best regards,
YongYi
Just run the FreeRTOS Ping-Pong first app Tutorial with Foxy as RTOS version
Buld works, client can connect to agent and can send out pings
Since last Friday 11/5 with previous install client create init options
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
but agent would crash when initializing pingpong_node.
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "pingpong_node", "", &support)); ,== crashed here.
Today following the tutorial fresh the build does not complete and issues the following error.
Starting >>> microxrcedds_client
Finished <<< tracetools_launch [1.02s]
Finished <<< tracetools [2.60s]
Finished <<< rosidl_parser [1.28s]
Starting >>> rosidl_cmake
Finished <<< ros2trace [0.93s]
Finished <<< tinydir_vendor [3.97s]
Starting >>> rcutils
Finished <<< rosidl_cmake [1.08s]
Starting >>> rosidl_generator_dds_idl
--- stderr: microxrcedds_client
/home/ubu/ws_check/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/ip_posix.c:18:10: fatal error: arpa/inet.h: No such file or directory
#include <arpa/inet.h>
^~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/microxrcedds_client.dir/build.make:391: CMakeFiles/microxrcedds_client.dir/src/c/profile/transport/ip/ip_posix.c.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/Makefile2:79: CMakeFiles/microxrcedds_client.dir/all] Error 2
make[1]: *** [Makefile:133: all] Error 2
Thank you
Hi everyone !
I am working on porting stm32f407g-disc1 in freeRTOS. For the moment I have successfully configured,built and flashed uros in my board but I am not able to connect and register with my host microros agent. Do you have an idea where the problem might be ? (I have no error code but I do have some warnings related to allocator.c)
Board: Discovery1 - STM32F407G
RTOS: FreeRTOS
App: int32_publisher
Config, build, flash are working
I am using UART 2 which is connected to my computer by a UART-USB bridge.
Any help would be appreciated.
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_0670FF555071494867152654-if02
ros2 topic echo /freertos_int32_publisher
Any time you plug the board, agent would established the link.
agent output
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_0670FF555071494867152654-if02
[1646308710.731945] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1646308710.732117] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
If you first run agent, then plug the board, the link will be established, and the demo would work
I think it may be related with #72 , and may be a problem with the initialization of the serial link.
I am not familar with embedded development so any help would be appreciated.
Thanks.
Hi, I'm a new in ROS world and I'm exploring the freertos apps examples of micro-ROS firmware (https://github.com/micro-ROS/freertos_apps/tree/foxy/apps) and trying to create one that publishes elements of an array. I have basic knowledge about C++ but I'm not getting how to make this works. I'm trying by diffent ways: using static alocation and dynamic alocation.
Dynamic alocation:
#include <stdio.h>
#include <unistd.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <std_msgs/msg/int64_multi_array.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);vTaskDelete(NULL);}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
rcl_publisher_t publisher;
std_msgs__msg__Int64MultiArray msg;
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.layout.dim.data[0].label.data++;
msg.layout.dim.data[1].label.data++;
msg.layout.dim.data[2].label.data++;
msg.layout.dim.data[3].label.data++;
}
}
void appMain(void * arg)
{
rcl_allocator_t allocator = rcl_get_default_allocator();
rclc_support_t support;
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "int64_array_publisher", "", &support));
// create publisher
RCCHECK(rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int64MultiArray),
"int64_array_publisher"));
// create timer,
rcl_timer_t timer;
const unsigned int timer_timeout = 1000;
RCCHECK(rclc_timer_init_default(
&timer,
&support,
RCL_MS_TO_NS(timer_timeout),
timer_callback));
// create executor
rclc_executor_t executor;
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_timer(&executor, &timer));
msg.data.capacity = 100;
msg.data.size = 0;
msg.data.data = (int64_t*) malloc(msg.data.capacity * sizeof(int64_t));
msg.layout.dim.capacity = 100;
msg.layout.dim.size = 0;
msg.layout.dim.data = (std_msgs__msg__MultiArrayDimension*) malloc(msg.layout.dim.capacity * sizeof(std_msgs__msg__MultiArrayDimension));
for(size_t i = 0; i < msg.layout.dim.capacity; i++){
msg.layout.dim.data[i].label.capacity = 100;
msg.layout.dim.data[i].label.size = 0;
msg.layout.dim.data[i].label.data = (char*) malloc(msg.layout.dim.data[i].label.capacity * sizeof(char));
}
while(1){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
usleep(100000);
}
// free resources
RCCHECK(rcl_publisher_fini(&publisher, &node))
RCCHECK(rcl_node_fini(&node))
vTaskDelete(NULL);
}
Static alocation:
#include <stdio.h>
#include <unistd.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <std_msgs/msg/int64_multi_array.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);vTaskDelete(NULL);}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
rcl_publisher_t publisher;
std_msgs__msg__Int64MultiArray msg[4];
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg->data.data[0]++, msg->data.data[1]++, msg->data.data[2]++, msg->data.data[3]++;
}
}
void appMain(void * arg)
{
rcl_allocator_t allocator = rcl_get_default_allocator();
rclc_support_t support;
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "int64_array_publisher", "", &support));
// create publisher
RCCHECK(rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int64MultiArray),
"int64_array_publisher"));
// create timer,
rcl_timer_t timer;
const unsigned int timer_timeout = 1000;
RCCHECK(rclc_timer_init_default(
&timer,
&support,
RCL_MS_TO_NS(timer_timeout),
timer_callback));
// create executor
rclc_executor_t executor;
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_timer(&executor, &timer));
msg->data.data[0] = 2;
msg->data.data[1] = 5;
msg->data.data[2] = 10;
msg->data.data[3] = 16;
while(1){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
usleep(100000);
}
// free resources
RCCHECK(rcl_publisher_fini(&publisher, &node))
RCCHECK(rcl_node_fini(&node))
vTaskDelete(NULL);
}
The second one compiles, using these steps: https://medium.com/@SameerT009/connect-esp32-to-ros2-foxy-5f06e0cc64df, but when I use the echo command looks like there is nothing being published on the topic. Anyway, I was using the int32_publisher example like support but I don't know how to deal with Int64MultiArray, I already read https://micro.ros.org/docs/tutorials/advanced/handling_type_memory/ and micro-ROS/micro_ros_arduino#413.
Hello
I am a newbie to ROS and currently studying it. I followed tutorials on github that you guys published.
I want to debug it using STM32CubeIDE to the Olimex STM32F407 board. Later on, I want to try it on custom board.
I've imported Posix, Micro-xrce-dds, rcl ... libraries to my workspace. But when I try to build the project, it gives the errors related with dependancy and configurations.
If it is possible, could you please provide a tutorial or any documentation about debugging micro-Ros app from IDE(freeRTOS).
Kind regards
Hello,
I have a new feature suggestion for a new example.
Do you have any examples, using any RTOS, using topics with Float64 data?
I am using the TIMx encoder hardware from the STM32F407 on the Olimex board to populate a sensor_msgs/JointState.msg.
http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/JointState.html
The firmware encoder data is float, but the JointState,position and JointState.velocity are float64.
Casting doesn’t to work to assign the fw encoder data to the msg data. Any suggestions how to configure to solve?
I have an imu publisher working with float data without any problems.
Thanks for your time…
ping_pong is unmodified from freertos_apps/apps/ping_pong/ (dashing branch)
To configure I used...
ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport serial --dev 3
It builds.
I found in rmw_init.c,
"(!uxr_create_session(&context_impl->session))"
always returns RMW_RET_ERROR when I configured with transport = custom_serial and dev = 3.
stepping through "uxr_create_session" it steps through by some functions take very long time in my debugger.
attached is an image of the struc session when it is called.
I have verified transport = udp and app-colon.meta modified to support udp the app builds and works with an Agent, so I think this is something specific with default serial-custom transport.
I got UDP working on another STM32 board and was testing serial mode from completeness. I found this issue on my board and then I reproduced this issue on the supported Olimex E407 hardware.
On another note I forked micro-ros-build and freertos_apps to add STM32F439ZI-Nucleo board support. Is this something you are interested for mainline, or is there a place for other hardware to be posted (ie my git) or not interest at this time?
I add string subscriber to ping_pong
app, and when initialize it, I get some error from the printf.
can the microROS connect to moveit2?
None
None
Following the apps/image_publisher/ example application I want to publish audio data. For now I just use dummy data. This code will work with 1024 elements. As soon as I change this to 2014*2 or larger, the publisher will fail. RCSOFTCHECK gives me: "Failed status on line 201: 1. Continuing.". I searched for the meaning of this error code, but it seems to be a generic error, which doesn't help me. Allocating with malloc does not fail, which I am checking with the print statement.
This is how I create my message:
int ELEMENTS = 1024*1;
msg->audio_data.capacity = ELEMENTS * sizeof(uint8_t);
printf("allocating %d\n", msg->audio_data.capacity);
msg->audio_data.data = (uint8_t *) malloc(msg->audio_data.capacity);
if(msg->audio_data.data == NULL){
printf("malloc failed!");
}else{
printf("malloc succeded!");
}
memset(msg->audio_data.data, 0x24, msg->audio_data.capacity);
msg->audio_data.size = msg->audio_data.capacity;
msg->sampling_rate = 16000;
msg->chunk_width = 1024;
msg->sample_size = 16;`
Which is then published with a timer:
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
printf("Publishing some data.\n");
RCSOFTCHECK(rcl_publish(&publisher, msg, NULL));
}
}
I have found other issues for example this one: micro-ROS/rmw_microxrcedds#53 where a similar problem is being discussed. I tried changing my app-colcon.meta to set the history and MTU values with no change.
{
"names": {
"rmw_microxrcedds": {
"cmake-args": [
"-DRMW_UXRCE_MAX_NODES=1",
"-DRMW_UXRCE_MAX_PUBLISHERS=1",
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=0",
"-DRMW_UXRCE_MAX_SERVICES=0",
"-DRMW_UXRCE_MAX_CLIENTS=0",
"-DRMW_UXRCE_MAX_HISTORY=16",
"-DRMW_UXRCE_STREAM_HISTORY=16",
]
},
"microxrcedds_client": {
"cmake-args": [
"-DUCLIENT_UDP_TRANSPORT_MTU=4096",
]
}
}
}
I have also changed a line in /firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/CMakeLists.txt so now it says : set(UCLIENT_UDP_TRANSPORT_MTU 4096 CACHE STRING "Set the UDP transport MTU.")
. This has changed nothing.
Am I editing the wrong files or is my problem somewhere else?
the configure I used :
ros2 run micro_ros_setup configure_firmware.sh ping_pong -t udp -i 192.168.0.181 -p 8888
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v 6
and change the IP addresses in lwip.c:
void MX_LWIP_Init(void)
{
/* Initilialize the LwIP stack with RTOS */
tcpip_init( NULL, NULL );
osThreadAttr_t attributes;
ipaddr.addr = 0xC0A800B5;//192.168.0.181
netmask.addr = 0xFFFFFF00;//255.255.255.0
gw.addr = 0xC0A80001;//192.168.0.1
......
it builds and works:
[1610689478.070872] info | UDPv4AgentLinux.cpp | init | running... | port: 8888
[1610689478.071353] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
and the port8888:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
micro_ros 4579 xu 4u IPv4 71317 0t0 UDP *:8888
but win i ping 192.168.0.181,it shows:
From 192.168.0.180 icmp_seq=166 Destination Host Unreachable
and win i use:ros2 topic echo /microROS/ping
WARNING: topic [/microROS/ping] does not appear to be published yet
Could not determine the type for the passed topic
the uart shows:
Ethernet Initialization␍␊
Waiting for IP␍␊
IP: 181.0.168.192␍␊
UDP mode => ip: 192.168.0.181 - port: 8888␊
**********************************␊
Task State Prio Stack Num␊
**********************************␊
initTask ⇥ X⇥ 23⇥ 118⇥ 3␍␊
IDLE ⇥ R⇥ 0⇥ 104⇥ 4␍␊
tcpip_thread ⇥ B⇥ 24⇥ 149⇥ 1␍␊
microROS_app ⇥ B⇥ 25⇥ 1660⇥ 6␍␊
Tmr Svc ⇥ B⇥ 2⇥ 214⇥ 5␍␊
EthIf ⇥ B⇥ 48⇥ 2⇥ 2␍␊
**********************************␊
[ERROR] [ld.ld] [rclc]: [rclc_init] Error in rcl_init: error not set␊
Failed status on line 87: 1. Aborting.␊
does olimexe407 support this configure?
or can you give me codes or settings that works?
thank you
Hi,
When trying to publish messages from different FreeRTOS task errors occur
and esp32 going to reboot
I've found the same error description with esp32 web server
https://www.esp32.com/viewtopic.php?t=3198
Errors of two types occur
CORRUPT HEAP: multi_heap.c:395 detected at 0x3ffbf968
abort() was called at PC 0x40086955 on core 1
INFO: rcl_wait timeout 0 ms
assertion "pbuf_free: p->ref > 0" failed: file "/opt/esp/idf/components/lwip/lwip/src/core/pbuf.c", line 757, function: pbuf_free
abort() was called at PC 0x40142bab on core 1
ELF file SHA256: e47e78ae1b6cd29d
Backtrace: 0x40087901:0x3ffc8e10 0x40087c85:0x3ffc8e30 0x40142bab:0x3ffc8e50 0x400f189b:0x3ffc8e80 0x40102e19:0x3ffc8ea0 0x400edf63:0x3ffc8ec0 0x400eeb6e:0x3ffc8f00 0x400eebee:0x3ffc8f60 0x400e4021:0x3ffc8f80 0x400e3e3a:0x3ffc8fb0 0x400def76:0x3ffc8fe0 0x400df678:0x3ffc9080 0x400dcf10:0x3ffc90a0 0x400d9571:0x3ffc90f0 0x400d612d:0x3ffc9110 0x40152221:0x3ffc9130 0x400d8985:0x3ffc9150 0x40088215:0x3ffc9180
Rebooting...
ets Jun 8 2016 00:22:57
If some information is available on this error please share it.
Regards,
Dmitry
ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport serial --dev 1
After execute this and build the firmware, ROS can still get message from UART3 instead of UART1.
It seems that only UART3 has DMA configured in stm32f4xx_hal_msp.c.
I have passed the test, freertos app's ping_pong, I would like to ask if there is an example of changing app.c to app.cpp. Under keil IDE under ros1, I can integrate cpp classes into my code. But under the micro-ros, it has not been tested by adding the cpp file.
Reliably reproducing the issue might not be that easy as it depends on how the memory is allocated and reallocated and the fragmentation happening in the reallocation steps.
I can reliably trigger the issue in my setup by creating a lifecycle node. Depending on the rest of the code, the issue will happen at different parts, but always when reallocating memory while initializing the state machine.
I read through the implementation of the memory management functions, and it appears to me that there is a bug in the reallocation function - pvPortRealloc. In particular, the aforementioned line should hold the count to the amount of allocated memory for the object, and not the total free block size. Therefore, it should be changed to
size_t count = (pxLink->xBlockSize & ~xBlockAllocatedBit) - xHeapStructSize;
I believe the state machine could be refactored to avoid all the reallocation, to begin with. We know the number of transitions and states beforehand, so we could already allocate all the necessary memory space for the maps. Naturally, this would be a PR to ros2/rcl
Hi
From the working group, I heard about adding the multithreading feature. My question is, what exactly is that you're planning to add? While working with FreeRTOS, I'd run each node on its own task, which runs as its own thread, and then use the built-in mechanism to communicate between them. What would be the case you had in mind?
I want to add to app.c to determine whether the agent is connected. Added #include <rmw_uros/options.h> in app.c, call rmw_uros_ping_agent in the program, but it will prompt undefined reference to'rmw_uros_ping_agent' when compiling. Where else might it not be dealt with?
Hello,
I am using microROS in FreeRTOS with Olimex-E407. My current installation was done the 15 October 2020.
I use serial communication with UART3 and I use UART6 as a debug console to retrieve printf messages.
To open a serial console I use this command :
Everything works fine and printf messages are being displayed.
However yesterday 23 November 2020 I installed a new microROS workspace and I tried the ping_pong demo. The demo works fine but nothing is sent to UART6 anymore.
To be sure there was nothing wrong with my installation I ran the same ping_pong demo but from my previous microROS workspace : I can see printf messages being displayed to the serial console.
So I guess there is something that went wrong between the 15th October and now.
Or is there something I am missing in order to activate the printf to serial ?
Regards,
Cocodmdr
Hi folks! I would appreciate some info regarding the current state of P2P communication between MCUs running micro-ROS nodes, and whether my (theoretical) setup would be achievable:
The rp2040 boards would be running distinct neural networks and publishing the inference results as per my micro-ROS + Edge Impulse project.
The reason I'm skeptical this is possible is because as far as I understand my options are to either:
Thanks in advance for any guidance :)
Avi
ros2 run micro_ros_setup configure_firmware.sh add_two_ints_service --transport udp --ip <our agent ip> --port 8888
ros2 service call /addtwoints example_interfaces/srv/AddTwoInts "{a: 5, b: 10}"
Should get a response (sum=15)
waiting for service to become available... requester: making request: example_interfaces.srv.AddTwoInts_Request(a=5, b=10)
We basically have the same issue as this but with FreeRTOS on our STM32 board.
We using a router from Teltonika- RUT240 (which a decent router), and the computer running the agent and making service calls is connected though Ethernet.
Quick note: I had to include #include <rclc/executor.h>
in the example code, and change "printk"s to printf to get it to compile.
Not very well-versed with uROS or DDS stuff, but we tried the following:
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
before starting the agent, as suggested in this thread.Logs from the agent:
$ ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v6
[1646402745.031716] info | UDPv4AgentLinux.cpp | init | running... | port: 8888
[1646402745.032007] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
[1646402745.756195] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x00000000, len: 24, data:
0000: 80 00 00 00 00 01 10 00 58 52 43 45 01 00 01 0F 09 6C 59 A4 81 00 FC 03
[1646402745.756401] info | Root.cpp | create_client | create | client_key: 0x096C59A4, session_id: 0x81
[1646402745.756505] info | SessionManager.hpp | establish_session | session established | client_key: 0x096C59A4, address: 192.168.10.18:12020
[1646402745.756658] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 19, data:
0000: 81 00 00 00 04 01 0B 00 00 00 58 52 43 45 01 00 01 0F 00
[1646402745.757560] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 56, data:
0000: 81 80 00 00 01 07 2E 00 00 0A 00 01 01 03 00 00 20 00 00 00 00 01 00 20 18 00 00 00 61 64 64 5F
0020: 74 77 6F 69 6E 74 73 5F 73 65 72 76 65 72 5F 72 63 6C 63 00 00 00 00 00
[1646402745.771891] info | ProxyClient.cpp | create_participant | participant created | client_key: 0x096C59A4, participant_id: 0x000(1)
[1646402745.771982] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 14, data:
0000: 81 80 00 00 05 01 06 00 00 0A 00 01 00 00
[1646402745.771996] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 01 00 00 00 80
[1646402745.772787] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 01 00 00 00 80
[1646402745.773173] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 208, data:
0000: 81 80 01 00 01 07 C5 00 00 0B 00 08 08 03 00 00 B7 00 00 00 0C 00 00 00 2F 61 64 64 74 77 6F 69
0020: 6E 74 73 00 33 00 00 00 65 78 61 6D 70 6C 65 5F 69 6E 74 65 72 66 61 63 65 73 3A 3A 73 72 76 3A
0040: 3A 64 64 73 5F 3A 3A 41 64 64 54 77 6F 49 6E 74 73 5F 52 65 71 75 65 73 74 5F 00 08 34 00 00 00
0060: 65 78 61 6D 70 6C 65 5F 69 6E 74 65 72 66 61 63 65 73 3A 3A 73 72 76 3A 3A 64 64 73 5F 3A 3A 41
0080: 64 64 54 77 6F 49 6E 74 73 5F 52 65 73 70 6F 6E 73 65 5F 00 01 23 03 08 15 00 00 00 72 71 2F 61
00A0: 64 64 74 77 6F 69 6E 74 73 52 65 71 75 65 73 74 00 01 00 00 13 00 00 00 72 72 2F 61 64 64 74 77
00C0: 6F 69 6E 74 73 52 65 70 6C 79 00 00 01 00 00 00
[1646402745.773799] info | ProxyClient.cpp | create_replier | replier created | client_key: 0x096C59A4, requester_id: 0x000(7), participant_id: 0x000(1)
[1646402745.773880] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 14, data:
0000: 81 80 01 00 05 01 06 00 00 0B 00 08 00 00
[1646402745.773894] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 02 00 00 00 80
[1646402745.774660] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 02 00 00 00 80
[1646402745.774678] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 24, data:
0000: 81 80 02 00 08 01 10 00 00 0C 00 08 80 00 00 01 FF FF 00 00 00 00 00 00
[1646402745.774818] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 03 00 00 00 80
[1646402768.908714] debug | Replier.cpp | read_fn | [==>> DDS <<==] | client_key: 0x00000000, len: 56, data:
0000: 69 F5 10 01 90 E8 E4 52 F3 48 EC 0C 00 00 14 03 00 00 00 00 01 00 00 00 AB CE 57 FA 4A 37 B3 F7
0020: 01 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00
[1646402768.908912] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 68, data:
0000: 81 80 02 00 09 01 3C 00 00 0C 00 08 69 F5 10 01 90 E8 E4 52 F3 48 EC 0C 00 00 14 03 00 00 00 00
0020: 01 00 00 00 AB CE 57 FA 4A 37 B3 F7 01 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 0A 00 00 00
0040: 00 00 00 00
[1646402768.973465] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 03 00 00 00 80
[1646402768.977226] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x096C59A4, len: 44, data:
0000: 81 80 03 00 07 01 24 00 00 0D 00 08 69 F5 10 01 90 E8 E4 52 F3 48 EC 0C 00 00 14 03 00 00 00 00
0020: 01 00 00 00 AC CE 57 FA 4A 37 B3 F7
[1646402768.977451] debug | Replier.cpp | write | [** <<DDS>> **] | client_key: 0x00000000, len: 32, data:
0000: 69 F5 10 01 90 E8 E4 52 F3 48 EC 0C 00 00 14 03 00 00 00 00 01 00 00 00 AC CE 57 FA 4A 37 B3 F7
[1646402768.977570] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x096C59A4, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 04 00 00 00 80
Hello @donRaphaco, I'm removing the libatomic from the extensions repositories and adding it to rcutils
package, check this: https://github.com/micro-ROS/micro_ros_setup/pull/171/checks?check_run_id=953530520
But in the case of the ESP32 I'm not able to remove the folder components/libatomics
and these two lines without having building errors.
Is possible for you to remove this libatomic dependency for the ESP32 board support? I'm working in this PR: #18 You can commit there if you wish.
Thanks!
Hi , i want to know if have method to get parameters like as declare_parameter() and get_parameter_or<>() under micro-ROS ?
https://github.com/ZhenshengLee/ros2_mcu/tree/master/libs/custom_stm32f767zi
compile and flash with udp configuration.
colcon.meta is https://github.com/ZhenshengLee/ros2_mcu/blob/master/mcu_ws/colcon.meta
app-colcol.meta is https://github.com/ZhenshengLee/ros2_mcu/blob/master/apps/int32_publisher/app-colcon.meta
ping stm32 device success, udp connectiong success, with agent output info. as long as possible.
ping failer, and udp connection hangs, agent output hangs. After a period of time, around 500s
This issue may be related with micro-ROS/micro_ros_setup#295 micro-ROS/micro_ros_setup#469 #40
the STM32 auto-generated code is by using STM32CubeMX 6.4.0 and Firmware v1.16.0
I would like to use micro-ROS to read a value of resistance.
On the STM32CubeIDE, program can run smoothly but micro-ROS can not.
Get an output as resistance value measured via micro-ROS.
~/firmware/freertos_apps/microros_nucleo_f746zg_extensions/build/main.o: in function `MX_ADC1_Init':
~/firmware/freertos_apps/microros_nucleo_f746zg_extensions/Src/main.c:286: undefined reference to `HAL_ADC_Init'
~/firmware/toolchain/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: ~/firmware/freertos_apps/microros_nucleo_f746zg_extensions/Src/main.c:294: undefined reference to `HAL_ADC_ConfigChannel'
~/firmware/toolchain/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: ~/firmware/freertos_apps/microros_nucleo_f746zg_extensions/build/app.o: in function `appMain':
~/firmware/freertos_apps/apps/int32_publisher/app.c:92: undefined reference to `HAL_ADC_Start'
~/firmware/toolchain/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: ~/firmware/freertos_apps/apps/int32_publisher/app.c:93: undefined reference to `HAL_ADC_PollForConversion'
~/firmware/toolchain/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: ~/firmware/freertos_apps/apps/int32_publisher/app.c:94: undefined reference to `HAL_ADC_GetValue'
collect2: error: ld returned 1 exit status
make: *** [Makefile:383: ~/firmware/freertos_apps/microros_nucleo_f746zg_extensions/build/micro-ROS.elf] Error 1
The program can not successfully build due to undefined reference. Also hal_adc file is included and located at the same containing file as others hal files. I did not change any directories stucture in micro-ROS's workspace.
Thanks.
Hi are there a set of steps we can follow to build a new board to run with freertos and uros?
For your reference I am using the nucleo_f746zg. I tried to imitate the f4 example you all already have in the example but I got stuck at the extensions and how to continue after that point.
Thank you
Look forward to your response.
I want to get the communication frequency over 200Hz, Thus I make the timer count number to be 5 (5ms per time).
But it has not worked well as expected. How can I solve this problem?
`/* USER CODE BEGIN 4 */
bool cubemx_transport_open(struct uxrCustomTransport * transport);
bool cubemx_transport_close(struct uxrCustomTransport * transport);
size_t cubemx_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err);
size_t cubemx_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err);
void * microros_allocate(size_t size, void * state);
void microros_deallocate(void * pointer, void * state);
void * microros_reallocate(void * pointer, size_t size, void * state);
void * microros_zero_allocate(size_t number_of_elements, size_t size_of_element, void * state);
rcl_publisher_t sensor_data_publisher;
std_msgs__msg__Int64MultiArray sensors_array_msg;
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
rcl_publish(&sensor_data_publisher, &sensors_array_msg, NULL);
sensors_array_msg.data.data[0] = 0;
sensors_array_msg.data.data[0] = sensors_array_msg.data.data[0] + 1;
sensors_array_msg.data.data[1] = sensors_array_msg.data.data[1] + 2;
sensors_array_msg.data.data[2] = sensors_array_msg.data.data[2] + 3;
sensors_array_msg.data.data[3] = sensors_array_msg.data.data[3] + 4;
}
}
/* USER CODE END 4 */
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
// micro-ROS configuration
rmw_uros_set_custom_transport(
true,
(void *) &huart1,
cubemx_transport_open,
cubemx_transport_close,
cubemx_transport_write,
cubemx_transport_read);
rcl_allocator_t freeRTOS_allocator = rcutils_get_zero_initialized_allocator();
freeRTOS_allocator.allocate = microros_allocate;
freeRTOS_allocator.deallocate = microros_deallocate;
freeRTOS_allocator.reallocate = microros_reallocate;
freeRTOS_allocator.zero_allocate = microros_zero_allocate;
if (!rcutils_set_default_allocator(&freeRTOS_allocator)) {
printf("Error on default allocators (line %d)\n", __LINE__);
}
// micro-ROS app
rcl_publisher_t publisher;
std_msgs__msg__Int32 msg;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;
allocator = rcl_get_default_allocator();
//create init_options
rclc_support_init(&support, 0, NULL, &allocator);
// create node
rclc_node_init_default(&node, "cubemx_node", "", &support);
// create publisher
rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"cubemx_publisher");
// Int64MultiArray Part:
// Create Publisher
// rcl_publisher_t sensor_data_publisher;
rclc_publisher_init_default(
&sensor_data_publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int64MultiArray),
"capacitance_sensor_data"
);
// Create Timer
rcl_timer_t timer;
const unsigned int timer_timeout = 1;
rclc_timer_init_default(
&timer,
&support,
RCL_MS_TO_NS(timer_timeout),
timer_callback
);
// Create Executor
rclc_executor_t executor;
rclc_executor_init(&executor, &support.context, 1, &allocator);
rclc_executor_add_timer(&executor, &timer);
// Int64MultiArray Part:
// Init Message
// std_msgs__msg__Int64MultiArray sensors_array_msg;
// Assing Memory to Message
int64_t buffer[BUFFER_SIZE] = {};
sensors_array_msg.data.data = buffer;
sensors_array_msg.data.size = 0;
sensors_array_msg.data.capacity = BUFFER_SIZE;
std_msgs__msg__MultiArrayDimension dim[BUFFER_SIZE] = {};
sensors_array_msg.layout.dim.data = dim;
sensors_array_msg.layout.dim.size = 0;
sensors_array_msg.layout.dim.capacity = BUFFER_SIZE;
char labels[BUFFER_SIZE][STRING_SIZE] = {};
for(size_t i = 0; i < BUFFER_SIZE; i++){
sensors_array_msg.layout.dim.data[i].label.data = labels[i];
sensors_array_msg.layout.dim.data[i].label.size = 0;
sensors_array_msg.layout.dim.data[i].label.capacity = STRING_SIZE;
}
// Fill the messgae with dummy data;
for(size_t i = 0; i<BUFFER_SIZE; i++){
sensors_array_msg.data.data[i] = i;
sensors_array_msg.data.size++;
}
sensors_array_msg.layout.data_offset = 42;
for(size_t i = 0; i<BUFFER_SIZE; i++){
sensors_array_msg.layout.dim.data[i].label.size = strlen(sensors_array_msg.layout.dim.data[i].label.data);
sensors_array_msg.layout.dim.data[i].size = 42;
sensors_array_msg.layout.dim.data[i].stride = 42;
}
uint8_t meas1 = 0x01;
uint32_t sensor_meas = 0;
FDC1004_readmeas(&hi2c1, &meas1, &sensor_meas);
msg.data = sensor_meas;
while(1)
{
// rcl_ret_t ret = rcl_publish(&publisher, &msg, NULL);
// if (ret != RCL_RET_OK)
// {
// printf("Error publishing (line %d)\n", __LINE__);
// }
//
// FDC1004_readmeas(&hi2c1, &meas1, &sensor_meas);
// msg.data = sensor_meas;
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(0));
// osDelay(10);
}
/* USER CODE END 5 */
}
Board: Nucleo 446ZE
RTOS: FreeRTOS
App: Ping Pong
Flash Utility: ST-Flash
Debug Utility: OpenOCD
Freertos_apps fork branch
Micro_ros_setup config branch
A call to allocator->deallocate in node.c line 412, during ping_pong app node initialization results in a HardFault.
allocator->deallocate(node_secure_root, allocator->state);
The following is a snapshot of the callstack & local variables at the above call
previous calls to allocator->deallocate
during node init are executed fine.
Any idea where/what to look for?
change main.c
, compile and flash.
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_DMA_Init();
MX_USB_OTG_FS_PCD_Init();
smoke test success.
transport of serial failed, with no output of agent
In auto-generated code by cubemx(6.4), MX_DMA_Init();
happens after MX_USART3_UART_Init();
Originally posted by @ZhenshengLee in ZhenshengLee/ros2_mcu#2 (comment)
Hello,
I am using last software (02 March 2021) with Olimex e407, freeRTOS and transport serial.
I modified the ping pong app in order to use nav_msgs msg Odometry instead of std_msgs msg Header.
Ping is published only once and then agent continously throw this error :
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTBT9XBM-if00-port0
[1614762536.858473] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1614762536.858646] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
[1614762505.989146] error | OutputMessage.cpp | log_error | serialization error | buffer:
0000: 81 01 00 00 09 01 EC 02 00 14 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Here is my app.c :
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <std_msgs/msg/header.h>
#include <nav_msgs/msg/odometry.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#define STRING_BUFFER_LEN 50
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc); vTaskDelete(NULL);}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
rcl_publisher_t ping_publisher;
rcl_publisher_t pong_publisher;
rcl_subscription_t ping_subscriber;
rcl_subscription_t pong_subscriber;
nav_msgs__msg__Odometry incoming_ping;
nav_msgs__msg__Odometry outcoming_ping;
nav_msgs__msg__Odometry incoming_pong;
int device_id;
int seq_no;
int pong_count;
void ping_timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
seq_no = rand();
sprintf(outcoming_ping.header.frame_id.data, "%d_%d", seq_no, device_id);
outcoming_ping.header.frame_id.size = strlen(outcoming_ping.header.frame_id.data);
// Fill the message timestamp
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
outcoming_ping.header.stamp.sec = ts.tv_sec;
outcoming_ping.header.stamp.nanosec = ts.tv_nsec;
sprintf(outcoming_ping.child_frame_id.data, "%d_%d", seq_no, device_id);
outcoming_ping.child_frame_id.size = strlen(outcoming_ping.child_frame_id.data);
outcoming_ping.pose.pose.orientation.x = 0.0;
outcoming_ping.pose.pose.orientation.y = 0.0;
outcoming_ping.pose.pose.orientation.z = 0.0;
outcoming_ping.pose.pose.orientation.w = 1.0;
// Reset the pong count and publish the ping message
pong_count = 0;
rcl_publish(&ping_publisher, (const void*)&outcoming_ping, NULL);
printf("Ping send seq %s\n", outcoming_ping.header.frame_id.data);
}
}
void ping_subscription_callback(const void * msgin)
{
const nav_msgs__msg__Odometry * msg = (const nav_msgs__msg__Odometry *)msgin;
// Dont pong my own pings
if(strcmp(outcoming_ping.header.frame_id.data, msg->header.frame_id.data) != 0){
printf("Ping received with seq %s. Answering.\n", msg->header.frame_id.data);
rcl_publish(&pong_publisher, (const void*)msg, NULL);
}
}
void pong_subscription_callback(const void * msgin)
{
const nav_msgs__msg__Odometry * msg = (const nav_msgs__msg__Odometry *)msgin;
if(strcmp(outcoming_ping.header.frame_id.data, msg->header.frame_id.data) == 0) {
pong_count++;
printf("Pong for seq %s (%d)\n", msg->header.frame_id.data, pong_count);
}
}
void appMain(void *argument)
{
rcl_allocator_t allocator = rcl_get_default_allocator();
rclc_support_t support;
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "pingpong_node", "", &support));
// Create a reliable ping publisher
RCCHECK(rclc_publisher_init_default(&ping_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry), "/microROS/ping"));
// Create a best effort pong publisher
RCCHECK(rclc_publisher_init_best_effort(&pong_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry), "/microROS/pong"));
// Create a best effort ping subscriber
RCCHECK(rclc_subscription_init_best_effort(&ping_subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry), "/microROS/ping"));
// Create a best effort pong subscriber
RCCHECK(rclc_subscription_init_best_effort(&pong_subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry), "/microROS/pong"));
// Create a 1 seconds ping timer timer,
rcl_timer_t timer;
RCCHECK(rclc_timer_init_default(&timer, &support, RCL_MS_TO_NS(1000), ping_timer_callback));
// Create executor
rclc_executor_t executor;
RCCHECK(rclc_executor_init(&executor, &support.context, 3, &allocator));
RCCHECK(rclc_executor_add_timer(&executor, &timer));
RCCHECK(rclc_executor_add_subscription(&executor, &ping_subscriber, &incoming_ping, &ping_subscription_callback, ON_NEW_DATA));
RCCHECK(rclc_executor_add_subscription(&executor, &pong_subscriber, &incoming_pong, &pong_subscription_callback, ON_NEW_DATA));
// Create and allocate the pingpong messages
char outcoming_ping_buffer[STRING_BUFFER_LEN];
outcoming_ping.header.frame_id.data = outcoming_ping_buffer;
outcoming_ping.header.frame_id.capacity = STRING_BUFFER_LEN;
outcoming_ping.child_frame_id.data = outcoming_ping_buffer;
outcoming_ping.child_frame_id.capacity = STRING_BUFFER_LEN;
char incoming_ping_buffer[STRING_BUFFER_LEN];
incoming_ping.header.frame_id.data = incoming_ping_buffer;
incoming_ping.header.frame_id.capacity = STRING_BUFFER_LEN;
incoming_ping.child_frame_id.data = incoming_ping_buffer;
incoming_ping.child_frame_id.capacity = STRING_BUFFER_LEN;
char incoming_pong_buffer[STRING_BUFFER_LEN];
incoming_pong.header.frame_id.data = incoming_pong_buffer;
incoming_pong.header.frame_id.capacity = STRING_BUFFER_LEN;
incoming_pong.child_frame_id.data = incoming_pong_buffer;
incoming_pong.child_frame_id.capacity = STRING_BUFFER_LEN;
device_id = rand();
while(1){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(10));
usleep(10000);
}
// Free resources
RCCHECK(rcl_publisher_fini(&ping_publisher, &node));
RCCHECK(rcl_publisher_fini(&pong_publisher, &node));
RCCHECK(rcl_subscription_fini(&ping_subscriber, &node));
RCCHECK(rcl_subscription_fini(&pong_subscriber, &node));
RCCHECK(rcl_node_fini(&node));
}
Thank you !
I have a stm32f407 board with the same chip as olimex_e407, I want to transplant the source code of olimex_e407 to my new version. I follow the tutorial https://micro-ros.github.io/docs/tutorials/core/first_application_rtos/freertos/ to complete the related installation and burning. My problem is that I cannot see the topic /microROS/ping in the new terminal.
My system is ubuntu 20.04 and ros2 version is foxy
I start the agent as follows:
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0 -v6
[1605573834.109076] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1605573834.109228] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
After I restart the device, I can see the serial port transceiver and dds reading and writing:
[1605573865.009277] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0B 01 05 00 0B 00 0B 00 80
[1605573865.009292] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0B 01 05 00 0B 00 0B 00 80
[1605573865.009370] debug | DataWriter.cpp | write | [** <<DDS>> **] | client_key: 0x00000000, len: 34, data:
0000: 04 00 00 00 00 6E 0A 1E 16 00 00 00 31 31 39 31 33 39 31 35 32 39 5F 31 30 38 35 33 37 37 37 34
0020: 33 00
[1605573865.009428] debug | DataReader.cpp | read_fn | [==>> DDS <<==] | client_key: 0x00000000, len: 34, data:
0000: 04 00 00 00 00 6E 0A 1E 16 00 00 00 31 31 39 31 33 39 31 35 32 39 5F 31 30 38 35 33 37 37 37 34
0020: 33 00
[1605573865.009447] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 0C 00 00 00 80
[1605573865.009516] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 0C 00 00 00 80
[1605573865.009531] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 0C 00 00 00 80
[1605573865.009555] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 46, data:
0000: 81 01 01 00 09 01 26 00 00 14 00 06 04 00 00 00 00 6E 0A 1E 16 00 00 00 31 31 39 31 33 39 31 35
0020: 32 39 5F 31 30 38 35 33 37 37 37 34 33 00
[1605573865.010425] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0B 01 05 00 0B 00 0B 00 80
[1605573865.010551] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
0000: 81 00 00 00 0A 01 05 00 0C 00 00 00 80
But I only see
$ ros2 topic list
/parameter_events
/rosout
I can't see it normally, the topic is like this
/microROS/ping
/microROS/pong
I have no clue what the problem is. . Do you have any suggestions?
At present, such errors often appear in the operation, leading to suspension. I want to know how to debug the problem?
show error in agent console :
[micro_ros_agent-1] [1614827269.838182] debug | ProxyClient.cpp | delete_object_unlock | object deleted | client_key: 0x5851F42D, object_id: 0x0001
[micro_ros_agent-1] [1614827269.838516] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 14, data:
[micro_ros_agent-1] 0000: 81 80 1D 00 05 01 06 00 01 D9 00 16 00 00
[micro_ros_agent-1] [1614827269.838615] debug | ProxyClient.cpp | delete_object_unlock | object deleted | client_key: 0x5851F42D, object_id: 0x0001
[micro_ros_agent-1] 0000: 81 00 00 00 0B 01 05 00 CA 01 CA 01 80
[micro_ros_agent-1] [1614827269.855471] debug | ProxyClient.cpp | delete_object_unlock | object deleted | client_key: 0x5851F42D, object_id: 0x0000
[micro_ros_agent-1] [1614827269.855631] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 14, data:
[micro_ros_agent-1] 0000: 81 80 1F 00 05 01 06 00 01 DB 00 01 00 00
[micro_ros_agent-1] [1614827269.855671] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0A 01 05 00 CB 01 00 00 80
[micro_ros_agent-1] [1614827269.855689] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0A 01 05 00 CB 01 00 00 80
[micro_ros_agent-1] [1614827269.855700] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0A 01 05 00 CB 01 00 00 80
[micro_ros_agent-1] [1614827269.857359] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0B 01 05 00 CA 01 CA 01 80
[micro_ros_agent-1] [1614827269.857575] debug | SerialAgentLinux.cpp | send_message | [** <<SER>> **] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0A 01 05 00 CB 01 00 00 80
[micro_ros_agent-1] [1614827269.860171] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 13, data:
[micro_ros_agent-1] 0000: 81 00 00 00 0A 01 05 00 20 00 00 00 80
[micro_ros_agent-1] [1614827269.862215] debug | SerialAgentLinux.cpp | recv_message | [==>> SER <<==] | client_key: 0x5851F42D, len: 12, data:
[micro_ros_agent-1] 0000: 81 00 00 00 03 01 04 00 00 02 FF FE
[micro_ros_agent-1] [1614827269.862371] info | Root.cpp | delete_client | delete | client_key: 0x5851F42D
[micro_ros_agent-1] [1614827269.862422] info | SessionManager.hpp | destroy_session | session closed | client_key: 0x5851F42D, address: 1
show Error in app.c on usart:
[11:06:33:111] **********************************␊
[11:06:34:449] initTask ⇥ X⇥ 8⇥ 1310⇥ 1␍␊
[11:06:37:121] IDLE ⇥ R⇥ 0⇥ 104⇥ 2␍␊
[11:06:37:132] microROS_app ⇥ B⇥ 55⇥ 3664⇥ 4␍␊
[11:06:37:132] Tmr Svc ⇥ B⇥ 2⇥ 215⇥ 3␍␊
[11:06:37:132] **********************************␊
[11:06:37:369] [INFO] [ld.ld] []: Created a timer with period 500 ms.␊
[11:06:37:379] ␊
[11:06:37:445] [INFO] [ld.ld] []: Created a timer with period 500 ms.␊
[11:06:37:451] ␊
[11:06:37:518] [INFO] [ld.ld] []: Created a timer with period 500 ms.␊
[11:06:37:523] ␊
[11:07:49:870] Failed status on line 226: 1. in /home/ubuntu/microros_ws/firmware/freertos_apps/apps/ailibot2/app.c Aborting.␊
error in app.c 226 line:
//executor
RCCHECK(rclc_executor_fini(&executor));
//support
RCCHECK(rclc_support_fini(&support));
//node
RCCHECK(rcl_node_fini(&node)); # line 266 error here
I build the ping_pong app allways have the CMake Warning :
Package 'rcutils' exports library 'dl' which couldn't be found
I can compile normally, get the bin file, or burn it to the board,
and the LED light flashes normally.
The detail infomation as below:
Starting >>> rosidl_typesupport_microxrcedds_c
--- stderr: rosidl_typesupport_microxrcedds_c
CMake Warning at /home/ubuntu/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
/home/ubuntu/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
/home/ubuntu/microros_ws/firmware/mcu_ws/install/rosidl_runtime_c/share/rosidl_runtime_c/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
/home/ubuntu/microros_ws/firmware/mcu_ws/install/rosidl_runtime_c/share/rosidl_runtime_c/cmake/rosidl_runtime_cConfig.cmake:41 (include)
CMakeLists.txt:22 (find_package)
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0 -b 115200 -v 6
[1605340011.161238] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1605340011.161433] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
[1605340015.254941] info | Root.cpp | create_client | create | client_key: 0x5851F42D, session_id: 0x81
[1605340015.255052] info | SessionManager.hpp | establish_session | session established | client_key: 0x1481765933, address: 1
But cannot display ros2 topic information /microROS/pong
$ ros2 topic list
/parameter_events
/rosout
I encountered this trouble in the very first tutorial, where the ping_pong app is used as demo. But it didn't worked. Then i tried other apps (such as int32_publisher, which works well) and build my own apps. Trying to make simplified version of ping_pong app (with one subscriber and publisher and two topics), i encountered the issue mentioned in title again.
Using HAL_TogglePin() to light LEDs for debug in my own test app, i discovered, that subscription callback hadn't called the second time. Such case: running ping_pong app on the MCU, i receive only the first ping and then the silence.
Adding timer, which toggles the LED, in test app i discovered, that the timer 'freezes' after subscription callback executed.
Screenshot shows, that there's respond to first message from node, but no respond to next messages (run micro_ros_agent with verbose level 5).
To be able to flash my MCU, i made some changes in 'flash.sh' script for nucleo_f767zi. I added the stlink-v2-1 as programmer (these lines you can also see in flash-script for nucleo_f446ze):
elif lsusb -d 0483:374b;then
PROGRAMMER=interface/stlink-v2-1.cfg
the configure I used :
ros2 run micro_ros_setup configure_firmware.sh ping_pong -t udp -i 192.168.0.181 -p 8888
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v 6
and change the IP addresses in lwip.c:
void MX_LWIP_Init(void)
{
/* Initilialize the LwIP stack with RTOS */
tcpip_init( NULL, NULL );
osThreadAttr_t attributes;
ipaddr.addr = 0xC0A800B5;
netmask.addr = 0xFFFFFF00;
gw.addr = 0xC0A80001;
......
it builds and works
[1610689478.070872] info | UDPv4AgentLinux.cpp | init | running... | port: 8888 [1610689478.071353] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
but win i ping 192.168.0.181,it shows:
From 192.168.0.180 icmp_seq=166 Destination Host Unreachable
and win i use:ros2 topic echo /microROS/ping
WARNING: topic [/microROS/ping] does not appear to be published yet Could not determine the type for the passed topic
Ethernet Initialization␍␊
Waiting for IP␍␊
IP: 181.0.168.192␍␊
UDP mode => ip: 192.168.0.181 - port: 8888␊
**********************************␊
Task State Prio Stack Num␊
**********************************␊
initTask ⇥ X⇥ 23⇥ 118⇥ 3␍␊
IDLE ⇥ R⇥ 0⇥ 104⇥ 4␍␊
tcpip_thread ⇥ B⇥ 24⇥ 149⇥ 1␍␊
microROS_app ⇥ B⇥ 25⇥ 1660⇥ 6␍␊
Tmr Svc ⇥ B⇥ 2⇥ 214⇥ 5␍␊
EthIf ⇥ B⇥ 48⇥ 2⇥ 2␍␊
**********************************␊
[ERROR] [ld.ld] [rclc]: [rclc_init] Error in rcl_init: error not set␊
Failed status on line 87: 1. Aborting.␊
does olimexe407 support this configure?
or can you give me codes that works?
so sorry i closed the issue by accident
thank you
Hi Pablo, et al..
Follow Tutorial at https://micro-ros.github.io/docs/tutorials/core/first_application_rtos/freertos/
with the following delta
ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport udp --ip 10.0.0.158 --port 8888
Build completes with no error.
Build fails , the first error is the following
In file included from
/home/ubu/microros_ws_test/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/include/rmw_uros/options.h:21,
from /home/ubu/microros_ws_test/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/./types.h:36,
from /home/ubu/microros_ws_test/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/utils.h:20,
from /home/ubu/microros_ws_test/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/rmw_client.c:15:
/home/ubu/microros_ws_test/firmware/mcu_ws/install/microxrcedds_client/include/uxr/client/profile/transport/custom/custom_transport.h:37:20: error: 'UCLIENT_CUSTOM_TRANSPORT_MTU' undeclared here (not in a function); did you mean 'UXR_CLIENT_CUSTOM_TRANSPORT_H_'?
uint8_t buffer[UCLIENT_CUSTOM_TRANSPORT_MTU];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
UXR_CLIENT_CUSTOM_TRANSPORT_H_
Thank you
Hello,
I am using microROS since two months now and I noticed some strange behaviour.
I am running the ping_pong example with freeRTOS on olimex board.
I am using UDP transport connection.
Everything runs fines in the beginning, however after some time it fails : no more ping are sent and the onboard LED does not blink anymore.
Using ros2 topic echo /microROS/ping I could see that it fails at arbitrary times.
I ran the test 12 times, here are the times in seconds at witch it failled : 111s, 209s, 148s, 248s, 295s, 141s, 243s, 203s, 73s, 97s, 311s, 95s
I tried also this demo in a private network with fixed IP addresses ( I changed the lwip.h file to fix the IP instead of using DHCP) but I get the same problem.
I took the int32_publisher example and restructured it into app.c, config.c and config.h. When I build the firmware it won't recognize the function in config.c I use in app.c. I put the function in config.h and all that stuff, so it's probably that it isn't compiling config.c, it just says 'undefined reference to...', here's the full terminal: https://justpaste.it/6nku1.
With CMakeLists.txt you can just add dependencies and there are examples on how to do it. But with colcon.meta I can't find any examples on how to do it, and I'm not even sure that's where you're supposed to add dependencies. Can someone show or link me how to do it, I couldn't find it by searching.
Sorry if it's a newbie question, but I really can't find how to do it.
Hi,
I have a STM32F407VETX based board and trying to find the right procedure to get a STM32CubeIDE project with micro-ROS. Not fully clear how to get the firmware and toolchain for this specific board ino the scripts. Any suggestions are really welcome!
I`ve configured my esp32 with the app int32_publisher in udp mode and got an error while tyring to create a ros node.
the error is this:
UDP mode => ip: 172.17.0.1 - port: 8888 // my docker ip
[ERROR] [0000000028.107394000] [rclc]: [rclc_init] error in rcl_init: failed to create node session on Micro ROS Agent., at /microros_ws/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/rmw_init.c:306, at /microros_ws/firmware/mcu_ws/uros/rcl/rcl/src/rcl/init.c:229
Failed status on line 37: 1. Aborting.
the line in the code:
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
Does anyone know what the problem is?
On the application examples, I see, the stack assigned is 1500 x 4 (which is a lot). Is there a minimum suggested by you?
I've managed to make a node work with 4098 with a simple subscriber. But if I need to be able to allocate at least 4098 for each Node I want to run, it'll be kind of hard.
I guess it'll depend on the type of messages. Assume there won't be any string, no doubles, maybe floats, and no arrays of variable size. Furthermore, for the QoS, I guess I'll decrease the history to 1 and probably transient local. Anything else I should keep in mind? Is there a limit on the number of nodes I can have?
Most of the threads I have work with up to 128, while I need to increase the stack size up to at least 512 to have printf (for debug purposes).
I do know the stack size depends on the call depth, the number of arguments to methods, optimization level, etc, etc.
Thanks in advance.
first step : Custom message type
here is my msg:
float32 linear_x float32 linear_y float32 angular_z
second step:
here is my app.c:
#include <stdio.h>
#include <unistd.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
//#include <std_msgs/msg/int32.h>
#include <my_custom_message/msg/velocities.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#endif
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);vTaskDelete(NULL);}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
rcl_publisher_t publisher;
//std_msgs__msg__Int32 msg;
my_custom_message__msg__Velocities msg;
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
//msg.linear_x++;
//msg.linear_y++;
//msg.angular_z++;
}
}
void appMain(void * arg)
{
rcl_allocator_t allocator = rcl_get_default_allocator();
rclc_support_t support;
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
rcl_node_t node;
RCCHECK(rclc_node_init_default(&node, "freertos_velocities_publisher", "", &support));
// create publisher
RCCHECK(rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(my_custom_message, msg, Velocities),
"freertos_Velocities_publisher"));
// create timer,
rcl_timer_t timer;
const unsigned int timer_timeout = 1000;
RCCHECK(rclc_timer_init_default(
&timer,
&support,
RCL_MS_TO_NS(timer_timeout),
timer_callback));
// create executor
rclc_executor_t executor;
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_timer(&executor, &timer));
msg.linear_x = 1.0;
msg.linear_y =1.0 ;
msg.angular_z = 1.0;
while(1){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
usleep(100000);
}
// free resources
RCCHECK(rcl_publisher_fini(&publisher, &node))
RCCHECK(rcl_node_fini(&node))
vTaskDelete(NULL);
}
step 3:
ros2 topic echo /freertos_Velocities_publisher
Traceback (most recent call last):
File "/opt/ros/foxy/bin/ros2", line 11, in <module>
load_entry_point('ros2cli==0.9.9', 'console_scripts', 'ros2')()
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
rc = extension.main(parser=parser, args=args)
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/command/topic.py", line 41, in main
return extension.main(args=args)
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/echo.py", line 81, in main
return main(args)
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/echo.py", line 95, in main
message_type = get_msg_class(node, args.topic_name, include_hidden_topics=True)
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/api/__init__.py", line 88, in get_msg_class
msg_class = _get_msg_class(node, topic, include_hidden_topics)
File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/api/__init__.py", line 133, in _get_msg_class
return get_message(message_type)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_runtime_py/utilities.py", line 28, in get_message
interface = import_message_from_namespaced_type(get_message_namespaced_type(identifier))
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_runtime_py/import_message.py", line 30, in import_message_from_namespaced_type
module = importlib.import_module(
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'my_custom_message'
I don't know what the problem is?
Hi,
Problem 1:
I estabulished a micro-ROS APP with:
-1 node
-16 publishers( sum,no more than 300byte), all are best_effort
-1 subscriber( best_effort)
-2 executors: one for publishers, add a timer(rclc_timer_init_default(&timer, &support, RCL_MS_TO_NS(5), publisher_timer_callback)));one for subscriber
then I set:
while(1){
rclc_executor_spin_some(&executor_pub, RCL_MS_TO_NS(5));
usleep(5000);
rclc_executor_spin_some(&executor_srv, RCL_MS_TO_NS(5));
}
The publish frequency was no more than 60HZ (tested by "ros2 topic hz")
Then I changed my code:
while(1){
rclc_executor_spin_some(&executor_pub, RCL_MS_TO_NS(3));
usleep(4000);
rclc_executor_spin_some(&executor_srv, RCL_MS_TO_NS(1));
}
The publish frequency was no more than 120 HZ
The publish frequency is expected to be 200 HZ, how can I improve it?
Problem 2:
I estabulished a micro-ROS APP with:
-1 node
-16 publishers( sum no more than 400byte), all are best_effort
-2 services( best_effort)
-2 executors: one for publishers, add a timer(rclc_timer_init_default(&timer, &support, RCL_MS_TO_NS(5), publisher_timer_callback)));one for services
ServiceTest.srv:
{
int64 a
int64 b
---
int64 sum
}
MyServiceMessage.srv
{
string demand
---
string data
}
initialized services:
service_test__srv__ServiceTest_Request__init(&req);
service_test__srv__ServiceTest_Response__init(&res);
my_service_message__srv__MyServiceMessage_Request req;
my_service_message__srv__MyServiceMessage_Response res;
my_service_message__srv__MyServiceMessage_Request__init(&req);
my_service_message__srv__MyServiceMessage_Response__init(&res);
const unsigned int SERVICE_MSG_CAPACITY = 10;
req.demand.data = malloc(SERVICE_MSG_CAPACITY);
req.demand.capacity = SERVICE_MSG_CAPACITY;
snprintf(req.demand.data, req.demand.capacity, "zz1");
req.demand.size = strlen(req.demand.data);
res.data.data = malloc(SERVICE_MSG_CAPACITY);
res.data.capacity = SERVICE_MSG_CAPACITY;
snprintf(res.data.data, res.data.capacity, "zz2");
res.data.size = strlen(res.data.data);
then I set:
while(1){
rclc_executor_spin_some(&executor_pub, RCL_MS_TO_NS(3));
usleep(4000);
rclc_executor_spin_some(&executor_srv, RCL_MS_TO_NS(1));
}
I try to establish the communication between client and agent, but: the service returns 1,which means:
Generic error to indicate operation could not complete successfully.
This problem don't always exist, I changed nothing but test again, everything can be ok sometimes.
I modified this problem by increasing "-DRMW_UXRCE_MAX_HISTORY" :"-DRMW_UXRCE_MAX_HISTORY=3"
However, I have changed "-DUCLIENT_SERIAL_TRANSPORT_MTU=1024",
The internal middleware layer uses a buffer of 1024x3 = 3072 Bytes, it is much larger than the data I wanted to transmit. There must be something wrong.
This buff seems to be unrelated with the attributes.stack_size in freeRTOS task, how can it be optimized to save space? This problem may cause RAM not enough.
Problem 3:
Test service with "ros2 service call"
For ServiceTest, everything is ok.
But for MyServiceMessage,fist time :
I received this error:
terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException' what(): Not enough memory in the buffer stream Aborted (core dumped)
the second time "ros2 service call": this problem will not happen.
How can I slove this problem? it seems due to msg "string".
Problem4:
The publish frequency is no more 60 HZ which is expected to be 200 HZ
Problem5:
when I run a lot of programs in callback of service, if one node is enough to support 16 publisher and 2 services? I want to ask if micro-ros can support establish two or more tasks of freeRTOS in micro-ROS app main,or any other example to support "multi-threading".
Problem6:
When I test service with "ros2 service call":
ros2 service call -r 0.5 /service_test service_test/srv/ServiceTest "{a: 1, b: 2}"
I can get the response several times and then there is no any response. The client-agent communication is still running.
Problem7:
Sometimes, I test service with "ros2 service call",the client-agent communication will stop: invalid client key
The agent log:
By the way, is there any way to reduce the compile time? It cost a lot of time to compile after I modified any code.
HOST OS: Ubuntu 20.04.1 LTS
Board: Olimex E407
RTOS: FreeRTOS
I‘d like to use the tracetools
So I modify something in colcon.meta
(PATH firmware/mcu_ws/colcon.meta
):
"tracetools": {
"cmake-args": [
"-DTRACETOOLS_DISABLED=OFF", # the previous is ON
"-DTRACETOOLS_STATUS_CHECKING_TOOL=ON" # the previous is OFF
]
},
But I got errors when I run ros2 run micro_ros_setup build_firmware.sh
:
/home/aero/ros/freertos/firmware/mcu_ws/build/tracetools/include/tracetools/tp_call.h:29:10: fatal error: lttng/tracepoint.h: No such file or directory
#include <lttng/tracepoint.h>
^~~~~~~~~~~~~~~~~~~~
/home/aero/ros/freertos/firmware/mcu_ws/uros/tracetools/tracetools/src/utils.cpp:20:10: fatal error: dlfcn.h: No such file or directory
#include <dlfcn.h>
^~~~~~~~~
compilation terminated.
I can find both the two header files in my computer:
/usr/include/dlfcn.h
and /usr/include/x86_64-linux-gnu/lttng/tracepoint.h
Can someone help me ?
Could we also have a Custom App Feature similar to what was done for zephyr (micro-ROS/micro_ros_setup#183)
thank you!
the configure I used :
ros2 run micro_ros_setup configure_firmware.sh ping_pong -t udp -i 192.168.0.181 -p 8888
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v 6
and change the IP addresses in lwip.c:
void MX_LWIP_Init(void)
{
/* Initilialize the LwIP stack with RTOS */
tcpip_init( NULL, NULL );
osThreadAttr_t attributes;
ipaddr.addr = 0xC0A800B5;
netmask.addr = 0xFFFFFF00;
gw.addr = 0xC0A80001;
......
it builds and works
but win i ping 192.168.0.181,it shows:
From 192.168.0.180 icmp_seq=166 Destination Host Unreachable
and win i use:ros2 topic echo /microROS/ping
WARNING: topic [/microROS/ping] does not appear to be published yet Could not determine the type for the passed topic
Ethernet Initialization␍␊
Waiting for IP␍␊
IP: 181.0.168.192␍␊
UDP mode => ip: 192.168.0.181 - port: 8888␊
**********************************␊
Task State Prio Stack Num␊
**********************************␊
initTask ⇥ X⇥ 23⇥ 118⇥ 3␍␊
IDLE ⇥ R⇥ 0⇥ 104⇥ 4␍␊
tcpip_thread ⇥ B⇥ 24⇥ 149⇥ 1␍␊
microROS_app ⇥ B⇥ 25⇥ 1660⇥ 6␍␊
Tmr Svc ⇥ B⇥ 2⇥ 214⇥ 5␍␊
EthIf ⇥ B⇥ 48⇥ 2⇥ 2␍␊
**********************************␊
[ERROR] [ld.ld] [rclc]: [rclc_init] Error in rcl_init: error not set␊
Failed status on line 87: 1. Aborting.␊
does olimexe407 support this configure?
or can you give me codes that works?
thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.