国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

如何在任何STM32上面安裝micro_ros(貌似這個(gè)文章里面已經(jīng)沒(méi)有什么可以繼續(xù)阻擋我的了,我有g(shù)itee和docker,雖然docker其實(shí)用不著)

這篇具有很好參考價(jià)值的文章主要介紹了如何在任何STM32上面安裝micro_ros(貌似這個(gè)文章里面已經(jīng)沒(méi)有什么可以繼續(xù)阻擋我的了,我有g(shù)itee和docker,雖然docker其實(shí)用不著)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

JMP推薦跳轉(zhuǎn)到此篇文章==>STM32CubeMX+micro_ros_stm32cubemx_utils庫(kù)-CSDN博客

就我知道的:micro-ros只能在特定的昂貴的開(kāi)發(fā)板上面運(yùn)行,但是偶然發(fā)現(xiàn)了這個(gè)文章,似乎提供了一個(gè)全新的方式來(lái)在ros2和單片機(jī)之間通訊,如果能夠這樣肯定也能夠提高效率,但即使不行,使用串口庫(kù)也應(yīng)該比較簡(jiǎn)單。

GitHub - lFatality/stm32_micro_ros_setup: Example of how to setup micro-ROS on any STM32 microcontroller

README.md

Setting up micro-ROS on any STM32 microcontroller

This repository gives an example of how to set up micro-ROS on any STM32 microcontroller. For this repository an STM32F429ZI was chosen but you are free to choose another one.

You can also find the instructions in video form here:?https://youtu.be/xbWaHARjSmk

Goal

If you follow all steps in the tutorial you should have an STM32 microcontroller with a micro-ROS publisher that transmits messages via UART to your PC running ROS 2. Here you can receive the messages via?ros2 topic echo.

Steps

In the following the required steps to achieve the goal are presented in detail. It will show how to do this for a microcontroller that is not listed as a device directly supported by micro-ROS. (看到?jīng)]有:即使是不受官方支持的,也可以使用MICRO_ROS,那個(gè)官方支持的開(kāi)發(fā)板實(shí)在太少,而且太貴,所以我才說(shuō)成本太高,現(xiàn)在看來(lái)有辦法降低成本了)If you find that you have problems check out the?Troubleshooting?section below.(如果有問(wèn)題請(qǐng)看后面的”Trobleshooting“部分

micro-ROS

1.) Create a new CubeMx project for your micro controller
2.) In?System Core -> RCC -> High Speed Clock (HSE)?select?Crystal/Ceramic Resonator

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
3.) In?System Core -> SYS -> Timebase Source?select?TIM1

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
4.) In?Middleware -> FREERTOS -> Interface?select?CMSIS_V2

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
4.1.) In?Middleware -> FREERTOS -> Configuration -> Task and Queues?double click the?defaultTask?and set a stack size of 3000. It has to be greater than 10.000 byte (3000 words * 4 byte = 12.000 byte).F103C8T6有20KB,明明沒(méi)有超為什么不行?

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

?注意了:STM32C8T6在這里好像出了問(wèn)題:因?yàn)檫@個(gè)Stack Size我感覺(jué)好像超了

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

如果遇到這個(gè)問(wèn)題需要首先修改堆棧大?。?/p>

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

?修改步驟:修改Config parmeters-->Memory management settings---->TOTAL_HEAP_SIZE設(shè)置為16000;然后就可以解決這個(gè)問(wèn)題

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

?看吧已經(jīng)改好了

5.) In?Connectivity?choose the?UART?/?USART?that you want to use.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
5.1.) In the Uart configuration, go to?DMA Settings. Click on the?Add?button. Click on the?Select?dropdown and choose both?Rx?and?Tx.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
5.2.) Click on the?Rx?DMA you've just created and for?Mode?choose?Circular.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
5.3.) For the priority of the?DMA?choose?Very high?for both?Rx?and?Tx.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2


