Skip to content

Commit

Permalink
Merge pull request #57 from mROS-base/v0.2.4
Browse files Browse the repository at this point in the history
V0.2.4
  • Loading branch information
takasehideki authored Feb 20, 2022
2 parents c027b87 + dce537c commit 446e90c
Show file tree
Hide file tree
Showing 83 changed files with 382 additions and 196 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ gen/
.project
.settings/
*.launch

# generated header files of custom msgs
mros2_msgs/
46 changes: 46 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"files.associations": {
"array": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"utility": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"optional": "cpp",
"string": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"fstream": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}
Empty file.
2 changes: 2 additions & 0 deletions makefiles/Makefile.mros2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ MROS2DIR := $(ROOTDIR)/mros2
INCLUDES += -I$(MROS2DIR)/include
INCLUDES += -I$(MROS2DIR)/mros2_msgs

INCLUDES += -I$(ROOTDIR)/mros2_msgs

APPLDIR += $(MROS2DIR)/src

APPL_CXXOBJS += mros2.o
2 changes: 1 addition & 1 deletion test/build/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ include ${MROS2_MAKEFILEDIR}/Makefile.rtps
include ${MROS2_MAKEFILEDIR}/Makefile.mros2

# asp3-f767zi makefiles include
include ${ASP3_MAKEFILEDIR}/Makefile.mros2
include ${ASP3_MAKEFILEDIR}/Makefile.mros2
16 changes: 15 additions & 1 deletion workspace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ BUILDSPACE := build

BOARDNAME := NODE_F767ZI
BOARDPATH := /media/${USER}/${BOARDNAME}
# BOARDPATH for MAC OS -> BOARDPATH := /Volumes/${BOARDNAME}

MSGDIR := custom_msgs/${msg}
MROS2DIR := ../mros2
HEADERGEN_FILE := $(MROS2DIR)/mros2_header_generator/header_generator.py
TEMPLATESGEN_FILE := $(MROS2DIR)/mros2_header_generator/templates_generator.py

ifdef app
# nothing to do
Expand All @@ -15,6 +21,8 @@ usage:
endif

all: clean

@python $(TEMPLATESGEN_FILE) $(MROS2DIR) $(APPNAME);
@cd $(BUILDSPACE) && make -j4 -f Makefile.common app=${APPNAME}
@cp $(BUILDSPACE)/asp.bin . && cp $(BUILDSPACE)/asp.elf .
@echo "Build complete successfully"
Expand All @@ -26,4 +34,10 @@ all: clean

clean:
@cd $(BUILDSPACE) && make -f Makefile.common clean
rm -f asp.*
rm -f asp.* && rm -f .asp*

