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

[jsk_network_tools] Add dynamic_reconfigure interface to specify bandwidth of highspeed streamer #828

Merged
merged 1 commit into from
Mar 22, 2015
Merged
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
8 changes: 6 additions & 2 deletions jsk_network_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 2.8.3)
project(jsk_network_tools)

find_package(catkin REQUIRED COMPONENTS message_generation std_msgs sensor_msgs rostest)
find_package(catkin REQUIRED COMPONENTS
message_generation std_msgs sensor_msgs rostest
dynamic_reconfigure)
catkin_python_setup()
add_message_files(
DIRECTORY msg
Expand All @@ -15,7 +17,9 @@ add_message_files(
OpenNISample.msg
AllTypeTest.msg
)

generate_dynamic_reconfigure_options(
cfg/SilverhammerHighspeedStreamer.cfg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
Expand Down
20 changes: 20 additions & 0 deletions jsk_network_tools/cfg/SilverhammerHighspeedStreamer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

# set up parameters that we care about
PACKAGE = 'jsk_network_tools'

try:
import imp
imp.find_module(PACKAGE)
from dynamic_reconfigure.parameter_generator_catkin import *;
except:
import roslib; roslib.load_manifest(PACKAGE)
from dynamic_reconfigure.parameter_generator import *;

from math import pi

gen = ParameterGenerator ()
# 1kbps ~ 1Gbps
gen.add("bandwidth", int_t, 0, "Expected bandwisth in bits", 250 * 1000 * 1000, 1000, 1000 * 1000 * 1000)

exit (gen.generate (PACKAGE, PACKAGE, "SilverhammerHighspeedStreamer"))
3 changes: 2 additions & 1 deletion jsk_network_tools/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
<build_depend>rostest</build_depend>
<build_depend>diagnostic_msgs</build_depend>
<build_depend>diagnostic_updater</build_depend>

<build_depend>dynamic_reconfigure</build_depend>
<run_depend>std_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>diagnostic_msgs</run_depend>
<run_depend>diagnostic_updater</run_depend>
<run_depend>dynamic_reconfigure</run_depend>
</package>
8 changes: 6 additions & 2 deletions jsk_network_tools/scripts/silverhammer_highspeed_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import roslib
from roslib.message import get_message_class
from std_msgs.msg import Time
from dynamic_reconfigure.server import Server
from jsk_network_tools.cfg import SilverHammerStreamerConfig

class SilverHammerStreamer:
def __init__(self):
Expand All @@ -22,6 +24,7 @@ def __init__(self):
except:
raise Exception("invalid topic type: %s"%message_class_str)
self.lock = Lock()
self.dynamic_reconfigure = Server(SilverHammerStreamerConfig, self.dynamicReconfigureCallback)
self.launched_time = rospy.Time.now()
self.packet_interval = None
self.diagnostic_updater = diagnostic_updater.Updater()
Expand All @@ -36,8 +39,6 @@ def __init__(self):
self.last_input_received_time_pub = rospy.Publisher(
"~last_input_received_time", Time)
self.send_num = 0
#self.packet_interval = rospy.get_param("~packet_interval", 0.001)
self.bandwidth = rospy.get_param("~bandwidth", 280 * 1000 * 1000)
self.rate = rospy.get_param("~send_rate", 2) #2Hz
self.socket_client = socket(AF_INET, SOCK_DGRAM)
self.packet_size = rospy.get_param("~packet_size", 1000) #2Hz
Expand All @@ -49,6 +50,9 @@ def __init__(self):
self.sendTimerCallback)
self.diagnostic_timer = rospy.Timer(rospy.Duration(1.0 / 10),
self.diagnosticTimerCallback)
def dynamicReconfigureCallback(self, config, level):
with self.lock:
self.bandwidth = config.bandwidth
def diagnosticCallback(self, stat):
# always OK
stat.summary(DiagnosticStatus.OK, "OK")
Expand Down