5.4.) Go to?NVIC Settings?of the?UART?and activate the?UARTx global interrupt.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
6.) Set up the?Clock Configuration?for your micro controller
7.) In?Project Manager?select a folder where to generate your code
7.1.) In?Toolchain / IDE?select?Makefile(這里有點(diǎn)不一樣:平時(shí)都選擇keil)

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2
7.2.) Optional: In?Project Manager -> Code Generator?select?Generate peripheral intitialization as a pair of '.c/.h' files per peripheral
8.) Click on?Generate Code
9.) In the root folder of the code you've just generated, clone the following repository (into a subfolder, don't change its name).:

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

git clone https://github.com/micro-ROS/micro_ros_stm32cubemx_utils.git

10.) Make sure you have the right branch for your ROS version checked out 11.) In the Makefile that was generated by CubeMx put the following code snippet after the part where it says?build the application:

#######################################
# micro-ROS addons
#######################################
LDFLAGS += micro_ros_stm32cubemx_utils/microros_static_library/libmicroros/libmicroros.a
C_INCLUDES += -Imicro_ros_stm32cubemx_utils/microros_static_library/libmicroros/microros_include

# Add micro-ROS utils
C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/custom_memory_manager.c
C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_allocators.c
C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_time.c

# Set here the custom transport implementation
C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_transports/dma_transport.c

print_cflags:
  @echo $(CFLAGS)

11.)Execute the static library generation tool.(執(zhí)行“靜態(tài)庫(kù)產(chǎn)生”工具軟件) Compiler flags will retrieved automatically from your?Makefile?and user will be prompted to check if they are correct.

Pull and run the following docker (這個(gè)docker就是靜態(tài)庫(kù)生產(chǎn)工具軟件)to generate the micro-ros lib(我現(xiàn)在就卡在這個(gè)編譯靜態(tài)micro_lib庫(kù)的地方,我需要知道怎么樣編譯micro_lib靜態(tài)庫(kù)). Make sure you use the right ROS version (注意這個(gè)ros的版本不要搞錯(cuò)了makefile里的版本要搞對(duì),下面這個(gè)galactic指的是ros2版本,我的是humble就應(yīng)該吧galactic改為humble)when you pull / run the docker. This should be executed in the root folder of your project.

stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

?#這里的microros/micro_ros_static_library_builder:humble是服務(wù)器上面的鏡像名稱(chēng),不是本地存放位置

docker pull microros/micro_ros_static_library_builder:humble

#docker pull命令:從鏡像倉(cāng)庫(kù)獲取鏡像;應(yīng)該就是構(gòu)建了一個(gè)micro_ros的編譯環(huán)境

#后面3行是一個(gè)整體,并且其中的project要修改為存放micro_ros_stm32cubemx_utils文件夾的文件夾其中/project必須是絕對(duì)文件位置,不能是以~開(kāi)頭之類(lèi)的相對(duì)位置

docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=micro_ros_stm32cubemx_utils/microros_static_library microros/micro_ros_static_library_builder:humble

解讀0:這個(gè)-v $(pwd): /project 應(yīng)該就是把本地的$(pwd)文件夾映射為容器里面的/project文件夾。

解讀1:上邊這個(gè)--env 即environment,指定環(huán)境變量microros_library_folder=靜態(tài)庫(kù)的地址為micro_ros_stm32cubemx_utils/microros_static_library.

解讀2:microros/micro_ros_static_library_builder:humble是本次運(yùn)行的軟件或者叫鏡像什么的。

這個(gè)句子的格式應(yīng)該就是docker run --env 指定環(huán)境變量X=123 運(yùn)行的軟件名稱(chēng)

最基本的啟動(dòng)命令(從image創(chuàng)建一個(gè)container并啟動(dòng)):docker run -d <image-name>

-v:本地host的文件(文件夾)映射到容器內(nèi)的文件(文件夾)

