Skip to content

Commit

Permalink
Merge pull request #25 from ichiro-its/miscellaneous-changes
Browse files Browse the repository at this point in the history
Miscellaneous changes
  • Loading branch information
threeal authored May 25, 2021
2 parents 84b5331 + 3200f37 commit 0748be4
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 54 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: Build and Test
on:
workflow_dispatch:
pull_request:
branches: [ master ]
branches: [master]
push:
branches: [ master ]
branches: [master]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checking out
- name: Checkout this repository
uses: actions/[email protected]
- name: Building and testing
uses: ichiro-its/[email protected]
with:
ros2-distro: foxy
path: musen

- name: Build and test workspace
uses: ichiro-its/ros2-build-and-test-action@main
41 changes: 41 additions & 0 deletions .github/workflows/deploy-debian-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Debian Nightly
on:
workflow_dispatch:
push:
branches: [master]
jobs:
deploy-debian-nightly:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
with:
path: musen

- name: Build nightly Debian package
uses: ichiro-its/ros2-build-debian-action@main
with:
unique-version: true

- name: Deploy nightly Debian package to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
source: "package/*.deb"
target: "~/temp/nightly/musen/"
rm: true

- name: Prepare nightly Debian package in the server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
script: |
cd ~/repository/debian
reprepro includedeb nightly ~/temp/nightly/musen/package/*.deb
rm -rf ~/temp/nightly/musen/
39 changes: 39 additions & 0 deletions .github/workflows/deploy-debian-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Debian Stable
on:
workflow_dispatch:
release:
types: [created]
jobs:
deploy-debian-stable:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
with:
path: musen

- name: Build stable Debian package
uses: ichiro-its/ros2-build-debian-action@main

- name: Deploy stable Debian package to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
source: "package/*.deb"
target: "~/temp/stable/musen/"
rm: true

- name: Prepare stable Debian package in the server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
script: |
cd ~/repository/debian
reprepro includedeb stable ~/temp/stable/musen/package/*.deb
rm -rf ~/temp/stable/musen/
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

[![latest version](https://img.shields.io/github/v/release/ichiro-its/musen)](https://github.com/ichiro-its/musen/releases/)
[![commits since latest version](https://img.shields.io/github/commits-since/ichiro-its/musen/latest)](https://github.com/ichiro-its/musen/commits/master)
[![milestone](https://img.shields.io/github/milestones/progress/ichiro-its/musen/1?label=milestone)](https://github.com/ichiro-its/musen/milestone/2)
[![license](https://img.shields.io/github/license/ichiro-its/musen)](./LICENSE)
[![build and test status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Build%20and%20Test?label=build%20and%20test)](https://github.com/ichiro-its/musen/actions)
[![test status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Build%20and%20Test?label=test)](https://github.com/ichiro-its/musen/actions)
[![deploy stable status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Deploy%20Debian%20Stable?label=deploy%20stable)](https://repository.ichiro-its.org/)
[![deploy nightly status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Deploy%20Debian%20Nightly?label=deploy%20nightly)](https://repository.ichiro-its.org/)

Musen (無線, wireless) is a [ROS 2](https://docs.ros.org/en/foxy/index.html) package that provides a [UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol) broadcast communication library for a ROS 2 project.
This package is written in C++ and currently only works on Linux based operating system.
Expand All @@ -25,7 +26,7 @@ In this package, the broadcast communication will be handled by a Broadcaster ob
### Binary Packages

- See [releases](https://github.com/ichiro-its/musen/releases) for the latest version of this package.
- Alternatively, this package is available on [ICHIRO ITS Repository](https://repository.ichiro-its.org/) as a `ros-foxy-musen` package.
- Alternatively, this package also available on [ICHIRO ITS Repository](https://repository.ichiro-its.org/) as `ros-foxy-musen` package.

### Build From Source

Expand Down
25 changes: 18 additions & 7 deletions include/musen/broadcaster/base_broadcaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,46 @@

#include <arpa/inet.h>

#include <string>
#include <list>
#include <memory>
#include <string>

#include "../udp_socket.hpp"

namespace musen
{

class BaseBroadcaster : public UdpSocket
class BaseBroadcaster
{
public:
explicit BaseBroadcaster(const int & port);
explicit BaseBroadcaster(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());

bool connect();
bool disconnect();

int send(const void * data, const int & length);
int send(const char * data, const int & length);

void enable_broadcast(const bool & enable);
void add_target_host(const std::string & host);

std::shared_ptr<UdpSocket> get_udp_socket() const;

const int & get_port() const;

protected:
std::list<struct sockaddr_in> get_recipent_sas() const;
std::list<struct sockaddr_in> get_recipent_sas_from_broadcast_ifas() const;
std::list<struct sockaddr_in> get_recipent_sas_from_target_hosts() const;
std::list<struct sockaddr_in> obtain_recipent_sas() const;
std::list<struct sockaddr_in> obtain_recipent_sas_from_broadcast_ifas() const;
std::list<struct sockaddr_in> obtain_recipent_sas_from_target_hosts() const;

std::shared_ptr<UdpSocket> udp_socket;

bool broadcast;
std::list<std::string> target_hosts;

int port;

std::list<struct sockaddr_in> recipent_sas;
};

} // namespace musen
Expand Down
9 changes: 6 additions & 3 deletions include/musen/broadcaster/broadcaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef MUSEN__BROADCASTER__BROADCASTER_HPP_
#define MUSEN__BROADCASTER__BROADCASTER_HPP_

#include <memory>

#include "./base_broadcaster.hpp"

namespace musen
Expand All @@ -30,14 +32,15 @@ template<typename T>
class Broadcaster : public BaseBroadcaster
{
public:
explicit Broadcaster(const int & port)
: BaseBroadcaster(port)
explicit Broadcaster(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>())
: BaseBroadcaster(port, udp_socket)
{
}

int send(const T & data)
{
return BaseBroadcaster::send(&data, sizeof(data));
return BaseBroadcaster::send((const char *)&data, sizeof(data));
}
};

Expand Down
4 changes: 3 additions & 1 deletion include/musen/broadcaster/string_broadcaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef MUSEN__BROADCASTER__STRING_BROADCASTER_HPP_
#define MUSEN__BROADCASTER__STRING_BROADCASTER_HPP_

#include <memory>
#include <string>
#include <vector>

Expand All @@ -32,7 +33,8 @@ namespace musen
class StringBroadcaster : public BaseBroadcaster
{
public:
explicit StringBroadcaster(const int & port);
explicit StringBroadcaster(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());

int send(const std::string & message);
int send(const std::vector<std::string> & messages, const std::string & delimiter = ",");
Expand Down
12 changes: 10 additions & 2 deletions include/musen/listener/base_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef MUSEN__LISTENER__BASE_LISTENER_HPP_
#define MUSEN__LISTENER__BASE_LISTENER_HPP_

#include <memory>

#include "../udp_socket.hpp"

namespace musen
Expand All @@ -29,15 +31,21 @@ namespace musen
class BaseListener : public UdpSocket
{
public:
explicit BaseListener(const int & port);
explicit BaseListener(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());

bool connect() override;
bool connect();
bool disconnect();

int receive(void * buffer, const int & length);

std::shared_ptr<UdpSocket> get_udp_socket() const;

const int & get_port() const;

protected:
std::shared_ptr<UdpSocket> udp_socket;

int port;
};

Expand Down
5 changes: 3 additions & 2 deletions include/musen/listener/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ template<typename T>
class Listener : public BaseListener
{
public:
explicit Listener(const int & port)
: BaseListener(port)
explicit Listener(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>())
: BaseListener(port, udp_socket)
{
}

Expand Down
4 changes: 3 additions & 1 deletion include/musen/listener/string_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef MUSEN__LISTENER__STRING_LISTENER_HPP_
#define MUSEN__LISTENER__STRING_LISTENER_HPP_

#include <memory>
#include <string>
#include <vector>

Expand All @@ -32,7 +33,8 @@ namespace musen
class StringListener : public BaseListener
{
public:
explicit StringListener(const int & port);
explicit StringListener(
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());

std::string receive(const int & length);
std::vector<std::string> receive(const int & length, const std::string & delimiter);
Expand Down
2 changes: 2 additions & 0 deletions include/musen/udp_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class UdpSocket
virtual bool connect();
virtual bool disconnect();

const int & get_sockfd() const;

bool is_connected() const;

protected:
Expand Down
Loading

0 comments on commit 0748be4

Please sign in to comment.