# Program Real-Time ROS Nodes on STM32
## Description
An embedded system supporting multiple ROS nodes that are able to communicate with one another using inter-process communication and with other ROS-compatible devices over a network. This system consists of an STM32F4Discovery board, the FreeRTOS operating system, an embedded ROS middleware, and an embedded ROS client library. Application layer is the layer for ROS nodes and sensor libraries.
With this software, ROS developers do not have to know the complexities of the real-time operating system. ROS Client Library allows ROS developers to create Nodes, Publishers, Subscribers, and define ROS messages. This is why they can program their nodes as if they were writing code on a general-purpose computer.
The software includes two different scheduling schemes: priority and deadline. If deadline scheduling is enabled, application developers can assign deadlines to periodic tasks in order to make sure that they are completed before this deadline as long as the system is not overloaded.
WARNING & DISCLAIMER: Completely experimental software! License statements in each file/directory should be read carefully.
In addition to these licenses, the LICENSE in the root directory applies, unless this LICENSE contradicts the original license.
| Layers |
| ---------------------------------|
| application |
| ROS Client Library |
| ROS Middleware |
| XMLRPC+UDP |
| FreeRTOS |
| Hardware (STM32F4) |
## Software Concept
The software concept is shown in the below image. Blue blocks represent FreeRTOS tasks.
![](https://github.com/bosch-ros-pkg/stm32/blob/master/doc/ROS.png)
Node functions are specified in the header file (node table) nodes.h, where developers need to type in the entry point of each ROS node on embedded system manually. Data transfer between PC and embedded system is realized using <a href="http://wiki.ros.org/ROS/UDPROS">UDPROS</a> over Ethernet. There is a very simple XMLRPC handling, which does not use any XML parser, to make negotiations with ROS master on a PC. ROS messages are serialized on embedded software using C++ headers generated with <a href="http://wiki.ros.org/rosserial">rosserial</a>'s message generator based on Python.
## Example Node Function
Node functions are located in apps/nodes. In order to add a node to the system, the node needs to be registered in apps/nodes.h.
``` cpp
#ifndef ASW_APPS_APPLICATION_TASKS_H_
#define ASW_APPS_APPLICATION_TASKS_H_
#include "nodes/ultrasonic_sensor/ultrasonic_sensor.h"
#include "nodes/imu_sensor/imu_sensor.h"
#include "nodes/my_node/my_node.h"
typedef struct node_descriptor {
char name[32];
void (*function)(void* params);
int deadline; // if deadline scheduling is enabled
} node_decriptor;
node_decriptor nodes[] = {
{"ultrasonic_sensor", ultrasonic_sensor, 50},
{"imu_sensor", imu_sensor, 30},
{"my_node", my_node_function, NO_DEADLINE},
};
#endif /* ASW_APPS_APPLICATION_TASKS_H_ */
```
For each function registered in nodes.h (i.e. ultrasonic_sensor, imu_sensor, and my_node_function), a function has to be declared and defined, which has an argument of type void*. Here is an example code for ultrasonic_sensor node function.
``` cpp
#include "ultrasonic_sensor.h"
#include "rcl.h"
#include "Node.h"
#include "Publisher.h"
#include "Subscriber.h"
#include "sensor_msgs/Range.h"
#include "HCSR04Sensor/HCSR04.h"
// Period in milliseconds
#define PUBLISH_PERIOD 300
using namespace sensor_msgs;
ros::Publisher* ultrasonic_pub;
void ultrasonicLoop()
{
Range msg;
msg.radiation_type = Range::ULTRASOUND;
msg.min_range = 0.03f;
msg.max_range = 2.0f;
// Get distance value acquired by ultrasonic sensor in meters.
float distance_m = HCSR04::pingMedian(5)/100.0f;
if (distance_m > -1)
{
msg.range = distance_m;
ultrasonic_pub->publish(msg);
}
}
void ultrasonic_sensor(void* params)
{
// Register node in the ROS system and create a publisher with ultrasound topic.
ros::Node* n = new ros::Node("ultrasonic_sensor");
ultrasonic_pub = new ros::Publisher;
ultrasonic_pub->advertise<Range>(n, "ultrasound");
// Initialize sensor.
HCSR04::init();
// Begin periodic loop with PUBLISH_PERIOD in milliseconds.
spinLoop(ultrasonicLoop, PUBLISH_PERIOD);
// Code never reaches here, deleting allocated memory is not necessary.
}
```
## How to Setup
A tutorial on how to set up the system is given <a href="https://github.com/bosch-ros-pkg/stm32/wiki">here</a>.
没有合适的资源?快使用搜索试试~ 我知道了~
stm32-master.zip_The Client_built1nn_memoryegy_roslibSTM32_stm32
共708个文件
c:359个
h:280个
cpp:26个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 15 浏览量
2022-09-21
00:42:09
上传
评论
收藏 3.68MB ZIP 举报
温馨提示
Program Real-Time ROS Nodes on STM32 An embedded system supporting multiple ROS nodes that are able to communicate with one another using inter-process communication and with other ROS-compatible devices over a network. This system consists of an STM32F4Discovery board, the FreeRTOS operating system, an embedded ROS middleware, and an embedded ROS client library. Application layer is the layer for ROS nodes and sensor libraries.
资源推荐
资源详情
资源评论
收起资源包目录
stm32-master.zip_The Client_built1nn_memoryegy_roslibSTM32_stm32 (708个子文件)
arm_cortexMx_math_Build.bat 734B
arm_cortexMx_math_Build.bat 404B
arm_dct4_init_f32.c 201KB
stm32f4xx_tim.c 122KB
mib2.c 105KB
arm_dct4_init_q31.c 105KB
arm_rfft_init_f32.c 103KB
stm32f4xx_rtc.c 101KB
stm32f4x7_eth.c 100KB
tasks.c 93KB
stm32f4xx_rcc.c 73KB
arm_dct4_init_q15.c 71KB
stm32f4xx_adc.c 67KB
dhcp.c 63KB
stm32f4xx_can.c 59KB
sockets.c 57KB
lcp.c 57KB
arm_cfft_radix4_q15.c 57KB
ppp.c 56KB
tcp_in.c 55KB
stm32f4xx_usart.c 55KB
arm_cfft_radix4_init_f32.c 55KB
queue.c 55KB
stm32f4xx_i2c.c 51KB
stm32f4xx_dma.c 51KB
stm32f4xx_spi.c 51KB
etharp.c 45KB
tcp.c 44KB
msg_in.c 43KB
stm32f4xx_fsmc.c 41KB
ipcp.c 40KB
stm32f4xx_sdio.c 39KB
arm_rfft_init_q15.c 38KB
ppp_oe.c 38KB
stm32f4xx_flash.c 37KB
tcp_out.c 35KB
api_msg.c 35KB
arm_cfft_radix4_f32.c 34KB
stm32f4xx_cryp.c 32KB
pbuf.c 31KB
dns.c 31KB
arm_cfft_radix4_init_q31.c 30KB
arm_rfft_init_q31.c 30KB
mib_structs.c 30KB
udp.c 29KB
arm_cfft_radix4_q31.c 27KB
ip_frag.c 27KB
stm32f4xx_dac.c 26KB
auth.c 26KB
timers.c 26KB
ip.c 26KB
igmp.c 26KB
stm32f4xx_hash.c 25KB
chap.c 25KB
stm32f4xx_pwr.c 25KB
fsm.c 24KB
arm_conv_partial_q15.c 24KB
arm_correlate_q7.c 24KB
arm_conv_partial_q7.c 23KB
dynamic.c 23KB
system_stm32f4xx.c 22KB
msg_out.c 22KB
startup_stm32f4xx.c 22KB
mem.c 22KB
arm_correlate_f32.c 22KB
arm_conv_partial_fast_q15.c 22KB
arm_correlate_q15.c 22KB
arm_cfft_radix4_init_q15.c 22KB
arm_mat_inverse_f32.c 22KB
arm_conv_q15.c 21KB
arm_sin_cos_f32.c 21KB
arm_correlate_q31.c 21KB
stm32f4xx_cryp_aes.c 21KB
arm_conv_q7.c 21KB
stm32f4xx_gpio.c 21KB
arm_conv_fast_q15.c 20KB
arm_conv_partial_fast_q31.c 20KB
arm_conv_partial_f32.c 20KB
netif.c 20KB
arm_correlate_fast_q31.c 19KB
arm_conv_partial_q31.c 19KB
printf-stdarg.c 19KB
vj.c 19KB
arm_correlate_fast_q15.c 19KB
stm32f4xx_dcmi.c 18KB
arm_conv_f32.c 18KB
arm_biquad_cascade_df1_32x64_q31.c 18KB
arm_conv_fast_q31.c 18KB
arm_conv_q31.c 18KB
events.c 17KB
arm_dct4_f32.c 17KB
api_lib.c 17KB
asn1_dec.c 17KB
autoip.c 16KB
tcpip.c 16KB
arm_fir_lattice_f32.c 16KB
Shell.c 16KB
arm_biquad_cascade_df1_f32.c 16KB
arm_fir_lattice_q15.c 16KB
croutine.c 15KB
共 708 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
JaniceLu
- 粉丝: 78
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功