LoginSignup
3
3

More than 3 years have passed since last update.

Juliaスクリプトをros2コマンドからrun/launchする方法

Last updated at Posted at 2020-12-05

環境

  • ROS2 Foxy
  • WSL2
  • Julia 1.4.1

ディレクトリ構造

  • hello
    • CmakeLists.txt
    • launch
      • hello.launch
    • script
      • hello.jl

Juliaコード

先頭に#!/bin/juliaを付ける.

script/hello.jl

#!/bin/julia
println("hello")

Cmake

パーミッションを設定することがポイント.

CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
project(hello)

find_package(ament_cmake REQUIRED)

install(FILES
        script/hello.jl DESTINATION share/${PROJECT_NAME}
        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

install(DIRECTORY
        launch
        DESTINATION share/${PROJECT_NAME}
)

ament_package()

launchファイル

launch/hello.launch

<launch>
    <node ns="/hello" pkg="hello" exec="hello.jl" output='screen'/>
</launch>

実行

$colcon build
$ros2 run hello hello.jl
hello
$ros2 launch hello hello.launch

[省略]
[hello.jl-1] hello
[省略]
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3