gen-msg:
@if [ -f $(MSGDIR)/msg_settings.json ]; then \
python -B $(HEADERGEN_FILE) $(MROS2DIR) $(MSGDIR); \
echo "msg file for ${msg} generated in ${MSGDIR}"; \
fi
37 changes: 17 additions & 20 deletions workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,36 @@ Please also check [mROS-base/mros2-host-examples](https://github.com/mROS-base/m
- `$ ros2 run mros2_echoback_string pub_node`
- `$ ros2 run mros2_echoback_string sub_node`

## echoreply_uint16
## sub_uint16

- Description:
- The mROS 2 node on the embedded board subscribes `uint16` (`std_msgs::msg::UInt16`) message from `/to_stm` topic.
- And then publishes this `uint16` message as it is to `/to_linux` as the reply.
- Host operation:
- `$ ros2 launch mros2_echoback_uint16 launch.py`
- `$ ros2 launch mros2_pub_uint16 launch.py`
- or, at two terminals:
- `$ ros2 run mros2_echoback_uint16 pub_node`
- `$ ros2 run mros2_echoback_uint16 sub_node`
- `$ ros2 run mros2_pub_uint16 pub_node`

## echoreply_float32
## pub_float32

- Description:
- The mROS 2 node on the embedded board subscribes `float32` (`std_msgs::msg::Float32`) message from `/to_stm` topic.
- And then publishes this `float32` message as it is to `/to_linux` as the reply.
- Note that this application just print whether the value of message is less than 0.0, between 0.0 and 1.0, or greater than 1.0, since TOPPERS/ASP3 kernel cannot print float value.
- The mROS 2 node on the embedded board publishes `float32` (`std_msgs::msg::Float32`) message to `/to_linux` topic.
- Host operation:
- `$ ros2 launch mros2_echoback_float32 launch.py`
- `$ ros2 launch mros2_sub_float32 launch.py`
- or, at two terminals:
- `$ ros2 run mros2_echoback_float32 pub_node`
- `$ ros2 run mros2_echoback_float32 sub_node`
- `$ ros2 run mros2_sub_float32 sub_node`

## pub_string
## sub_pose

- Description:
- The mROS 2 node on the embedded board says hello to `/to_linux` as the publication message of `string`.
- Host operation:
- `$ ros2 run mros2_echoback_string pub_node`
- The mROS 2 node on the embedded board subscribes `Pose` (`geometry_msgs::msg::Pose`) message from `cmd_vel` topic.
- `$ ros2 launch mros2_pub_pose launch.py`
- or, at two terminals:
- `$ ros2 run mros2_pub_pose pub_node`

## sub_string
## pub_twist

- Description:
- The mROS 2 node on the embedded board just subscribes `string` message from `/to_stm` topic.
- The mROS 2 node on the embedded board publishes `Twist` (`geometry_msgs::msg::Twist`) message to `cmd_vel` topic.
- Host operation:
- `$ ros2 run mros2_echoback_string sub_node`
- `$ ros2 launch mros2_sub_twist launch.py`
- or, at two terminals:
- `$ ros2 run mros2_sub_twist sub_node`
2 changes: 1 addition & 1 deletion workspace/build/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ include ${MROS2_MAKEFILEDIR}/Makefile.rtps
include ${MROS2_MAKEFILEDIR}/Makefile.mros2

# asp3-f767zi makefiles include
include ${ASP3_MAKEFILEDIR}/Makefile.mros2
include ${ASP3_MAKEFILEDIR}/Makefile.mros2
3 changes: 3 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg/Point.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
float64 x
float64 y
float64 z
2 changes: 2 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg/Pose.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
geometry_msgs/msg/Point position
geometry_msgs/msg/Quaternion orientation
4 changes: 4 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg/Quaternion.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
float64 x
float64 y
float64 z
float64 w
2 changes: 2 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg/Twist.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
geometry_msgs/msg/Vector3 linear
geometry_msgs/msg/Vector3 angular
3 changes: 3 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg/Vector3.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
float64 x
float64 y
float64 z
4 changes: 4 additions & 0 deletions workspace/custom_msgs/geometry_msgs/msg_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pubsubMsgs": [
]
}
26 changes: 0 additions & 26 deletions workspace/echoreply_float32/README.md

This file was deleted.

14 changes: 7 additions & 7 deletions workspace/echoreply_string/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
### string型通信動作確認用アプリ
# echoreply_string app

string型の通信の動作確認をするためのサンプルアプリです。
以下の手順で確認できます。
This is a sample application to publish/subscribe `string` (`std_msgs::msg::String`) message.
Please follow the steps below.

1.workspaceディレクトリにて、`make app=echoreply_string` によりアプリをビルド
1.Execute `make app=echoreply_string` in `workspace` direcroty, then this app will be built.

2.Serial Console (picocomなど) を立ち上げて、初期化
2.Open serial console (ex. picocom) and initialize your micro computer board.

