Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPI PICO W integration #890

Open
wants to merge 1 commit into
base: humble
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ project(pico_micro_ros_example C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(PICO_BOARD pico_w CACHE STRING "Board type")

pico_sdk_init()

link_directories(libmicroros)
add_executable(pico_micro_ros_example
pico_micro_ros_example.c
pico_uart_transport.c
pico_wifi_transport.c
librobot/motor.c
librobot/robot.c
librobot/sensor.c
)
target_link_libraries(pico_micro_ros_example
pico_stdlib
hardware_pwm
microros
)

target_include_directories(pico_micro_ros_example PUBLIC
libmicroros/include
librobot
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/..
)

target_link_libraries(pico_micro_ros_example
pico_cyw43_arch_lwip_threadsafe_background
)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
Expand Down
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ source ~/.bashrc
Once the Pico SDK is ready, compile the example:

```bash
cd micro_ros_raspberrypi_pico_sdk
cd uros_pico_w
mkdir build
cd build
cmake ..
Expand All @@ -54,13 +54,34 @@ cp pico_micro_ros_example.uf2 /media/$USER/RPI-RP2
Micro-ROS follows the client-server architecture, so you need to start the Micro-ROS Agent.
You can do so using the [micro-ros-agent Docker](https://hub.docker.com/r/microros/micro-ros-agent):
```bash
docker run -it --rm -v /dev:/dev --privileged --net=host microros/micro-ros-agent:humble serial --dev /dev/ttyACM0 -b 115200
docker run -it --rm -v /dev:/dev --privileged --net=host microros/micro-ros-agent:humble upd4 --port 4444
```

Or using the snap agent:
```bash
#Install
sudo snap install micro-ros-agent
#Run
micro-ros-agent udp4 --port 4444 # add -v[1-6] to specify verbosity
```

Or directly in your ros ecosystem running the micro-ros-agent node [micro-ros-agent node](https://micro.ros.org/docs/tutorials/core/first_application_linux/):
```bash
# Download micro-ROS-Agent packages
ros2 run micro_ros_setup create_agent_ws.sh

# Build step
ros2 run micro_ros_setup build_agent.sh
. install/local_setup.bash

# Run a micro-ROS agent
ros2 run micro_ros_agent micro_ros_agent udp4 --port 4444
```

## What files are relevant?
- `pico_uart_transport.c`: Contains the board specific implementation of the serial transport (no change needed).
- `pico_wifi_transport.c`: Contains the board specific implementation of the wifi transport (no change needed).
- `CMakeLists.txt`: CMake file.
- `pico_micro_ros_example.c`: The actual ROS 2 publisher.
- `pico_micro_ros_example.c`: The Picobot ROS 2 exemple.

## How to build the precompiled library

Expand All @@ -73,6 +94,7 @@ docker run -it --rm -v $(pwd):/project microros/micro_ros_static_library_builder
```

Note that folders added to `microros_static_library/library_generation/extra_packages` and entries added to `microros_static_library/library_generation/extra_packages/extra_packages.repos` will be taken into account by this build system.

## How to use Pico SDK?

Here is a Raspberry Pi Pico C/C++ SDK documentation:
Expand Down
Loading