想起的-v參數(shù)是:-v [[host-dir:] container-dir

-v的第一個(gè)參數(shù)是host-dir,這個(gè)參數(shù)是可選參數(shù),如果沒(méi)設(shè)置,docker會(huì)在host主機(jī)中創(chuàng)建該文件夾

第二個(gè)參數(shù)是container-dir,這個(gè)參數(shù)是必選參數(shù),是容器內(nèi)部的文件夾

我已經(jīng)安裝了ros2和Ubuntu所以我就不用docker了上邊這個(gè)很可能就是編譯靜態(tài)庫(kù)的的過(guò)程,我替換為以下步驟:

#這個(gè)地方的網(wǎng)址可能要改一下,另外這條命令中src/micro_ros_setup表示在本地建立2個(gè)文件夾,一個(gè)是src,另外在src內(nèi)再建立一個(gè)micro_ros_setup文件夾,最后把遠(yuǎn)程復(fù)制的文件放到這個(gè)里面來(lái)
git clone -b humble https://github.com/micro-ROS/micro_ros_stm32cubemx_utils.git src/micro_ros_stm32cubemx_utils
rosdep update && rosdep install --from-paths src --ignore-src -y
colcon build
#應(yīng)該就是使用rosdep補(bǔ)全依賴(lài)項(xiàng),然后就使用colcon工具編譯這個(gè)代碼庫(kù)成為靜態(tài)庫(kù)

?上邊這個(gè)git命令不一定能正確運(yùn)行,所以可以自己使用瀏覽器從github下載代碼庫(kù),然后把文件放到文件夾內(nèi)。具體說(shuō)就是下載后的文件夾整個(gè)復(fù)制到src文件夾內(nèi)(沒(méi)有就新建一個(gè)src文件夾)

后面這個(gè)是對(duì)git clone remote_address local_address的一個(gè)示范??煽闯鰈ocal_address指定的是存放代碼庫(kù)的文件夾stm32micro-ros,ros2與STM32通訊,micro_ros與STM32通訊,stm32,ros2

12.) If it asks for the?CFLAGS, if you can see some, continue. They might look like this:

Found CFLAGS:
-------------
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32F429xx -ICore/Inc -IDrivers/STM32F4xx_HAL_Driver/Inc -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy -IMiddlewares/Third_Party/FreeRTOS/Source/include -IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -IDrivers/CMSIS/Device/ST/STM32F4xx/Include -IDrivers/CMSIS/Include -IDrivers/CMSIS/Include -Imicro_ros_stm32cubemx_utils/microros_static_library/libmicroros/microros_include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MFprint_cflags
-------------

If instead the CFLAGS are empty there was likely a mistake. If you get an error about a missing separator in the Makefile, check the line in the Makefile. For me there were 2 similar includes. I deleted one of them.

13.) If you get an error like this during building:

'rcutils' exports library 'dl' which couldn't be found

That's ok and can be ignored.

14.) Go into?Core/main.cpp?and adjust it so that it's similar to the?sample_main.cpp?you can find in the?micro_ros_stm32cubemx_utils?repository we found earlier. The most interesting parts are the following:

#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <uxr/client/transport.h>
#include <rmw_microxrcedds_c/config.h>
#include <rmw_microros/rmw_microros.h>

#include <std_msgs/msg/int32.h>
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);
void StartDefaultTask(void *argument)
{
    /* USER CODE BEGIN StartDefaultTask */
    /* Infinite loop */
    // micro-ROS configuration

    rmw_uros_set_custom_transport(
      true,
      (void *) &huart2,
      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");

    msg.data = 0;

    for(;;)
    {
      rcl_ret_t ret = rcl_publish(&publisher, &msg, NULL);
      if (ret != RCL_RET_OK)
      {
        printf("Error publishing (line %d)\n", __LINE__);
      }

      msg.data++;
      osDelay(10);
    }
    /* USER CODE END StartDefaultTask */
}

15.) Open the project in your favorite IDE. In general you should now be able to build and debug your program. To built I used the?arm-none-eabi-toolchain. To flash and debug I used?openocd. If you can not build check step 15.1.

15.1.) It might be that you can not build yet because of missing syscalls. In that case you might get errors like?undefined reference to _kill?or?undefined reference to _getpid. In that case add a?syscalls.c?file to your project and also add it to the?Makefile?so that it will be compiled. You can find an example?syscalls.c?at the end of this page.

micro-ROS agent

19.) Now you need a micro-ROS agent. It's responsible to create the communication between your embedded controller and the rest of your ROS 2 software. Create a different folder that will be used as a ROS 2 workspace.