3.hostのros2アプリからstring型のmessageを送信
3.On the host device to communicate with, run `mros2_echoback_string` app (https://github.com/mROS-base/mros2-host-examples) .

4.messageを受信、これを再びhostのros2アプリに向かって送信 (以下)
4.If you get logs below, which means success!!

```
Subscribed msg : Hello, world! 1
Expand Down
4 changes: 2 additions & 2 deletions workspace/echoreply_string/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mros2::Publisher pub;

void userCallback(std_msgs::msg::String *msg)
{
MROS2_INFO("subscribed msg: '%s'", msg->data.c_str());
MROS2_INFO("publishing msg: '%s'", msg->data.c_str());
MROS2_INFO("Subscribed msg : %s", msg->data.c_str());
MROS2_INFO("Publishing msg : %s", msg->data.c_str());
pub.publish(*msg);
}

Expand Down
11 changes: 11 additions & 0 deletions workspace/echoreply_string/templates.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#include "std_msgs/msg/string.hpp"


template mros2::Publisher mros2::Node::create_publisher<std_msgs::msg::String>(std::string topic_name, int qos);
template void mros2::Publisher::publish(std_msgs::msg::String &msg);



template mros2::Subscriber mros2::Node::create_subscription(std::string topic_name, int qos, void (*fp)(std_msgs::msg::String*));
template void mros2::Subscriber::callback_handler<std_msgs::msg::String>(void *callee, const rtps::ReaderCacheChange &cacheChange);
24 changes: 0 additions & 24 deletions workspace/echoreply_uint16/README.md

This file was deleted.

File renamed without changes.
18 changes: 18 additions & 0 deletions workspace/pub_float32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# pub_float32

This is a sample application to publish `float32` (`std_msgs::msg::Float32`) message.
Please follow the steps below.

1.Execute `make app=pub_float32` in `workspace` direcroty, then this app will be built.

2.Open serial console (ex. picocom) and initialize your micro computer board.

3.On the host device to communicate with, run `mros2_sub_float32` app (https://github.com/mROS-base/mros2-host-examples) .

4.If you get logs below, which means success!!
```
publishing float msg!!
publishing float msg!!
...
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,8 @@

#include "stm32f7xx_nucleo_144.h"

mros2::Subscriber sub;
mros2::Publisher pub;

void userCallback(std_msgs::msg::Float32 *msg)
{
if (0.0 >= msg->data) {
MROS2_INFO("msg <= 0.0");
} else if (0.0 < msg->data && msg->data < 0.5) {
MROS2_INFO("0.0 < msg < 0.5");
} else if (0.5 < msg->data && msg->data < 1.0) {
MROS2_INFO("0.5 < msg < 1.0");
} else {
MROS2_INFO("msg >= 1.0");
}
/* TODO: make MROS2_INFO support float type
MROS2_INFO("subscribed msg: '%f'", msg->data);
MROS2_INFO("publishing msg: '%f'", msg->data);
*/
pub.publish(*msg);
}

int main(int argc, char *argv[])
{
MROS2_INFO("mROS 2 application is started");
Expand All @@ -35,10 +16,16 @@ int main(int argc, char *argv[])

mros2::Node node = mros2::Node::create_node("mros2_node");
pub = node.create_publisher<std_msgs::msg::Float32>("to_linux", 10);
sub = node.create_subscription<std_msgs::msg::Float32>("to_stm", 10, userCallback);
std_msgs::msg::Float32 msg;

MROS2_INFO("ready to pub/sub message");

std_msgs::msg::Float32 msg;
auto publish_count = 0;
while (1) {
msg.data = publish_count++/1.0;
MROS2_INFO("publishing float msg!!");
pub.publish(msg);
osDelay(1000);
}
mros2::spin();
BSP_LED_Toggle(LED3);
}
Expand All @@ -51,4 +38,4 @@ void main_task(void)
void led_cyclic_handler(intptr_t exinf)
{
BSP_LED_Toggle(LED2);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions workspace/pub_float32/templates.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "std_msgs/msg/float32.hpp"


template mros2::Publisher mros2::Node::create_publisher<std_msgs::msg::Float32>(std::string topic_name, int qos);
template void mros2::Publisher::publish(std_msgs::msg::Float32 &msg);


Loading

0 comments on commit 446e90c

Please sign in to comment.