Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A GUI for configuring launch-files #253

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions clover/launch/aruco.launch
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<launch>
<arg name="aruco_detect" default="true"/>
<arg name="aruco_map" default="false"/>
<arg name="aruco_vpe" default="false"/>
<arg name="aruco_detect" default="false"/> <!-- markers recognition enabled -->
<arg name="aruco_map" default="false"/> <!-- markers map recognition enabled -->
<arg name="aruco_vpe" default="false"/> <!-- markers map positioning enabled -->
<arg name="placement" default="floor"/> <!-- markers placement: floor, ceiling, unknown -->
<arg name="length" default="0.33"/> <!-- not-in-map markers length, m -->
<arg name="map" default="map.txt"/> <!-- markers map file name -->

<!-- For additional help go to https://clover.coex.tech/aruco -->

Expand All @@ -12,8 +15,9 @@
<remap from="map_markers" to="aruco_map/markers" if="$(arg aruco_map)"/>
<param name="estimate_poses" value="true"/>
<param name="send_tf" value="true"/>
<param name="known_tilt" value="map"/>
<param name="length" value="0.33"/>
<param name="known_tilt" value="map" if="$(eval placement == 'floor')"/>
<param name="known_tilt" value="map_flipped" if="$(eval position == 'ceiling')"/>
<param name="length" value="$(arg length)"/>
<!-- aruco detector parameters -->
<param name="cornerRefinementMethod" value="2"/> <!-- contour refinement -->
<param name="minMarkerPerimeterRate" value="0.075"/> <!-- 0.075 for 320x240, 0.0375 for 640x480 -->
Expand All @@ -24,8 +28,9 @@
<remap from="image_raw" to="main_camera/image_raw"/>
<remap from="camera_info" to="main_camera/camera_info"/>
<remap from="markers" to="aruco_detect/markers"/>
<param name="map" value="$(find aruco_pose)/map/map.txt"/>
<param name="known_tilt" value="map"/>
<param name="map" value="$(find aruco_pose)/map/$(arg map)"/>
<param name="known_tilt" value="map" if="$(eval placement == 'floor')"/>
<param name="known_tilt" value="map_flipped" if="$(eval placement == 'ceiling')"/>
<param name="image_axis" value="true"/>
<param name="frame_id" value="aruco_map_detected" if="$(arg aruco_vpe)"/>
<param name="frame_id" value="aruco_map" unless="$(arg aruco_vpe)"/>
Expand Down
32 changes: 19 additions & 13 deletions clover/launch/clover.launch
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<launch>
<arg name="fcu_conn" default="usb"/>
<arg name="fcu_ip" default="127.0.0.1"/>
<arg name="fcu_sys_id" default="1"/>
<arg name="gcs_bridge" default="tcp"/>
<arg name="web_video_server" default="true"/>
<arg name="rosbridge" default="true"/>
<arg name="main_camera" default="true"/>
<arg name="optical_flow" default="true"/>
<arg name="aruco" default="false"/>
<arg name="rangefinder_vl53l1x" default="true"/>
<arg name="led" default="true"/>
<arg name="rc" default="true"/>
<arg name="fcu_conn" default="usb"/> <!-- FCU connection type: usb, uart, tcp, udp, sitl -->
<arg name="fcu_ip" default="127.0.0.1"/> <!-- FCU IP adddress (if using TCP/UDP) -->
<arg name="fcu_sys_id" default="1"/> <!-- MAVLink system ID, noeditor -->
<arg name="gcs_bridge" default="tcp"/> <!-- GCS bridge type: tcp, udp, udp-b, udp-pb -->
<arg name="web_video_server" default="true"/> <!-- web video server enabled -->
<arg name="rosbridge" default="true"/> <!-- rosbridge_suite enabled, noeditor -->
<arg name="main_camera" default="true"/> <!-- main camera enabled -->
<arg name="optical_flow" default="true"/> <!-- optical flow enabled -->
<arg name="rangefinder_vl53l1x" default="true"/> <!-- VL53l1X rangefinder enabled -->
<arg name="led" default="true"/> <!-- LED strip driver enabled -->
<arg name="rc" default="true"/> <!-- support for mobile RC enabled -->
<arg name="shell" default="true"/>

