Skip to content

Commit

Permalink
Support no display (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo authored Oct 8, 2023
1 parent 610e104 commit d7ceb85
Show file tree
Hide file tree
Showing 28 changed files with 500 additions and 599 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/catkin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ jobs:
CATKIN_WS: /home/runner/work/catkin_ws
steps:
- uses: actions/checkout@v2
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/package.xml') }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-${{ hashFiles('**/package.xml') }}-${{ hashFiles('**/requirements.txt') }}
- name: Cache apt
uses: actions/cache@v2
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ github.run_id }}
restore-keys: ${{ runner.os }}-apt-${{ github.run_id }}
- name: Setup ROS
uses: ros-tooling/[email protected]
with:
Expand Down
72 changes: 39 additions & 33 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,53 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
target_project:
- enr_dps310_interface
- enr_message_board
- enr_stickv2_interface
- m5atoms3_sesami_client
- m5atoms3_switchbot_client
- sample_aes_cmac
- sample_esp_now_broadcaster
- sample_esp_now_receiver
- sample_sesami
- sample_uwb
- sdp_debug_board
- sdp_elevator_status_broadcaster
- sdp_example
- sdp_landmark_information
- sdp_sesami_host
- sdp_stickv2_interface
- smart_device_protocol_interface
env:
CATKIN_WS: /home/runner/work/catkin_ws
steps:
- uses: actions/checkout@v2
- name: Setup ROS
uses: ros-tooling/[email protected]
- name: Cache pip
uses: actions/cache@v2
with:
required-ros-distributions: noetic
- name: Install catkin tool
run: sudo apt-get install python3-catkin-tools
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.txt') }}
- name: Cache PlatformIO global ${{ matrix.target_project }}
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio-global-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
restore-keys: ${{ runner.os }}-platformio-global-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
- name: Cache PlatformIO local ${{ matrix.target_project }}
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/sketchbooks/${{ matrix.target_project }}/.pio
key: ${{ runner.os }}-platformio-local-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
restore-keys: ${{ runner.os }}-platformio-local-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
- name: Update pip and install pip package
run: |
pip3 install pip --upgrade
pip3 install pyopenssl --upgrade
pip3 install platformio
- name: Init workspace
run: |
source /opt/ros/noetic/setup.bash
mkdir -p ${CATKIN_WS}/src
ln -s ${GITHUB_WORKSPACE} ${CATKIN_WS}/src/
- name: pre build
run: |
source /opt/ros/noetic/setup.bash
rosdep update
rosdep install -i -y --from-paths ./
- name: build
run: |
source /opt/ros/noetic/setup.bash
cd ${CATKIN_WS}
catkin build
- name: Update ros_lib
run: |
source ${CATKIN_WS}/devel/setup.bash
rm -rf $(rospack find esp_now_ros)/ros_lib
rosrun rosserial_arduino make_libraries.py $(rospack find esp_now_ros)/ros_lib
- name: build sketches esp_now_ros
- name: build sketch ${{ matrix.target_project }}
run: |
source ${CATKIN_WS}/devel/setup.bash
find $(rospack find esp_now_ros)/sketchbooks -maxdepth 1 -type d | while read dir; do
if [ "$dir" != "$(rospack find esp_now_ros)/sketchbooks" ]; then
echo "Building $dir"
pio run -d $dir
fi
done
pio run -d ${{ github.workspace }}/sketchbooks/${{ matrix.target_project }}
91 changes: 91 additions & 0 deletions .github/workflows/platformio_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Cakin Build and PlatformIO Build Workflow

