-
Notifications
You must be signed in to change notification settings - Fork 266
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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} | ||
# ) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You really want to add something like |
||
############# | ||
## 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) |
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I'd prefer a single (standalone) mode. We've discussed |
||
|
||
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`. |
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
string package | ||
string name | ||
string content |
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> |
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() |
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 |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.