-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
visualization client: Create client, implement ComputeRobotConfigsFor…
…GraspVisualization
- Loading branch information
Tan Li Boon
committed
Feb 3, 2022
1 parent
66b8ffd
commit f0dac44
Showing
4 changed files
with
118 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2022 MUJIN Inc. | ||
# Mujin controller client for visualization task | ||
|
||
from . import realtimerobotclient | ||
|
||
# logging | ||
import logging | ||
log = logging.getLogger(__name__) | ||
|
||
class VisualizationClient(realtimerobotclient.RealtimeRobotControllerClient): | ||
"""Mujin controller client for visualization tasks | ||
""" | ||
tasktype = 'visualization' | ||
|
||
def __init__(self, **kwargs): | ||
"""Logs into the mujin controller, initializes realtimeitlplanning3 task, and sets up parameters | ||
:param controllerurl: URL of the mujin controller, e.g. http://controller13 | ||
:param controllerusername: Username of the mujin controller, e.g. testuser | ||
:param controllerpassword: Password of the mujin controller | ||
:param taskzmqport: Port of the realtimeitlplanning3 task's zmq server, e.g. 7110 | ||
:param taskheartbeatport: Port of the realtimeitlplanning3 task's zmq server's heartbeat publisher, e.g. 7111 | ||
:param taskheartbeattimeout: Seconds until reinitializing realtimeitlplanning3 task's zmq server if no heartbeat is received, e.g. 7 | ||
:param scenepk: Primary key (pk) of the bin picking task scene, e.g. komatsu_ntc.mujin.dae | ||
:param robotname: Name of the robot, e.g. VP-5243I | ||
:param robotspeed: Speed of the robot, e.g. 0.4 | ||
:param regionname: Name of the bin, e.g. container1 | ||
:param targetname: Name of the target, e.g. plasticnut-center | ||
:param toolname: Name of the manipulator, e.g. 2BaseZ | ||
:param envclearance: Environment clearance in millimeters, e.g. 20 | ||
:param usewebapi: Whether to use webapi for controller commands | ||
:param robotaccelmult: Optional multiplier for forcing the acceleration | ||
""" | ||
super(VisualizationClient, self).__init__(tasktype = self.tasktype, **kwargs) | ||
self.SetVisualizationState({}) | ||
|
||
def SetVisualizationState(self, visualizationState, timeout=10, fireandforget=False, **kwargs): | ||
# type: (dict, int, bool, dict) -> dict | None | ||
taskparameters = { | ||
'command': 'SetVisualizationState', | ||
'visualizationState': visualizationState, | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, usewebapi=False, timeout=timeout, fireandforget=fireandforget) | ||
|
||
def ComputeRobotConfigsForGraspVisualization(self, targetname, graspname, robotname=None, toolname=None, unit='mm', timeout=10, **kwargs): | ||
# type: (str, str, str, str, str, int, dict) -> dict | None | ||
'''Returns robot configs for grasp visualization | ||
''' | ||
taskparameters = { | ||
'command': 'ComputeRobotConfigsForGraspVisualization', | ||
'targetname': targetname, | ||
'graspname': graspname | ||
} | ||
if unit is not None: | ||
taskparameters['unit'] = unit | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, robotname=robotname, toolname=toolname, usewebapi=False, timeout=timeout) | ||
|
||
#SetCameraTransforms, SetViewerParameters inherited from PlanningControllerClient | ||
|
||
# | ||
# Nothing from binpickingui yet | ||
# | ||
|
||
# | ||
# Originally from teachworkerui | ||
# | ||
|
||
def ComputeRobotConfigsForCommandVisualization(self, executiongraph, commandindex=0, timeout=2, fireandforget=False, **kwargs): | ||
# type: (dict, int, int, bool, dict) -> dict | None | ||
taskparameters = { | ||
'command': 'ComputeRobotConfigsForCommandVisualization', | ||
'executiongraph': executiongraph, | ||
'commandindex': commandindex, | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, usewebapi=False, timeout=timeout, fireandforget=fireandforget) | ||
|
||
def ComputeRobotJointValuesForCommandVisualization(self, program, commandindex=0, timeout=2, fireandforget=False, **kwargs): | ||
# type: (dict, int, int, bool, dict) -> dict | None | ||
taskparameters = { | ||
'command': 'ComputeRobotJointValuesForCommandVisualization', | ||
'program': program, | ||
'commandindex': commandindex, | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, usewebapi=False, timeout=timeout, fireandforget=fireandforget) | ||
|
||
def PlotProgramWaypoints(self, timeout=1, fireandforget=True, **kwargs): | ||
# type: (int, bool, dict) -> dict | None | ||
taskparameters = { | ||
'command': 'PlotProgramWaypoints', | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, usewebapi=False, timeout=timeout, fireandforget=fireandforget) | ||
|
||
def PlotContacts(self, report={}, timeout=1, fireandforget=True, **kwargs): | ||
# type: (dict, int, bool, dict) -> dict | None | ||
taskparameters = { | ||
'command': 'PlotContacts', | ||
'report': report | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, usewebapi=False, timeout=timeout, fireandforget=fireandforget) | ||
|
||
def GenerateExecutionGraph(self, programName, commandTimeout=0.2, totalTimeout=1.0, timeout=10, fireandforget=False, **kwargs): | ||
# type: (str, float, float, float, bool, dict) -> dict | None | ||
"""generate list of commands for the itl program | ||
""" | ||
taskparameters = { | ||
'command': 'GenerateExecutionGraph', | ||
'programName': programName, | ||
'commandTimeout': commandTimeout, | ||
'totalTimeout': totalTimeout, | ||
} | ||
taskparameters.update(kwargs) | ||
return self.ExecuteCommand(taskparameters, timeout=timeout, usewebapi=False, fireandforget=fireandforget) |