<!-- log formatting -->
Expand All @@ -31,7 +30,7 @@
</node>

<!-- aruco markers -->
<include file="$(find clover)/launch/aruco.launch" if="$(arg aruco)"/>
<include file="$(find clover)/launch/aruco.launch"/>

<!-- optical flow -->
<node pkg="nodelet" type="nodelet" name="optical_flow" args="load clover/optical_flow nodelet_manager" if="$(arg optical_flow)" clear_params="true" output="screen">
Expand Down Expand Up @@ -87,4 +86,11 @@
<node pkg="roswww_static" name="roswww_static" type="main.py" clear_params="true">
<param name="default_package" value="clover"/>
</node>

<!-- roslaunch editor parameters -->
<group ns="roslaunch_editor">
<param name="items" type="yaml" value="[clover/clover.launch, clover/main_camera.launch, clover/aruco.launch, clover/led.launch]"/>
<param name="apply_command" value="sudo systemctl restart clover"/>
<param name="hide_uncommented" value="true"/>
</group>
</launch>
11 changes: 7 additions & 4 deletions clover/launch/led.launch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<launch>
<arg name="ws281x" default="true"/>
<arg name="led_effect" default="true"/>
<arg name="led_notify" default="true"/>
<arg name="ws281x" default="true"/> <!-- LED strip driver enabled -->
<arg name="led_effect" default="true"/> <!-- LED effect API enabled -->
<arg name="led_notify" default="all"/> <!-- LED strip notifications: all, battery, none -->

<!-- For additional help go to https://clover.coex.tech/led -->

Expand All @@ -22,7 +22,7 @@
<param name="fade_period" value="0.5"/>
<param name="rainbow_period" value="5"/>
<!-- events effects table -->
<rosparam param="notify" if="$(arg led_notify)">
<rosparam param="notify" if="$(eval led_notify == 'all')">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could have a set of default notifications and append to it somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't completely get what you mean.

startup: { r: 255, g: 255, b: 255 }
connected: { effect: rainbow }
disconnected: { effect: blink, r: 255, g: 50, b: 50 }
Expand All @@ -34,5 +34,8 @@
low_battery: { threshold: 3.7, effect: blink_fast, r: 255, g: 0, b: 0 }
error: { effect: flash, r: 255, g: 0, b: 0 }
</rosparam>
<rosparam param="notify" if="$(eval led_notify == 'battery')">
low_battery: { threshold: 3.7, effect: blink_fast, r: 255, g: 0, b: 0 }
</rosparam>
</node>
</launch>
82 changes: 82 additions & 0 deletions roslaunch_editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
cmake_minimum_required(VERSION 2.8.3)
project(roslaunch_editor)

find_package(catkin REQUIRED COMPONENTS message_generation)

add_message_files(
FILES
LaunchFile.msg
)

add_service_files(
FILES
ReadLaunchFiles.srv
WriteLaunchFiles.srv
)

generate_messages(
DEPENDENCIES
# std_msgs # Or other packages containing msgs
)