on:
push:
branches: [master]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
target_project:
- enr_dps310_interface
- enr_message_board
- enr_stickv2_interface
- m5atoms3_sesami_client
- m5atoms3_switchbot_client
- sample_aes_cmac
- sample_esp_now_broadcaster
- sample_esp_now_receiver
- sample_sesami
- sample_uwb
- sdp_debug_board
- sdp_elevator_status_broadcaster
- sdp_example
- sdp_landmark_information
- sdp_sesami_host
- sdp_stickv2_interface
- smart_device_protocol_interface
env:
CATKIN_WS: /home/runner/work/catkin_ws
steps:
- uses: actions/checkout@v2
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}-${{ hashFiles('${GITHUB_WORKSPACE}/requirements.txt') }}
- name: Cache apt
uses: actions/cache@v2
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}
restore-keys: ${{ runner.os }}-apt-${{ hashFiles('${GITHUB_WORKSPACE}/package.xml') }}
- name: Cache PlatformIO global ${{ matrix.target_project }}
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio-global-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
restore-keys: ${{ runner.os }}-platformio-global-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
- name: Cache PlatformIO local ${{ matrix.target_project }}
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/sketchbooks/${{ matrix.target_project }}/.pio
key: ${{ runner.os }}-platformio-local-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
restore-keys: ${{ runner.os }}-platformio-local-${{ matrix.target_project }}-${{ hashFiles('${GITHUB_WORKSPACE}/sketchbooks/${{ matrix.target_project }}/platformio.ini') }}
- name: Setup ROS
uses: ros-tooling/[email protected]
with:
required-ros-distributions: noetic
- name: Install catkin tool
run: sudo apt-get install python3-catkin-tools
- name: Update pip and install pip package
run: |
pip3 install pip --upgrade
pip3 install pyopenssl --upgrade
pip3 install platformio
- name: Init workspace
run: |
source /opt/ros/noetic/setup.bash
mkdir -p ${CATKIN_WS}/src
ln -s ${{ github.workspace }} ${CATKIN_WS}/src/
- name: pre build
run: |
source /opt/ros/noetic/setup.bash
rosdep update
rosdep install -i -y --from-paths ./
- name: catkin build
run: |
source /opt/ros/noetic/setup.bash
cd ${CATKIN_WS}
catkin build
- name: Update ros_lib
run: |
source ${CATKIN_WS}/devel/setup.bash
rm -rf ${{ github.workspace }}/ros_lib
rosrun rosserial_arduino make_libraries.py ${{ github.workspace }}/ros_lib
- name: build sketch ${{ matrix.target_project }}
run: |
pio run -d ${{ github.workspace }}/sketchbooks/${{ matrix.target_project }}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ Second, you have to make an ESP32 device which is connected to your PC via USB.
This device will be the interface to Smart Device Protocol communication of your PC.
Basically, you can use any ESP32 device, but this package is tested with M5Stack-Fire, M5Stack-Core2, and M5Atom-S3.

There are two types of smart device protocol interface device. In this tutorial, we will use [esp_now_ros_interface](./sketchbooks/esp_now_ros/).