20.) Clone the?micro_ros_setup?repository and build it by executing the following steps from the root of your workspace folder:

source /opt/ros/$ROS_DISTRO/setup.bash
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
rosdep update && rosdep install --from-path src --ignore-src -y
colcon build
source install/local_setup.bash

21.) Build the agent packages

ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.sh

I got a warning about stderr output when running?build_agent.sh?(at the end of the build process) but I ignored that. I also had a problem were?build_agent.sh?complained about being unable to find a package (Package 'micro_ros_agent' specified with --packages-up-to was not found). This was because I didn't follow the steps to build the workspace first correctly (step 20).

22.) Start the micro-ros-agent. For example:

ros2 run micro_ros_agent micro_ros_agent serial -b 115200 --dev /dev/ttyACM0

serial: for UART use, other options available -b: baudrate --dev: the device to use

To get help with the usage:

ros2 run micro_ros_agent micro_ros_agent --help

23.) In the agent you should see something like this:

[1641665035.090947] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1641665035.130109] info     | Root.cpp           | create_client            | create                 | client_key: 0x041835D4, session_id: 0x81
[1641665035.130212] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x041835D4, address: 0
[1641665035.156038] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x041835D4, participant_id: 0x000(1)
[1641665035.171020] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x041835D4, topic_id: 0x000(2), participant_id: 0x000(1)
[1641665035.181034] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x041835D4, publisher_id: 0x000(3), participant_id: 0x000(1)
[1641665035.191347] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x041835D4, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[1641665052.957930] info     | SessionManager.hpp | establish_session        | session re-established | client_key: 0x041835D4, address: 0

This is some kind of handshake between the agent and the embedded system. You might have to restart your MCU, the agent should be started first it seems.

If you see something like this instead:

[1641665033.757172] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1641665034.757430] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...

You have likely selected the wrong device or your MCU is not connected.

23.) You should now be able to see the messages published by the MCU on ROS2:

ros2 topic echo /cubemx_publisher

The data would look like this:

---
data: 2399
---
data: 2400
---
data: 2401
---
data: 2402
---
data: 2403
---
data: 2404
---

Troubleshooting

Problem 1

When stepping through the code the programs hangs at?rclc_support_init.

Solution 1

Be sure that the UART you use when calling?rmw_uros_set_custom_transport?is the one that you set up for ROS (e.g. with the right DMA settings). Also be aware that the call to this function can take some time (~10 seconds). When running the micro-ROS agent it usually is faster though.

Problem 2

The publishing doesn't work. I go into the error case in the infinite loop of the main task:

rcl_ret_t ret = rcl_publish(&publisher, &msg, NULL);
if (ret != RCL_RET_OK)
{
  printf("Error publishing (line %d)\n", __LINE__); // <-------------------- this is entered
}

In my case I can see some prints on the UART before entering the while loop. There is a lot of random bytes but sometimes I can see XRCE.

Solution 2

You need a running micro-ROS agent. See steps 19.) and following. If you have an agent running but it still doesn't work, look at problem / solution 6.

Problem 3

When trying to flash the board, I get an openocd bug saying something with "free"

Solution 3

Unplug MCU and replug it (power).

Problem 4

When I run the agent and MCU the agent says

fynn@sphalerite:~/main/dev/tests/micro-ros/agent_ws$ ros2 run micro_ros_agent micro_ros_agent serial -b 115200 --dev /dev/ttyACM0
[1643036775.906617] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1643036775.906762] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4

but nothing else happens and I can't receive my data.

Solution 4 :

Check that your MCU doesn't crash anywhere (e.g. in the syscalls).

Problem 5

I get an error saying that?_getpid?and?_kill?are not defined.

Solution 5

You need to define a?syscalls.c?file and add these function with their functionality. You can find an example of such a file at the end of this page.

Problem 6

When I run the agent and the MCU, the agent says

[1641665035.090947] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1641665035.130109] info     | Root.cpp           | create_client            | create                 | client_key: 0x041835D4, session_id: 0x81
[1641665035.130212] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x041835D4, address: 0

