-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from mROS-base/mturtle_teleop
add `mturtle_teleop` example
- Loading branch information
Showing
16 changed files
with
884 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Makefile definition for mros2 application | ||
# | ||
|
||
# name of main application | ||
APPLNAME = app | ||
|
||
# log level: 0(DEBUG), 1(INFO), 2(WARN), 3(ERROR), 4(FATAL), 5(NONE) | ||
# NOTE: also check `initLogMask` in app.cdl for syslog setting | ||
CDEFS := -DMROS2_LOG_MIN_SEVERITY=0 | ||
|
||
# information for directory tree | ||
APPLDIR := $(APPDIR) | ||
APPLDIR += $(APPDIR)/config | ||
|
||
# link option for C++ code | ||
SRCLANG = c++ | ||
APPL_CXXLIBS += -specs=nano.specs | ||
|
||
# compile switch | ||
CDEFS += -DUSE_ASP3_FOR_STM | ||
|
||
# additional files for configuration | ||
APPL_COBJS := task_impl.o | ||
APPL_COBJS += autosar_os_ext_user_config.o | ||
APPL_COBJS += autosar_os_ext_asp3_user_config.o | ||
APPL_COBJS += mros2_user_config.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# m_turtle_teleop | ||
|
||
This is a sample application along with [turtlesim](https://github.com/mROS-base/ros_tutorials/tree/mros2/foxy-devel/turtlesim) (mros2 version). | ||
|
||
The mROS 2 node on the embedded board publishes `Twist` (`geometry_msgs::msg::Twist`) message to `/turtle1/cmd_vel` topic, according to the input from keyboard via serial console. | ||
|
||
## Generate header files for Twist | ||
|
||
See detail in [<repo_root>/README.md#generating-header-files-for-custom-msgtypes](../README.md#generating-header-files-for-custom-msgtypes). | ||
|
||
## Build and Run for embedded devices | ||
|
||
Make sure to set `app=mturtle_teleop` as `make` option. | ||
|
||
``` | ||
$ pwd | ||
<snip.>/mros2-asp3-f767zi/workspace | ||
$ make app=mturtle_teleop | ||
<snip.> | ||
configuration check passed | ||
make[2]: Leaving directory '/home/takase/ros/mROS2/github/mros2-asp3-f767zi/workspace/build' | ||
make[1]: Leaving directory '/home/takase/ros/mROS2/github/mros2-asp3-f767zi/workspace/build' | ||
Build complete successfully | ||
Copying binary to the board... | ||
### The above message is appeared if the board is already connected to host PC. | ||
### If not, please connect the board and copy the binary manually. | ||
$ cp asp.bin /media/$USER/NODE_F767ZI/ | ||
``` | ||
|
||
## Host operation for native ROS 2 | ||
|
||
Since the current version of does not support the QoS control, the original version of `turtlesim` could not work well with this application. So please use the following repository that is customized for mros2. | ||
|
||
``` | ||
### clone repository and build package | ||
$ cd <your_ros2_ws>/src | ||
$ git clone -b mros2/foxy-devel https://github.com/mROS-base/ros_tutorials | ||
$ cd .. | ||
$ colcon build --packages-select turtlesim | ||
$ source install/local_setup.bash | ||
### run turtlesim node | ||
$ ros2 run turtlesim turtlesim_node | ||
``` | ||
|
||
## Expected output | ||
|
||
### serial console for the baord with mros2 | ||
|
||
``` | ||
$ picocom -b 115200 /dev/ttyACM0 | ||
<snip.> | ||
ready to pub/sub message | ||
keymap to move arround: | ||
------------------ | ||
u i o | ||
j k l | ||
m , . | ||
------------------ | ||
q/z : increase/decrease max speeds by 10 percent | ||
w/x : increase/decrease only linear speed by 10 percent | ||
e/c : increase/decrease only angular speed by 10 percent | ||
currently: speed 0.5000 / turn 1.0000 | ||
[MROS2LIB] Initilizing Domain complete | ||
[MROS2LIB] publisher matched with remote subscriber | ||
publishing Twist msg by 'u' command | ||
publishing Twist msg by 'u' command | ||
publishing Twist msg by 'u' command | ||
<cont.> | ||
``` | ||
|
||
### terminal console on the host | ||
|
||
``` | ||
$ ros2 launch mros2_sub_twist sub.launch.py | ||
<snip.> | ||
[INFO] [1647589190.956007464] [turtlesim]: Starting turtlesim with node name /turtlesim | ||
[INFO] [1647589190.957948401] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000] | ||
[INFO] [1647589195.831260526] [turtlesim]: subscribed Twist msg from mros2 | ||
[INFO] [1647589196.422450459] [turtlesim]: subscribed Twist msg from mros2 | ||
[INFO] [1647589196.934933835] [turtlesim]: subscribed Twist msg from mros2 | ||
<cont.> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* サンプルプログラム(1)のコンポーネント記述ファイル | ||
* | ||
* $Id: sample1.cdl 839 2017-10-17 02:48:52Z ertl-hiro $ | ||
*/ | ||
/* | ||
* カーネルオブジェクトの定義 | ||
*/ | ||
import(<kernel.cdl>); | ||
|
||
/* | ||
* ターゲット非依存のセルタイプの定義 | ||
*/ | ||
import("syssvc/tSerialPort.cdl"); | ||
import("syssvc/tSerialAdapter.cdl"); | ||
import("syssvc/tSysLog.cdl"); | ||
import("syssvc/tSysLogAdapter.cdl"); | ||
import("syssvc/tLogTask.cdl"); | ||
import("syssvc/tBanner.cdl"); | ||
|
||
/* | ||
* ターゲット依存部の取り込み | ||
*/ | ||
import("target.cdl"); | ||
|
||
/* | ||
* 「セルの組上げ記述」とは,"cell"で始まる行から,それに対応する"};" | ||
* の行までのことを言う. | ||
*/ | ||
|
||
/* | ||
* システムログ機能のアダプタの組上げ記述 | ||
* | ||
* システムログ機能のアダプタは,C言語で記述されたコードから,TECSベー | ||
* スのシステムログ機能を呼び出すためのセルである.システムログ機能の | ||
* サービスコール(syslog,syslog_0〜syslog_5,t_perrorを含む)を呼び | ||
* 出さない場合には,以下のセルの組上げ記述を削除してよい. | ||
*/ | ||
cell tSysLogAdapter SysLogAdapter { | ||
cSysLog = SysLog.eSysLog; | ||
}; | ||
|
||
/* | ||
* シリアルインタフェースドライバのアダプタの組上げ記述 | ||
* | ||
* シリアルインタフェースドライバのアダプタは,C言語で記述されたコー | ||
* ドから,TECSベースのシリアルインタフェースドライバを呼び出すための | ||
* セルである.シリアルインタフェースドライバのサービスコールを呼び出 | ||
* さない場合には,以下のセルの組上げ記述を削除してよい. | ||
*/ | ||
cell tSerialAdapter SerialAdapter { | ||
cSerialPort[0] = SerialPort1.eSerialPort; | ||
}; | ||
|
||
/* | ||
* システムログ機能の組上げ記述 | ||
* | ||
* システムログ機能を外す場合には,以下のセルの組上げ記述を削除し,コ | ||
* ンパイルオプションに-DTOPPERS_OMIT_SYSLOGを追加すればよい.ただし, | ||
* システムログタスクはシステムログ機能を使用するため,それも外すこと | ||
* が必要である.また,システムログ機能のアダプタも外さなければならな | ||
* い.tecsgenが警告メッセージを出すが,無視してよい. | ||
*/ | ||
cell tSysLog SysLog { | ||
logBufferSize = 32; /* ログバッファのサイズ */ | ||
initLogMask = C_EXP("LOG_UPTO(LOG_DEBUG)"); | ||
/* ログバッファに記録すべき重要度 */ | ||
initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)"); | ||
/* 低レベル出力すべき重要度 */ | ||
/* 低レベル出力との結合 */ | ||
cPutLog = PutLogTarget.ePutLog; | ||
}; | ||
|
||
/* | ||
* シリアルインタフェースドライバの組上げ記述 | ||
* | ||
* シリアルインタフェースドライバを外す場合には,以下のセルの組上げ記 | ||
* 述を削除すればよい.ただし,システムログタスクはシリアルインタフェー | ||
* スドライバを使用するため,それも外すことが必要である.また,シリア | ||
* ルインタフェースドライバのアダプタも外さなければならない. | ||
*/ | ||
cell tSerialPort SerialPort1 { | ||
receiveBufferSize = 256; /* 受信バッファのサイズ */ | ||
sendBufferSize = 256; /* 送信バッファのサイズ */ | ||
|
||
/* ターゲット依存部との結合 */ | ||
cSIOPort = SIOPortTarget1.eSIOPort; | ||
eiSIOCBR <= SIOPortTarget1.ciSIOCBR; /* コールバック */ | ||
}; | ||
|
||
/* | ||
* システムログタスクの組上げ記述 | ||
* | ||
* システムログタスクを外す場合には,以下のセルの組上げ記述を削除すれ | ||
* ばよい. | ||
*/ | ||
cell tLogTask LogTask { | ||
priority = 3; /* システムログタスクの優先度 */ | ||
stackSize = LogTaskStackSize; /* システムログタスクのスタックサイズ */ | ||
|
||
/* シリアルインタフェースドライバとの結合 */ | ||
cSerialPort = SerialPort1.eSerialPort; | ||
cnSerialPortManage = SerialPort1.enSerialPortManage; | ||
|
||
/* システムログ機能との結合 */ | ||
cSysLog = SysLog.eSysLog; | ||
|
||
/* 低レベル出力との結合 */ | ||
cPutLog = PutLogTarget.ePutLog; | ||
}; | ||
|
||
/* | ||
* カーネル起動メッセージ出力の組上げ記述 | ||
* | ||
* カーネル起動メッセージの出力を外す場合には,以下のセルの組上げ記述 | ||
* を削除すればよい. | ||
*/ | ||
cell tBanner Banner { | ||
/* 属性の設定 */ | ||
targetName = BannerTargetName; | ||
copyrightNotice = BannerCopyrightNotice; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* サンプルプログラム(1)のシステムコンフィギュレーションファイル | ||
*/ | ||
INCLUDE("tecsgen.cfg"); | ||
INCLUDE("asp3ext.cfg"); | ||
INCLUDE("task.cfg"); | ||
|
||
#include "app.h" | ||
#include "stm32f7xx_it.h" | ||
CRE_TSK(MAIN_TASK, { TA_ACT, 0, main_task, MAIN_PRIORITY, STACK_SIZE, NULL }); | ||
CRE_TSK(TELEOP_TASK, { TA_NULL, 0, teleop_task, MID_PRIORITY, STACK_SIZE, NULL }); | ||
CRE_ISR(ETH_IRQ_HANDLER, { TA_NULL, 0, 77, ETH_IRQHandler, 1 }); | ||
CFG_INT(77, {TA_EDGE, -4}); | ||
|
||
CRE_CYC(LED_CYCHDR, { TA_STA, { TNFY_HANDLER, 0, led_cyclic_handler }, 1000000, 0 }); |
Oops, something went wrong.