catkin_package(
# INCLUDE_DIRS include
# LIBRARIES roslaunch_editor
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really want to add something like catkin_install_python here.

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_roslaunch_editor.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
28 changes: 28 additions & 0 deletions roslaunch_editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# roslaunch_editor

Web-based ROS launch-files editor, created for making configuration of your robot more user-friendly for novices.

<img src="roslaunch_editor.jpg" width=450>

## Quick launch

```bash
roslaunch roslaunch_editor example.launch
```

Then, open `http://localhost:8085/roslaunch_editor/` and edit the test launch file.

## Modes

`roslaunch_editor` works in two modes: standalone mode (where running `editor` node is required), and Clover mode (where `clover`'s `shell` node, `roswww_static` and `rosbridge_suite` are utilized). The editor will read and write launch-files and restart the nodes (if configured) using one of these nodes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'd prefer a single (standalone) mode. We've discussed shell before, and even though I understand its usefulness, I'm not in favor of it being used.


The mode is determined automatically, based on advertised ROS-services.

## Parameters

* `items` (`string` or `list`) – launch files to edit, format: `package_name/launch_file_name.launch`.
* `hide_uncommented` (`boolean`, default: `false`) – don't show arguments without comments.
* `apply_command` (`string`, default: `''`) – shell command to execute after writing launch-files (e. g. to restart the systemd service).
* `backup` (`boolean`, default: `false`) – backup overwritten launch-files (backup is written to `file_name.launch.bak`).

Some parameters (`items`, `hide_uncommented`) can be overwritten over GET-parameters, e. g. `?items=package/foo.launch,package/bar.launch&hide_uncommented=1`.
11 changes: 11 additions & 0 deletions roslaunch_editor/launch/example.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<launch>
<include file="$(find roswww)/launch/roswww.launch"/>

<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch"/>

<node name="roslaunch_editor" pkg="roslaunch_editor" type="editor">
<param name="items" type="yaml" value="[roslaunch_editor/test.launch]"/>
<param name="reference_frames/base_link" value="map"/>
<param name="reference_frames/navigate_target" value="map"/>
</node>
</launch>
3 changes: 3 additions & 0 deletions roslaunch_editor/msg/LaunchFile.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string package
string name
string content
45 changes: 45 additions & 0 deletions roslaunch_editor/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<package format="2">
<name>roslaunch_editor</name>
<version>0.0.0</version>
<description>Web based roslaunch files editor</description>
<maintainer email="[email protected]">Oleg Kalachev</maintainer>
<license>MIT</license>

<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<url type="repository">https://github.com/CopterExpress/clover</url>

<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<author email="[email protected]">Oleg Kalachev</author>

<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<depend>message_generation</depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

</export>
</package>
Binary file added roslaunch_editor/roslaunch_editor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions roslaunch_editor/src/editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python

import rospy
import os
import shutil
import rospkg

from std_srvs.srv import Trigger
from roslaunch_editor.srv import ReadLaunchFiles, ReadLaunchFilesResponse, WriteLaunchFiles
from roslaunch_editor.msg import LaunchFile

rospy.init_node('roslaunch_editor')
rospack = rospkg.RosPack()
backup = rospy.get_param('~backup', True)
apply_command = rospy.get_param('~apply_command', '')


def get_launch_file_path(package, name):
path = rospack.get_path(package)
for root, dirnames, filenames in os.walk(path):
if name in filenames:
return os.path.join(root, name)
raise Exception('Launch file %s/%s not found' % (package, name))


def read(req):
try:
res = ReadLaunchFilesResponse()
for launch_file in req.files:
path = get_launch_file_path(launch_file.package, launch_file.name)
rospy.loginfo('read file %s', path)
launch_file.content = open(path, 'r').read()
res.files.append(launch_file)
res.success = True
return res
except Exception as e:
rospy.logerr(str(e))
return {'success': False, 'message': str(e)}


def write(req):
try:
# write files
for launch_file in req.files:
if not launch_file.name.endswith('.launch'):
raise Exception('Launch file name should end with .launch')
path = get_launch_file_path(launch_file.package, launch_file.name)
rospy.loginfo('write file %s', path)
if backup:
shutil.copyfile(path, path + '.bak.launch')
with open(path, 'w') as f:
f.write(launch_file.content)

# restart the system
if not apply_command:
return {'success': True}

rospy.loginfo('apply: %s', apply_command)
res = os.system(apply_command)
if res == 0:
return {'success': True}
else:
return {'success': False, 'message': 'Error invoking %s' % apply_command}
except Exception as e:
rospy.logerr(str(e))
return {'success': False, 'message': str(e)}


rospy.Service('~read', ReadLaunchFiles, read)
rospy.Service('~write', WriteLaunchFiles, write)


rospy.spin()
7 changes: 7 additions & 0 deletions roslaunch_editor/srv/ReadLaunchFiles.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Read launch-files

LaunchFile[] files # content field is ignored
---
bool success
string message
LaunchFile[] files
6 changes: 6 additions & 0 deletions roslaunch_editor/srv/WriteLaunchFiles.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Write launch-files and apply (restart the system)

LaunchFile[] files
---
bool success
string message
Loading