Skip to content

Commit 6d3aa67

Browse files
committed
create a session
0 parents  commit 6d3aa67

File tree

7 files changed

+325
-0
lines changed

7 files changed

+325
-0
lines changed

CMakeLists.txt

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(catmux)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
# add_compile_options(-std=c++11)
6+
7+
## Find catkin macros and libraries
8+
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9+
## is used, also find other catkin packages
10+
find_package(catkin REQUIRED COMPONENTS
11+
catkin_pkg rospy
12+
)
13+
14+
## System dependencies are found with CMake's conventions
15+
# find_package(Boost REQUIRED COMPONENTS system)
16+
17+
## Uncomment this if the package has a setup.py. This macro ensures
18+
## modules and global scripts declared therein get installed
19+
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
20+
catkin_python_setup()
21+
22+
################################################
23+
## Declare ROS messages, services and actions ##
24+
################################################
25+
26+
## To declare and build messages, services or actions from within this
27+
## package, follow these steps:
28+
## * Let MSG_DEP_SET be the set of packages whose message types you use in
29+
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
30+
## * In the file package.xml:
31+
## * add a build_depend tag for "message_generation"
32+
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
33+
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
34+
## but can be declared for certainty nonetheless:
35+
## * add a run_depend tag for "message_runtime"
36+
## * In this file (CMakeLists.txt):
37+
## * add "message_generation" and every package in MSG_DEP_SET to
38+
## find_package(catkin REQUIRED COMPONENTS ...)
39+
## * add "message_runtime" and every package in MSG_DEP_SET to
40+
## catkin_package(CATKIN_DEPENDS ...)
41+
## * uncomment the add_*_files sections below as needed
42+
## and list every .msg/.srv/.action file to be processed
43+
## * uncomment the generate_messages entry below
44+
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
45+
46+
## Generate messages in the 'msg' folder
47+
# add_message_files(
48+
# FILES
49+
# Message1.msg
50+
# Message2.msg
51+
# )
52+
53+
## Generate services in the 'srv' folder
54+
# add_service_files(
55+
# FILES
56+
# Service1.srv
57+
# Service2.srv
58+
# )
59+
60+
## Generate actions in the 'action' folder
61+
# add_action_files(
62+
# FILES
63+
# Action1.action
64+
# Action2.action
65+
# )
66+
67+
## Generate added messages and services with any dependencies listed here
68+
# generate_messages(
69+
# DEPENDENCIES
70+
# std_msgs # Or other packages containing msgs
71+
# )
72+
73+
################################################
74+
## Declare ROS dynamic reconfigure parameters ##
75+
################################################
76+
77+
## To declare and build dynamic reconfigure parameters within this
78+
## package, follow these steps:
79+
## * In the file package.xml:
80+
## * add a build_depend and a run_depend tag for "dynamic_reconfigure"
81+
## * In this file (CMakeLists.txt):
82+
## * add "dynamic_reconfigure" to
83+
## find_package(catkin REQUIRED COMPONENTS ...)
84+
## * uncomment the "generate_dynamic_reconfigure_options" section below
85+
## and list every .cfg file to be processed
86+
87+
## Generate dynamic reconfigure parameters in the 'cfg' folder
88+
# generate_dynamic_reconfigure_options(
89+
# cfg/DynReconf1.cfg
90+
# cfg/DynReconf2.cfg
91+
# )
92+
93+
###################################
94+
## catkin specific configuration ##
95+
###################################
96+
## The catkin_package macro generates cmake config files for your package
97+
## Declare things to be passed to dependent projects
98+
## INCLUDE_DIRS: uncomment this if your package contains header files
99+
## LIBRARIES: libraries you create in this project that dependent projects also need
100+
## CATKIN_DEPENDS: catkin_packages dependent projects also need
101+
## DEPENDS: system dependencies of this project that dependent projects also need
102+
catkin_package(
103+
CATKIN_DEPENDS
104+
catkin_pkg rospy
105+
)
106+
107+
###########
108+
## Build ##
109+
###########
110+
111+
## Specify additional locations of header files
112+
## Your package locations should be listed before other locations
113+
include_directories(
114+
# include
115+
${catkin_INCLUDE_DIRS}
116+
)
117+
118+
## Declare a C++ library
119+
# add_library(${PROJECT_NAME}
120+
# src/${PROJECT_NAME}/catmux.cpp
121+
# )
122+
123+
## Add cmake target dependencies of the library
124+
## as an example, code may need to be generated before libraries
125+
## either from message generation or dynamic reconfigure
126+
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
127+
128+
## Declare a C++ executable
129+
## With catkin_make all packages are built within a single CMake context
130+
## The recommended prefix ensures that target names across packages don't collide
131+
# add_executable(${PROJECT_NAME}_node src/catmux_node.cpp)
132+
133+
## Rename C++ executable without prefix
134+
## The above recommended prefix causes long target names, the following renames the
135+
## target back to the shorter version for ease of user use
136+
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
137+
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
138+
139+
## Add cmake target dependencies of the executable
140+
## same as for the library above
141+
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
142+
143+
## Specify libraries to link a library or executable target against
144+
# target_link_libraries(${PROJECT_NAME}_node
145+
# ${catkin_LIBRARIES}
146+
# )
147+
148+
#############
149+
## Install ##
150+
#############
151+
152+
# all install targets should use catkin DESTINATION variables
153+
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
154+
155+
## Mark executable scripts (Python etc.) for installation
156+
## in contrast to setup.py, you can choose the destination
157+
158+
159+
## Mark executables and/or libraries for installation
160+
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
161+
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
162+
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
163+
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
164+
# )
165+
166+
## Mark cpp header files for installation
167+
# install(DIRECTORY include/${PROJECT_NAME}/
168+
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
169+
# FILES_MATCHING PATTERN "*.h"
170+
# PATTERN ".svn" EXCLUDE
171+
# )
172+
173+
## Mark other files for installation (e.g. launch and bag files, etc.)
174+
# install(FILES
175+
# # myfile1
176+
# # myfile2
177+
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
178+
# )
179+
180+
#############
181+
## Testing ##
182+
#############
183+
184+
## Add gtest based cpp test target and link libraries
185+
# catkin_add_gtest(${PROJECT_NAME}-test test/test_catmux.cpp)
186+
# if(TARGET ${PROJECT_NAME}-test)
187+
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
188+
# endif()
189+
190+
## Add folders to be run by python nosetests
191+
# catkin_add_nosetests(test)
192+
catkin_install_python(PROGRAMS script/create_session
193+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

etc/tmux_default.conf

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
run-shell ~/.tmux/plugins/tmux-yank/yank.tmux
2+
3+
# Get almost perfect use of mouse. Remember to press shift for select and paste
4+
set -g mouse on
5+
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M; send-keys -M; send-keys -M; send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M; send-keys -M; send-keys -M; send-keys -M' 'copy-mode -e; send-keys -M; send-keys -M; send-keys -M; send-keys -M'"
6+
bind -n WheelDownPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M; send-keys -M; send-keys -M; send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M; send-keys -M; send-keys -M; send-keys -M' 'copy-mode -e; send-keys -M; send-keys -M; send-keys -M; send-keys -M'"
7+
8+
# Use CTRL-left/right for word navigation
9+
set-window-option -g xterm-keys on
10+
11+
12+
set-window-option -g window-status-current-bg red
13+
set-window-option -g window-status-current-bg red
14+
15+
# Use Alt-arrow keys without prefix key to switch panes
16+
bind -n M-Left select-pane -L
17+
bind -n M-Right select-pane -R
18+
bind -n M-Up select-pane -U
19+
bind -n M-Down select-pane -D
20+
21+
# easily toggle synchronization (mnemonic: e is for echo)
22+
# sends input to all panes in a given window.
23+
bind e setw synchronize-panes on
24+
bind E setw synchronize-panes off
25+
bind-key h select-pane -L
26+
bind-key l select-pane -R
27+
bind-key j select-pane -D
28+
bind-key k select-pane -U
29+
bind-key K confirm-before kill-session
30+
31+
set -g history-limit 99999

package.xml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
<name>catmux</name>
4+
<version>0.0.0</version>
5+
<description>The catmux package</description>
6+
7+
<!-- One maintainer tag required, multiple allowed, one person per tag -->
8+
<!-- Example: -->
9+
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
10+
<maintainer email="[email protected]">Felix Mauch</maintainer>
11+
12+
<!-- One license tag required, multiple allowed, one license per tag -->
13+
<!-- Commonly used license strings: -->
14+
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
15+
<license>TODO</license>
16+
17+
<!-- Url tags are optional, but multiple are allowed, one per tag -->
18+
<!-- Optional attribute type can be: website, bugtracker, or repository -->
19+
<!-- Example: -->
20+
<!-- <url type="website">http://wiki.ros.org/catmux</url> -->
21+
22+
<!-- Author tags are optional, multiple are allowed, one per tag -->
23+
<!-- Authors do not have to be maintainers, but could be -->
24+
<!-- Example: -->
25+
<!-- <author email="[email protected]">Jane Doe</author> -->
26+
27+
<!-- The *depend tags are used to specify dependencies -->
28+
<!-- Dependencies can be catkin packages or system dependencies -->
29+
<!-- Examples: -->
30+
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
31+
<!-- <depend>roscpp</depend> -->
32+
<!-- Note that this is equivalent to the following: -->
33+
<!-- <build_depend>roscpp</build_depend> -->
34+
<!-- <exec_depend>roscpp</exec_depend> -->
35+
<!-- Use build_depend for packages you need at compile time: -->
36+
<!-- <build_depend>message_generation</build_depend> -->
37+
<!-- Use build_export_depend for packages you need in order to build against this package: -->
38+
<!-- <build_export_depend>message_generation</build_export_depend> -->
39+
<!-- Use buildtool_depend for build tool packages: -->
40+
<!-- <buildtool_depend>catkin</buildtool_depend> -->
41+
<!-- Use exec_depend for packages you need at runtime: -->
42+
<!-- <exec_depend>message_runtime</exec_depend> -->
43+
<!-- Use test_depend for packages you need only for testing: -->
44+
<!-- <test_depend>gtest</test_depend> -->
45+
<!-- Use doc_depend for packages you need only for building documentation: -->
46+
<!-- <doc_depend>doxygen</doc_depend> -->
47+
<buildtool_depend>catkin</buildtool_depend>
48+
<build_depend>catkin_pkg</build_depend>
49+
<build_depend>rospy</build_depend>
50+
<exec_depend>catkin_pkg</exec_depend>
51+
<exec_depend>rospy</exec_depend>
52+
<exec_depend>tmux</exec_depend>
53+
54+
<!-- The export tag contains other, unspecified, tags -->
55+
<export>
56+
<!-- Other tools can request additional information be placed here -->
57+
58+
</export>
59+
</package>

script/create_session

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
from __future__ import print_function
3+
import subprocess
4+
import sys
5+
6+
import rospy
7+
8+
def safe_call(cmd_list):
9+
"""Makes a subprocess check_call and outputs a clear error message on failure and then exits"""
10+
try:
11+
subprocess.check_output(cmd_list)
12+
return True
13+
except subprocess.CalledProcessError as err_thrown:
14+
rospy.logerr('Error while calling "%s"', err_thrown.cmd)
15+
return False
16+
17+
def main():
18+
"""Creates a new tmux session if it does not yet exist"""
19+
rospy.init_node('create_catmux_session', anonymous=True)
20+
session_name = rospy.get_param('~session_name', 'catmux')
21+
if safe_call(['tmux', 'has-session', '-t', session_name]):
22+
rospy.logwarn('Session with name "%s" already exists. Not overwriting session.',
23+
session_name)
24+
sys.exit(0)
25+
26+
if not safe_call(['tmux', 'new-session', '-s', session_name, '-d']):
27+
sys.exit(1)
28+
29+
if __name__ == "__main__":
30+
main()

setup.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
3+
from distutils.core import setup
4+
from catkin_pkg.python_setup import generate_distutils_setup
5+
6+
package_info = generate_distutils_setup(
7+
packages=['catmux'],
8+
scripts=['script/create_session'],
9+
package_dir={'': 'src'}
10+
)
11+
12+
setup(**package_info)

src/catmux/__init__.py

Whitespace-only changes.

src/catmux/catmux.py

Whitespace-only changes.

0 commit comments

Comments
 (0)