- [esp_now_ros_interface](./sketchbooks/esp_now_ros/): This is the basic interface device. You can send and receive packet via ROS topic.
- [enr_interface_with_uwb](./sketchbooks/enr_interface_with_uwb/): This is the interface device with [UWB module](https://shop.m5stack.com/products/ultra-wideband-uwb-unit-indoor-positioning-module-dw1000). You can send and receive packet via ROS topic, and also you can get UWB ranging result via ROS topic.

We will use [smart_device_protocol_interface](./sketchbooks/smart_device_protocol_interface) project.
This code is developed with [PlatformIO](https://platformio.org/). So you can build and burn firmware with it.

You can execute `pio` command.
Expand Down Expand Up @@ -102,7 +98,7 @@ Then, connect M5Stack-Core2 to your PC. You can check which port is connected to
So let's build firmware and burn it to M5Stack-Core2
```bash
roscd esp_now_ros/sketchbooks/esp_now_ros/
roscd esp_now_ros/sketchbooks/smart_device_protocol_interface/
pio run -e m5stack-core2 --target upload --upload-port /dev/ttyACM0
```
Expand Down
23 changes: 23 additions & 0 deletions arduino_lib/sdp/esp_now.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <esp_system.h>
#include <esp_now.h>
#include <WiFi.h>

#include <esp_now_ros/Packet.h>

bool init_esp_now(uint8_t *mac_address, esp_now_recv_cb_t callback_receive)
{
// Read device mac address
esp_read_mac(mac_address, ESP_MAC_WIFI_STA);

WiFi.mode(WIFI_STA);
WiFi.disconnect();
if (esp_now_init() != ESP_OK)
{
return false;
}
if (callback_receive != NULL)
{
esp_now_register_recv_cb(callback_receive);
}
return true;
}
17 changes: 10 additions & 7 deletions arduino_lib/sdp/sdp_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*
* To use these functions, you need to include the following libraries:
* - esp_now_ros/Packet.h
* - packet_creator.h
* - packet_parser.h
*/

#include <esp_system.h>
Expand All @@ -16,6 +14,7 @@

#include <esp_now_ros/Packet.h>

#include "sdp/esp_now.h"
#include "sdp/packet_util.h"
#include "sdp/packet_creator.h"
#include "sdp/packet_parser.h"
Expand All @@ -24,8 +23,10 @@ String _sdp_device_name;
esp_now_peer_info_t _peer_broadcast;

typedef void (*sdp_data_if_recv_cb_t)(const uint8_t *mac_addr, const std::vector<SDPData> &body);
typedef void (*sdp_data_recv_cb_t)(const uint8_t *mac_addr, const SDPInterfaceDescription &interface_description, const std::vector<SDPData> &body);
typedef void (*sdp_meta_recv_cb_t)(const uint8_t *mac_addr, const std::string &device_name, const std::vector<SDPInterfaceDescription> &interfaces);
typedef void (*sdp_data_recv_cb_t)(const uint8_t *mac_addr, const SDPInterfaceDescription &interface_description,
const std::vector<SDPData> &body);
typedef void (*sdp_meta_recv_cb_t)(const uint8_t *mac_addr, const std::string &device_name,
const std::vector<SDPInterfaceDescription> &interfaces);
typedef std::tuple<SDPInterfaceDescription, sdp_data_if_recv_cb_t> SDPInterfaceCallbackEntry;

std::vector<SDPInterfaceCallbackEntry> _sdp_interface_data_callbacks;
Expand Down Expand Up @@ -75,7 +76,8 @@ bool _broadcast_sdp_meta_packet(const SDPInterfaceDescription &packet_descriptio
uint8_t buf[245];
const std::string &packet_description = std::get<0>(packet_description_and_serialization_format);
const std::string &serialization_format = std::get<1>(packet_description_and_serialization_format);
generate_meta_frame(buf, _sdp_device_name.c_str(), packet_description.c_str(), serialization_format.c_str(), "", "", "", "");
generate_meta_frame(buf, _sdp_device_name.c_str(), packet_description.c_str(), serialization_format.c_str(), "", "",
"", "");
bool success = esp_now_send(_peer_broadcast.peer_addr, buf, sizeof(buf)) == ESP_OK;
return success;
}
Expand Down Expand Up @@ -125,7 +127,8 @@ bool init_sdp(uint8_t *mac_address, const String &device_name)
return true;
}

bool register_sdp_interface_callback(SDPInterfaceDescription packet_description_and_serialization_format, sdp_data_if_recv_cb_t callback)
bool register_sdp_interface_callback(SDPInterfaceDescription packet_description_and_serialization_format,
sdp_data_if_recv_cb_t callback)
{
// Check if the callback is already registered
for (auto &entry : _sdp_interface_data_callbacks)
Expand Down Expand Up @@ -182,4 +185,4 @@ bool send_sdp_data_packet(const SDPInterfaceDescription &interface_description,
}
}

#endif // ESP_NOW_ROS_SDP_UTIL_H
#endif // ESP_NOW_ROS_SDP_UTIL_H
Empty file added arduino_lib/utils/ros_util.h
Empty file.
26 changes: 0 additions & 26 deletions sketchbooks/enr_interface_with_uwb/platformio.ini

This file was deleted.

Loading

0 comments on commit d7ceb85

Please sign in to comment.