Skip to content
Open
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
163 changes: 0 additions & 163 deletions CMakeLists.txt~

This file was deleted.

17 changes: 1 addition & 16 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>


<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/cloud_ros</url> -->


<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->


<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<build_depend>message_generation</build_depend>
<!-- Use buildtool_depend for build tool packages: -->
Expand All @@ -43,6 +27,7 @@
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>python3-websocket</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
Expand Down
56 changes: 0 additions & 56 deletions package.xml~

This file was deleted.

Binary file added src/__pycache__/roscommands.cpython-38.pyc
Binary file not shown.
Binary file added src/__pycache__/rosrun.cpython-38.pyc
Binary file not shown.
Binary file added src/__pycache__/rosservice.cpython-38.pyc
Binary file not shown.
Binary file added src/__pycache__/rostopic.cpython-38.pyc
Binary file not shown.
94 changes: 94 additions & 0 deletions src/boolean_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/python3

import time
import locale
import curses
import sys
from pySpacebrew.spacebrew import Spacebrew

# set the encoding to use for the terminal string
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()

# initialize the terminal display
stdscr = curses.initscr()
stdscr.keypad(1)
curses.noecho() # turn off echo
curses.curs_set(0) # turn off cursor

# set-up a variables to hold coordinates
pos_state = 15
local_state = False
remote_state = False

# get app name and server from query string
name = "pyBoolean Example"
# server = "sandbox.spacebrew.cc"
server = "forever-spacebrew.herokuapp.com/"

for cur_ele in sys.argv:
if "name" in cur_ele:
name = cur_ele[5:]
if "server" in cur_ele:
server = cur_ele[7:]


# configure the spacebrew client
brew = Spacebrew(name=name, server=server)
brew.addPublisher("local state", "boolean")
brew.addSubscriber("remote state", "boolean")


def handleBoolean(value):
global code, stdscr
stdscr.addstr(pos_remote, pos_state, (str(value) + " ").encode(code))
stdscr.refresh()


brew.subscribe("remote state", handleBoolean)

try:
# start-up spacebrew
brew.start()

# create and load info message at the top of the terminal window
info_msg = "This is the pySpacebrew library boolean example. It sends out a boolean message every time\n"
info_msg += "the enter or return key is pressed and displays the latest boolean value it has received.\n"
info_msg += "Connected to Spacebrew as: " + name + "\n"
info_msg += "IMPORTANT: don't shrink the Terminal window as it may cause app to crash (bug with curses lib)."
stdscr.addstr(0, 0, info_msg.encode(code))
stdscr.refresh()

# update the location for the remote and local dice state
pos_local = stdscr.getyx()[0] + 2
pos_remote = pos_local + 2

# display the label for the remote and local boolean states
stdscr.addstr(pos_local, 0, "local state: ".encode(code), curses.A_BOLD)
stdscr.addstr(pos_remote, 0, "remote state: ".encode(code), curses.A_BOLD)

# display the starting state for remote and local boolean states
stdscr.addstr(pos_local, pos_state, (str(local_state) + " ").encode(code))
stdscr.addstr(pos_remote, pos_state,
(str(remote_state) + " ").encode(code))
stdscr.refresh()

# listen for keypresses and handle input
while 1:
c = stdscr.getch()
local_state = not local_state
brew.publish('local state', True)

if (c == 10 or c == 13):
stdscr.addstr(pos_local, pos_state,
(str(local_state) + " ").encode(code))

stdscr.refresh()

# closing out the app and returning terminal to old settings
finally:
brew.stop()
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
Loading