def test_get_master_uri(): from rosgraph.rosenv import get_master_uri val = get_master_uri() if 'ROS_MASTER_URI' in os.environ: assert val == os.environ['ROS_MASTER_URI'] # environment override val = get_master_uri(env=dict(ROS_MASTER_URI='foo')) assert val == 'foo' # argv override precedence, first arg wins val = get_master_uri(env=dict(ROS_MASTER_URI='foo'), argv=['__master:=bar', '__master:=bar2']) assert val == 'bar' # empty env assert None == get_master_uri(env={}) # invalid argv try: val = get_master_uri(argv=['__master:=']) assert False, "should have failed" except ValueError: pass # invalid argv try: val = get_master_uri(argv=['__master:=foo:=bar']) assert False, "should have failed" except ValueError: pass
def __init__(self, parent): """ @type parent: LaunchMain """ super(LaunchWidget, self).__init__() self._parent = parent self._config = None self._settings = QSettings('ros', 'rqt_launch') self._settings.sync() self._package_update = False self._launchfile_update = False # TODO: should be configurable from gui self._port_roscore = 11311 self._run_id = None self._rospack = rospkg.RosPack() ui_file = os.path.join( self._rospack.get_path('rqt_launch'), 'resource', 'launch_widget.ui' ) loadUi(ui_file, self) # row=0 allows any number of rows to be added. self._datamodel = QStandardItemModel(0, 1) master_uri = rosenv.get_master_uri() rospy.loginfo('LaunchWidget master_uri={}'.format(master_uri)) self._delegate = NodeDelegate(master_uri, self._rospack) self._treeview.setModel(self._datamodel) self._treeview.setItemDelegate(self._delegate) # NodeController used in controller class for launch operation. self._node_controllers = [] self._pushbutton_load_params.clicked.connect(self._parent.load_params) self._pushbutton_start_all.clicked.connect(self._parent.start_all) self._pushbutton_stop_all.clicked.connect(self._parent.stop_all) self._pushbutton_refresh.clicked.connect( self._update_pkgs_contain_launchfiles ) # Bind package selection with .launch file selection. self._combobox_pkg.currentIndexChanged[str].connect( self._refresh_launchfiles ) # Bind a launch file selection with launch GUI generation. self._combobox_launchfile_name.currentIndexChanged[str].connect( self._load_launchfile_slot ) self._update_pkgs_contain_launchfiles()
def setup(self, context): self.name = 'NAO Dashboard (%s)'%rosenv.get_master_uri() self.max_icon_size = QSize(50, 30) self.message = None self._dashboard_message = None self._last_dashboard_message_time = 0.0 self._raw_byte = None self.digital_outs = [0, 0, 0] icons_path = path.join(roslib.packages.get_pkg_dir('nao_dashboard'), "icons/") self._robot_combobox = QComboBox() self._robot_combobox.setSizeAdjustPolicy(QComboBox.AdjustToContents) self._robot_combobox.setInsertPolicy(QComboBox.InsertAlphabetically) self._robot_combobox.setEditable(True) gobject.threads_init() dbus.glib.threads_init() self.robots = [] self.sys_bus = dbus.SystemBus() self.avahi_server = dbus.Interface(self.sys_bus.get_object(avahi.DBUS_NAME, '/'), avahi.DBUS_INTERFACE_SERVER) self.sbrowser = dbus.Interface(self.sys_bus.get_object(avahi.DBUS_NAME, self.avahi_server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_INET, '_naoqi._tcp', 'local', dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) self.sbrowser.connect_to_signal("ItemNew", self.avahiNewItem) self.sbrowser.connect_to_signal("ItemRemove", self.avahiItemRemove) # Diagnostics self._monitor = MonitorDashWidget(self.context) # Rosout self._console = ConsoleDashWidget(self.context, minimal=False) ## Joint temperature self._temp_joint_button = StatusControl('Joint temperature', 'temperature_joints') ## CPU temperature self._temp_head_button = StatusControl('CPU temperature', 'temperature_head') ## Motors self._motors_button = Motors(self.context) ## Battery State self._power_state_ctrl = PowerStateControl('NAO Battery') self._agg_sub = rospy.Subscriber('diagnostics_agg', DiagnosticArray, self.new_diagnostic_message) self._last_dashboard_message_time = 0.0
def setup(self, context): self.name = 'NAOqi Dashboard (%s)'%rosenv.get_master_uri() self.robot_prefix = '' # get robot info rospy.wait_for_service("/naoqi_driver/get_robot_config") try: get_robot_info = rospy.ServiceProxy("/naoqi_driver/get_robot_config", GetRobotInfo) resp = get_robot_info.call( GetRobotInfoRequest() ) if resp.info.type == 0: self.robot_prefix = "nao_robot" elif resp.info.type == 2: self.robot_prefix = "pepper_robot" except rospy.ServiceException, e: print "Unable to call naoqi_driver/get_robot_config:%s", e
def setup(self, context): self.name = 'Irp6 Dashboard (%s)'%rosenv.get_master_uri() # Diagnostics self._monitor = MonitorDashWidget(self.context) # Rosout self._console = ConsoleDashWidget(self.context, minimal=False) ## Motors self._irp6p_motors_button = Irp6pMotors(self.context) self._irp6ot_motors_button = Irp6otMotors(self.context) self._conveyor_motors_button = ConveyorMotors(self.context) self._agg_sub = rospy.Subscriber('diagnostics', DiagnosticArray, self.new_diagnostic_message_diagnostics)
def setup(self, context): self.name = 'Irp6 Dashboard (%s)'%rosenv.get_master_uri() # Diagnostics self._monitor = MonitorDashWidget(self.context) # Rosout self._console = ConsoleDashWidget(self.context, minimal=False) ## Motors self._irp6p_motors_button = Irp6pMotors(self.context) self._irp6ot_motors_button = Irp6otMotors(self.context) self._conveyor_motors_button = ConveyorMotors(self.context) self._stop_button = Irp6Stop('Irp6Stop',self.emergency_stop) self._agg_sub = rospy.Subscriber('diagnostics', DiagnosticArray, self.new_diagnostic_message_diagnostics)
def setup(self, context): self.name = 'NAOqi Dashboard (%s)' % rosenv.get_master_uri() self.robot_prefix = '' # get robot info rospy.wait_for_service("/naoqi_driver/get_robot_config") try: get_robot_info = rospy.ServiceProxy( "/naoqi_driver/get_robot_config", GetRobotInfo) resp = get_robot_info.call(GetRobotInfoRequest()) if resp.info.type == 0: self.robot_prefix = "nao_robot" elif resp.info.type == 2: self.robot_prefix = "pepper_robot" except rospy.ServiceException, e: print "Unable to call naoqi_driver/get_robot_config:%s", e
def __init__(self, parent): ''' @type parent: LaunchMain ''' super(LaunchWidget, self).__init__() self._parent = parent print 'FROM WIDGET' self._config = None #TODO: should be configurable from gui self._port_roscore = 11311 self._run_id = None self._rospack = rospkg.RosPack() ui_file = os.path.join(self._rospack.get_path('rqt_launch'), 'resource', 'launch_widget.ui') loadUi(ui_file, self) # row=0 allows any number of rows to be added. self._datamodel = QStandardItemModel(0, 1) master_uri = rosenv.get_master_uri() rospy.loginfo('LaunchWidget master_uri={}'.format(master_uri)) self._delegate = NodeDelegate(master_uri, self._rospack) self._treeview.setModel(self._datamodel) self._treeview.setItemDelegate(self._delegate) # NodeController used in controller class for launch operation. self._node_controllers = [] self._pushbutton_start_all.clicked.connect(self._parent.start_all) self._pushbutton_stop_all.clicked.connect(self._parent.stop_all) # Bind package selection with .launch file selection. self._combobox_pkg.currentIndexChanged[str].connect( self._refresh_launchfiles) # Bind a launch file selection with launch GUI generation. self._combobox_launchfile_name.currentIndexChanged[str].connect( self._load_launchfile_slot) self._update_pkgs_contain_launchfiles() # Used for removing previous nodes self._num_nodes_previous = 0
def setup(self, context): self.name = 'NAO Dashboard (%s)'%rosenv.get_master_uri() self._robot_combobox = AvahiWidget() # Diagnostics self._monitor = MonitorDashWidget(self.context) # Rosout self._console = ConsoleDashWidget(self.context, minimal=False) ## Joint temperature self._temp_joint_button = StatusControl('Joint temperature', 'temperature_joints') ## CPU temperature self._temp_head_button = StatusControl('CPU temperature', 'temperature_head') ## Motors self._motors_button = Motors(self.context) ## Battery State self._power_state_ctrl = PowerStateControl('NAO Battery') self._agg_sub = rospy.Subscriber('diagnostics_agg', DiagnosticArray, self.new_diagnostic_message)
def __init__(self, parent, id=wx.ID_ANY, title='SLAW Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX): wx.Frame.__init__(self, parent, id, title, pos, size, style) wx.InitAllImageHandlers() self.SetBackgroundColour(wx.Colour(242,241,240,255)) self.SetTitle('SLAW dashboard (%s)'%rosenv.get_master_uri()) rospy.init_node('slaw_dashboard', anonymous=True) try: getattr(rxtools, "initRoscpp") rxtools.initRoscpp("slaw_dashboard_cpp", anonymous=True) except AttributeError: pass slaw_icons_path = path.join(roslib.packages.get_pkg_dir('slaw_dashboard'), "icons/") sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(sizer) # Diagnostics Panel static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostics"), wx.HORIZONTAL) sizer.Add(static_sizer, 0) # Diagnostics self._diagnostics_button = StatusControl(self, wx.ID_ANY, slaw_icons_path, "diagnostics", False) self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics")) static_sizer.Add(self._diagnostics_button, 0) # Rosout self._rosout_button = StatusControl(self, wx.ID_ANY, slaw_icons_path, "rosout", False) self._rosout_button.SetToolTip(wx.ToolTip("Rosout")) static_sizer.Add(self._rosout_button, 0) # SmachViewer self._smach_button = StatusControl(self, wx.ID_ANY, slaw_icons_path, "smach", False) self._smach_button.SetToolTip(wx.ToolTip("Smach Viewer")) static_sizer.Add(self._smach_button, 0) self._smach_button.Bind(wx.EVT_LEFT_DOWN, self.on_smach_button_clicked) self._smach_button.set_ok() # Platform static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Platform"), wx.HORIZONTAL) sizer.Add(static_sizer, 0) # base status self._base_status = StatusControl(self, wx.ID_ANY, slaw_icons_path, "wheel", False) self._base_status.SetToolTip(wx.ToolTip("Base Motors: Stale")) static_sizer.Add(self._base_status, 0) self._base_status.Bind(wx.EVT_LEFT_DOWN, self.on_base_status_clicked) # arm status self._arm_status = StatusControl(self, wx.ID_ANY, slaw_icons_path, "arm", False) self._arm_status.SetToolTip(wx.ToolTip("Arm Motors: Stale")) static_sizer.Add(self._arm_status, 0) self._arm_status.Bind(wx.EVT_LEFT_DOWN, self.on_arm_status_clicked) # Driver static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Drv"), wx.HORIZONTAL) sizer.Add(static_sizer, 0) # driver status self._driver_status = StatusControl(self, wx.ID_ANY, slaw_icons_path, "motor", False) self._driver_status.SetToolTip(wx.ToolTip("Driver: Stale")) static_sizer.Add(self._driver_status, 0) self._driver_status.Bind(wx.EVT_BUTTON, self.on_driver_status_clicked) # System info self._robot_sysinfo = SysInfoControl(self, wx.ID_ANY, "System", slaw_icons_path) sizer.Add(self._robot_sysinfo) # Apps static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Apps"), wx.HORIZONTAL) sizer.Add(static_sizer, 0) # Clear costmap self._costmap_ctrl = StatusControl(self, wx.ID_ANY, slaw_icons_path, "costmap", False) self._costmap_ctrl.SetToolTip(wx.ToolTip("Clear costmap")) static_sizer.Add(self._costmap_ctrl, 0) self._costmap_ctrl.Bind(wx.EVT_BUTTON, self.on_costmap_clicked) # Cancel goals self._goal_ctrl = StatusControl(self, wx.ID_ANY, slaw_icons_path, "cancel-goal", False) self._goal_ctrl.SetToolTip(wx.ToolTip("Cancel goal")) static_sizer.Add(self._goal_ctrl, 0) self._goal_ctrl.Bind(wx.EVT_BUTTON, self.on_goal_clicked) # Tuck arm self._arm_ctrl = StatusControl(self, wx.ID_ANY, slaw_icons_path, "arm-tuck", False) self._arm_ctrl.SetToolTip(wx.ToolTip("Tuck arm")) static_sizer.Add(self._arm_ctrl, 0) self._arm_ctrl.Bind(wx.EVT_BUTTON, self.on_arm_clicked) # Store location self._location_ctrl = StatusControl(self, wx.ID_ANY, slaw_icons_path, "nav", False) self._location_ctrl.SetToolTip(wx.ToolTip("Store location")) static_sizer.Add(self._location_ctrl, 0) self._location_ctrl.Bind(wx.EVT_BUTTON, self.on_location_clicked) # Wrap up stuff self._config = wx.Config("slaw_dashboard") self.Bind(wx.EVT_CLOSE, self.on_close) self.Layout() self.Fit() self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics") self._diagnostics_frame.Hide() self._diagnostics_frame.Center() self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked) self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout") self._rosout_frame.Hide() self._rosout_frame.Center() self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked) self.load_config() self._timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer) self._timer.Start(500) # Message subscribers self._last_sysinfo_message = 0.0 self._last_power_state_message = 0.0 self._last_platform_state_message = 0.0 self._platform_state_message = None self._sub_sysinfo = rospy.Subscriber('dashboard/sysinfo', SysInfo, self.cb_sysinfo) self._sub_platform_state = rospy.Subscriber('dashboard/platform_state', PowerBoardState, self.cb_platform_state) try: rospy.wait_for_service('/move_base/clear_costmaps', 1) self._srv_costmap = rospy.ServiceProxy('/move_base/clear_costmaps', Empty) self._costmap_ctrl.set_ok() self._costmap_ok = True except rospy.ROSException, e: rospy.logwarn("move base not running yet, can't clear costmap") self._costmap_ctrl.set_stale() self._costmap_ok = False