but it's not creating a participant or topic. I can't receive my data.

Solution 6

Check that you don't have another serial program (putty, hterm, gtkterm, ...) connected to your device (at least not to that same UART). Also be sure that your hardware setup is correct, e.g. that you have GND connected between the two nodes when using a UART connection.

Problem 7

If you're using Eclipse: When compiling Eclipse says?Error: Program "" not found in PATH

Solution 7

Right click your project -> Properties -> C/C++ Build -> Uncheck "Use default build command" and exchange?${cross_make}?with a simple?make

Problem 8

If you're using Eclipse:
I get an error that the program "" can not be executed

Solution 8

Right click your project -> Properties -> C/C++ Build: Untick?Use default build command. Define Build command as:?make

Problem 10

If you're using Eclipse and it says that it can't find the?arm-none-eabi-gcc

Solution 10

You need to download and extract the toolchain. You can find it here:?Downloads | GNU Arm Embedded Toolchain Downloads – Arm Developer

Then set up your Eclipse to know where it is: Right click your project -> Properties -> MCU -> Arm Toolchains Paths: Toolchain name:?xPack GNU Arm Embedded GCC?Toolchain folder:?path/to/your/arm-none-eabi-toolchain/bin

In the?bin?folder should be?arm-none-eabi-gcc?among others.

If it still doesn't work, try just opening the following menu: Right click your project -> Properties -> C/C++ Build -> Settings文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-834730.html

Example syscalls.c

/**
*****************************************************************************
**
**  File        : syscalls.c
**
**  Author        : Auto-generated by System workbench for STM32
**
**  Abstract    : System Workbench Minimal System calls file
**
**                   For more information about which c-functions
**                need which of these lowlevel functions
**                please consult the Newlib libc-manual
**
**  Target      : STMicroelectronics STM32
**
**  Distribution: The file is distributed “as is,” without any warranty
**                of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
**   1. Redistributions of source code must retain the above copyright notice,
**      this list of conditions and the following disclaimer.
**   2. Redistributions in binary form must reproduce the above copyright notice,
**      this list of conditions and the following disclaimer in the documentation
**      and/or other materials provided with the distribution.
**   3. Neither the name of STMicroelectronics nor the names of its contributors
**      may be used to endorse or promote products derived from this software
**      without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*****************************************************************************
*/

// the code was modified by Fynn Boyer

/* Includes */
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>


/* Variables */
//#undef errno
extern int errno;
extern int __io_putchar(int ch) __attribute__((weak));
extern int __io_getchar(void) __attribute__((weak));

register char * stack_ptr asm("sp");

char *__env[1] = { 0 };
char **environ = __env;

extern char _estack;  // see ld file
extern char _Min_Stack_Size;  // see ld file

/* Functions */
void initialise_monitor_handles()
{
}

int _getpid(void)
{
    return 1;
}

int _kill(int pid, int sig)
{
    errno = EINVAL;
    return -1;
}

void _exit (int status)
{
    _kill(status, -1);
    while (1) {}        /* Make sure we hang here */
}

__attribute__((weak)) int _read(int file, char *ptr, int len)
{
    int DataIdx;

    for (DataIdx = 0; DataIdx < len; DataIdx++)
    {
        *ptr++ = __io_getchar();
    }

return len;
}

__attribute__((weak)) int _write(int file, char *ptr, int len)
{
    int DataIdx;

    for (DataIdx = 0; DataIdx < len; DataIdx++)
    {
        __io_putchar(*ptr++);
    }
    return len;
}

caddr_t _sbrk(int incr) {
    extern char __heap_start__ asm("end");  // Defined by the linker.
    static char *heap_end;
    char *prev_heap_end;

    if (heap_end == NULL) heap_end = &__heap_start__;

    prev_heap_end = heap_end;

    if (heap_end + incr > &_estack - _Min_Stack_Size) {
            __asm("BKPT #0\n");
        errno = ENOMEM;
        return (caddr_t)-1;

    }

    heap_end += incr;
    return (caddr_t)prev_heap_end;

}

int _close(int file)
{
    return -1;
}


int _fstat(int file, struct stat *st)
{
    st->st_mode = S_IFCHR;
    return 0;
}

int _isatty(int file)
{
    return 1;
}

int _lseek(int file, int ptr, int dir)
{
    return 0;
}

int _open(char *path, int flags, ...)
{
    /* Pretend like we always fail */
    return -1;
}

int _wait(int *status)
{
    errno = ECHILD;
    return -1;
}

int _unlink(char *name)
{
    errno = ENOENT;
    return -1;
}

int _times(struct tms *buf)
{
    return -1;
}

int _stat(char *file, struct stat *st)
{
    st->st_mode = S_IFCHR;
    return 0;
}

int _link(char *old, char *new)
{
    errno = EMLINK;
    return -1;
}

int _fork(void)
{
    errno = EAGAIN;
    return -1;
}

int _execve(char *name, char **argv, char **env)
{
    errno = ENOMEM;
    return -1;
}

到了這里,關(guān)于如何在任何STM32上面安裝micro_ros(貌似這個(gè)文章里面已經(jīng)沒(méi)有什么可以繼續(xù)阻擋我的了,我有g(shù)itee和docker,雖然docker其實(shí)用不著)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【運(yùn)行在freertos上的microros 任何stm32平臺(tái)】

    【運(yùn)行在freertos上的microros 任何stm32平臺(tái)】

    `本文主要分享一下如何快速在stm32f103或stm32系列的任意板子上運(yùn)行microros的具體步驟。(所需要的文件已經(jīng)生成好了)。 生成的步驟極其踩坑,是一段令人痛苦的回憶。 生成靜態(tài)鏈接庫(kù)的踩坑主要內(nèi)容就是 所有資源都是外網(wǎng),需要代理,如果網(wǎng)絡(luò)不通暢所有的步驟都得重新

    2024年03月16日
    瀏覽(88)
  • ROS與STM32通信(二)-pyserial

    ROS與STM32通信(二)-pyserial

    ROS與STM32通信一般分為兩種, STM32上運(yùn)行ros節(jié)點(diǎn)實(shí)現(xiàn)通信 使用普通的串口庫(kù)進(jìn)行通信,然后以話(huà)題方式發(fā)布 第一種方式具體實(shí)現(xiàn)過(guò)程可參考上篇文章ROS與STM32通信-rosserial,上述文章中的收發(fā)頻率不一致情況,目前還沒(méi)解決,所以本篇文章采用第二種方式來(lái)實(shí)現(xiàn)STM32與ROS通信,

    2024年02月12日
    瀏覽(18)
  • ROS與STM32通信(一)-rosserial

    ROS與STM32通信(一)-rosserial

    STM32F103c8t6 OLED(I2C) USB2TTL Stlink 接線(xiàn) OLED(GPIO模擬I2C) 硬件 引腳 OLEDSCL PA4 OLEDSDA PA5 USART1 硬件 引腳 作用 RX PA9 USART1_TX TX PA10 USART1_RX LED 硬件 引腳 LED0 PC13 LED1 PC15 STM32CubeMX Clion STM32CubeMX配置 SYS-Debug-Serial Wire RCC-HSE-Crystal/Ceramic Resonator PC15-OutPut ,Label為L(zhǎng)ED0 PC13-OutPut ,Label為L(zhǎng)ED1 TIM1-Clock

    2024年02月09日
    瀏覽(12)
  • ROS機(jī)器人制作(三)—— ROS上位機(jī)與stm32進(jìn)行串口通信

    總代碼在文末,需要完整的工程文件可以私聊(收一點(diǎn)點(diǎn)辛苦費(fèi)) 首先創(chuàng)建一個(gè)功能包,用于發(fā)送和接收數(shù)據(jù)。 注意: 1.功能包依賴(lài): roscpp std_msgs rosserial 2.當(dāng)有兩個(gè)c++文件進(jìn)行編譯時(shí)可以在功能包下的CMakeLists.txt文件中 第一部分是ROS上位機(jī)給stm32發(fā)送數(shù)據(jù)。第二部分是stm

    2024年02月15日
    瀏覽(24)
  • STM32 使用microros與ROS2通信

    STM32 使用microros與ROS2通信

    本文主要介紹如何在STM32中使用microros與ROS2進(jìn)行通信,在ROS1中標(biāo)準(zhǔn)的庫(kù)是rosserial,在ROS2中則是microros,目前網(wǎng)上的資料也有一部分了,但是都沒(méi)有提供完整可驗(yàn)證的demo,本文將根據(jù)提供的demo一步步給大家進(jìn)行演示。 1、首先如果你用的不是STM32F4的話(huà),則需要自己去生成 micro_r

    2024年02月08日
    瀏覽(16)
  • yocto stm32mp1集成ros

    yocto stm32mp1集成ros

    本章節(jié)介紹yocto如何集成ros系統(tǒng)用來(lái)作機(jī)器人開(kāi)發(fā)。 第一步首先需要下載meta-ros layer,meta-ros的鏈接如下:https://github.com/ros/meta-ros/tree/master,在我們的yocto源碼layers路徑下執(zhí)行如下指令: 下載完成以后如下: 完成以后需要進(jìn)入到meta-ros里面切換匹配yocto版本的分支,比如我當(dāng)前

    2024年02月09日
    瀏覽(13)
  • 如何在centos上面安裝mpi4py

    參考鏈接: https://stackoverflow.com/questions/41446426/cannot-install-mpi4py-on-centos-7 https://stackoverflow.com/questions/55129738/centos-7-undefined-symbol-ompi-mpi-logical8 一般來(lái)說(shuō),直接使用pip安裝就可以了: 1.但是在centos上面我遇到了下面的問(wèn)題: error: Cannot compile MPI programs. Check your configuration!!! 找到的

    2024年02月15日
    瀏覽(28)
  • 在STM32中實(shí)現(xiàn)ROS節(jié)點(diǎn)——Rosserial的用法

    在STM32中實(shí)現(xiàn)ROS節(jié)點(diǎn)——Rosserial的用法

    本文介紹如何將stm32控制板作為一個(gè)單獨(dú)的ROS節(jié)點(diǎn)接入整個(gè)機(jī)器人ROS系統(tǒng)。 在一個(gè)完整的機(jī)器人硬件系統(tǒng)中,由于眾多傳感器接口和實(shí)時(shí)性的需求,不可避免的需要加入嵌入式控制器,現(xiàn)在的機(jī)器人大多使用了分布式ROS系統(tǒng),這套系統(tǒng)主要基于linux運(yùn)行,而以stm32為例的大多數(shù)

    2023年04月24日
    瀏覽(9)
  • SLAM從入門(mén)到精通(ROS和底盤(pán)Stm32的關(guān)系)

    SLAM從入門(mén)到精通(ROS和底盤(pán)Stm32的關(guān)系)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請(qǐng)勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 學(xué)過(guò)Ros的同學(xué),一般對(duì)subscribe、publish、話(huà)題、服務(wù)這些內(nèi)容都比較熟悉。如果再熟悉一點(diǎn)的話(huà),還會(huì)知道slam、move_base、moveit這些框架。再了解多一點(diǎn)的呢,會(huì)對(duì)框架里面的算法,比如

    2024年02月07日
    瀏覽(19)
  • 基于STM32F103的樹(shù)莓派ROS小車(chē)——全局路徑規(guī)劃之Dijkstra算法

    基于STM32F103的樹(shù)莓派ROS小車(chē)——全局路徑規(guī)劃之Dijkstra算法

    Dijkstra Dijkstra算法概念: 基本思想:由近到遠(yuǎn)把所有點(diǎn)的最短路徑算出來(lái)。 算法解析:從起點(diǎn)向四周輻射,由近到遠(yuǎn)一層一層遍歷所有的點(diǎn),直到包含目標(biāo)點(diǎn)所在層級(jí)。然后將所有可行路徑進(jìn)行計(jì)算比較,篩選出絕對(duì)最佳路徑。 優(yōu)點(diǎn):最終得到的路徑一定是最佳路徑。 缺點(diǎn)

    2024年02月15日
    瀏覽(25)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包