Skip to content
Snippets Groups Projects
Commit 62b9c5c7 authored by ipa-fxm's avatar ipa-fxm
Browse files

dynamic reconfigure server for prevent_programming

parent b1b27651
Branches
Tags
No related merge requests found
...@@ -4,17 +4,20 @@ project(ur_driver) ...@@ -4,17 +4,20 @@ project(ur_driver)
## Find catkin macros and libraries ## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages ## is used, also find other catkin packages
find_package(catkin REQUIRED) find_package(catkin REQUIRED dynamic_reconfigure)
catkin_python_setup() catkin_python_setup()
generate_dynamic_reconfigure_options(
cfg/URDriver.cfg
)
################################### ###################################
## catkin specific configuration ## ## catkin specific configuration ##
################################### ###################################
catkin_package() catkin_package()
############# #############
## Install ## ## Install ##
############# #############
......
#!/usr/bin/env python
PACKAGE = "ur_driver"
from dynamic_reconfigure.parameter_generator_catkin import *
gen = ParameterGenerator()
gen.add("prevent_programming", bool_t, 0, "Prevent driver from continuously uploading 'prog'", False)
exit(gen.generate(PACKAGE, "ur_driver", "URDriver"))
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
<url type="website">http://ros.org/wiki/ur_driver</url> <url type="website">http://ros.org/wiki/ur_driver</url>
<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>catkin</buildtool_depend>
<build_depend>dynamic_reconfigure</build_depend>
<run_depend>rospy</run_depend> <run_depend>rospy</run_depend>
<run_depend>actionlib</run_depend> <run_depend>actionlib</run_depend>
<run_depend>control_msgs</run_depend> <run_depend>control_msgs</run_depend>
...@@ -22,4 +24,5 @@ ...@@ -22,4 +24,5 @@
<run_depend>trajectory_msgs</run_depend> <run_depend>trajectory_msgs</run_depend>
<run_depend>ur_msgs</run_depend> <run_depend>ur_msgs</run_depend>
<run_depend>python-lxml</run_depend> <run_depend>python-lxml</run_depend>
<run_depend>dynamic_reconfigure</run_depend>
</package> </package>
...@@ -16,6 +16,9 @@ from control_msgs.msg import FollowJointTrajectoryAction ...@@ -16,6 +16,9 @@ from control_msgs.msg import FollowJointTrajectoryAction
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
from geometry_msgs.msg import WrenchStamped from geometry_msgs.msg import WrenchStamped
from dynamic_reconfigure.server import Server
from ur_driver.cfg import URDriverConfig
from ur_driver.deserialize import RobotState, RobotMode from ur_driver.deserialize import RobotState, RobotMode
from ur_driver.deserializeRT import RobotStateRT from ur_driver.deserializeRT import RobotStateRT
...@@ -894,12 +897,24 @@ def handle_set_io(req): ...@@ -894,12 +897,24 @@ def handle_set_io(req):
def set_io_server(): def set_io_server():
s= rospy.Service('set_io', SetIO, handle_set_io) s= rospy.Service('set_io', SetIO, handle_set_io)
def reconfigure_callback(config, level):
global prevent_programming
prevent_programming = config.prevent_programming
## What about updating the value on the parameter server?
return config
def main(): def main():
rospy.init_node('ur_driver', disable_signals=True) rospy.init_node('ur_driver', disable_signals=True)
if rospy.get_param("use_sim_time", False): if rospy.get_param("use_sim_time", False):
rospy.logwarn("use_sim_time is set!!!") rospy.logwarn("use_sim_time is set!!!")
global prevent_programming global prevent_programming
prevent_programming = rospy.get_param("prevent_programming", False) prevent_programming = rospy.get_param("prevent_programming", False)
reconfigure_srv = Server(URDriverConfig, reconfigure_callback)
## Still use parameter server?
#update = URDriverConfig(prevent_programming)
#reconfigure_srv.update_configuration(update)
prefix = rospy.get_param("~prefix", "") prefix = rospy.get_param("~prefix", "")
print "Setting prefix to %s" % prefix print "Setting prefix to %s" % prefix
global joint_names global joint_names
...@@ -968,7 +983,7 @@ def main(): ...@@ -968,7 +983,7 @@ def main():
# Checks for disconnect # Checks for disconnect
if getConnectedRobot(wait=False): if getConnectedRobot(wait=False):
time.sleep(0.2) time.sleep(0.2)
prevent_programming = rospy.get_param("prevent_programming", False) #prevent_programming = rospy.get_param("prevent_programming", False)
if prevent_programming: if prevent_programming:
print "Programming now prevented" print "Programming now prevented"
connection.send_reset_program() connection.send_reset_program()
...@@ -983,7 +998,7 @@ def main(): ...@@ -983,7 +998,7 @@ def main():
while not connection.ready_to_program(): while not connection.ready_to_program():
print "Waiting to program" print "Waiting to program"
time.sleep(1.0) time.sleep(1.0)
prevent_programming = rospy.get_param("prevent_programming", False) #prevent_programming = rospy.get_param("prevent_programming", False)
connection.send_program() connection.send_program()
r = getConnectedRobot(wait=True, timeout=1.0) r = getConnectedRobot(wait=True, timeout=1.0)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment