本文整理汇总了Python中OpenRTM_aist类的典型用法代码示例。如果您正苦于以下问题:Python OpenRTM_aist类的具体用法?Python OpenRTM_aist怎么用?Python OpenRTM_aist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OpenRTM_aist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onDeactivated
def onDeactivated(self, ec_id):
"""
The deactivated action (Active state exit action)
former rtc_active_exit()
\param ec_id target ExecutionContext Id
\return RTC::ReturnCode_t
"""
# Servo Motor: Torque OFF
self._d_on_off.data = [0, self.servo_id, 0]
OpenRTM_aist.setTimestamp(self._d_on_off)
self._on_offOut.write()
# URG: Measurement stop
self._d_urg.data = [0]
OpenRTM_aist.setTimestamp(self._d_urg)
self._urgOut.write()
print('onDeactivated')
return RTC.RTC_OK
示例2: onExecute
def onExecute(self, ec_id):
"""
The execution action that is invoked periodically
former rtc_active_do()
\param ec_id target ExecutionContext Id
\return RTC::ReturnCode_t
"""
if self._commandIn.isNew():
self._d_command = self._commandIn.read()
if self._d_command.data[0] == 2:
self.cw_angle = self._d_command.data[1]
self.ccw_angle = self._d_command.data[2]
self.move_time = self._d_command.data[3]
# Servo: Moving CW
self._d_motion.data = [0, self.servo_id,
self.servo_offset + self.ccw_angle, self.move_time_ccw]
OpenRTM_aist.setTimestamp(self._d_motion)
self._motionOut.write()
time.sleep(self.move_time_ccw / 100.0 + self.margin_time / 1000.0)
# Servo: Moving CCW
self._d_motion.data = [0, self.servo_id,
self.servo_offset + self.cw_angle, self.move_time_cw]
OpenRTM_aist.setTimestamp(self._d_motion)
self._motionOut.write()
time.sleep(self.move_time_cw / 100.0 + self.margin_time / 1000.0)
return RTC.RTC_OK
示例3: initConsumers
def initConsumers(self):
self._rtcout.RTC_TRACE("initConsumers()")
# create OuPort consumers
factory = OpenRTM_aist.OutPortConsumerFactory.instance()
consumer_types = factory.getIdentifiers()
self._rtcout.RTC_DEBUG("available consumers: %s",
OpenRTM_aist.flatten(consumer_types))
if self._properties.hasKey("consumer_types") and \
OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all":
self._rtcout.RTC_DEBUG("allowed consumers: %s",
self._properties.getProperty("consumer_types"))
temp_types = consumer_types
consumer_types = []
active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",")
temp_types.sort()
active_types.sort()
set_ctypes = set(temp_types).intersection(set(active_types))
consumer_types = consumer_types + list(set_ctypes)
# OutPortConsumer supports "pull" dataflow type
if len(consumer_types) > 0:
self._rtcout.RTC_PARANOID("dataflow_type pull is supported")
self.appendProperty("dataport.dataflow_type", "pull")
self.appendProperty("dataport.interface_type",
OpenRTM_aist.flatten(consumer_types))
self._consumerTypes = consumer_types
return
示例4: initProviders
def initProviders(self):
self._rtcout.RTC_TRACE("initProviders()")
# create InPort providers
factory = OpenRTM_aist.InPortProviderFactory.instance()
provider_types = factory.getIdentifiers()
self._rtcout.RTC_DEBUG("available providers: %s",
OpenRTM_aist.flatten(provider_types))
if self._properties.hasKey("provider_types") and \
OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all":
self._rtcout.RTC_DEBUG("allowed providers: %s",
self._properties.getProperty("provider_types"))
temp_types = provider_types
provider_types = []
active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",")
temp_types.sort()
active_types.sort()
set_ptypes = set(temp_types).intersection(set(active_types))
provider_types = provider_types + list(set_ptypes)
# InPortProvider supports "push" dataflow type
if len(provider_types) > 0:
self._rtcout.RTC_DEBUG("dataflow_type push is supported")
self.appendProperty("dataport.dataflow_type", "push")
self.appendProperty("dataport.interface_type",
OpenRTM_aist.flatten(provider_types))
self._providerTypes = provider_types
return
示例5: createProvider
def createProvider(self, cprof, prop):
if not prop.getProperty("interface_type") and \
not OpenRTM_aist.includes(self._providerTypes, prop.getProperty("interface_type")):
self._rtcout.RTC_ERROR("no provider found")
self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type"))
self._rtcout.RTC_DEBUG("interface_types: %s",
OpenRTM_aist.flatten(self._providerTypes))
return 0
self._rtcout.RTC_DEBUG("interface_type: %s", prop.getProperty("interface_type"))
provider = OpenRTM_aist.InPortProviderFactory.instance().createObject(prop.getProperty("interface_type"))
if provider != 0:
self._rtcout.RTC_DEBUG("provider created")
provider.init(prop.getNode("provider"))
if not provider.publishInterface(cprof.properties):
self._rtcout.RTC_ERROR("publishing interface information error")
OpenRTM_aist.InPortProviderFactory.instance().deleteObject(provider)
return 0
return provider
self._rtcout.RTC_ERROR("provider creation failed")
return 0
示例6: onExecute
def onExecute(self, ec_id):
print "Please input number: ",
self._data.data = long(sys.stdin.readline())
OpenRTM_aist.setTimestamp(self._data)
print "Sending to subscriber: ", self._data.data
self._outport.write()
return RTC.RTC_OK
示例7: onExecute
def onExecute(self, ec_id):
#データを新規に受信した場合に、データをm_last_sensor_dataを格納する
if self._distance_sensorIn.isNew():
data = self._distance_sensorIn.read()
if len(data.data) == 4:
self._last_sensor_data = data.data[:]
#センサの計測値がstop_distance以上の時に前進しないようにする
if self._forward_velocity[0] > 0:
for d in self._last_sensor_data:
if d > self._stop_distance[0]:
self._d_target_velocity.data.vx = 0
self._d_target_velocity.data.vy = 0
self._d_target_velocity.data.va = 0
OpenRTM_aist.setTimestamp(self._d_target_velocity)
self._target_velocityOut.write()
return RTC.RTC_OK
#コンフィギュレーションパラメータで設定した速度を送信する
self._d_target_velocity.data.vx = self._forward_velocity[0]
self._d_target_velocity.data.vy = 0
self._d_target_velocity.data.va = self._rotate_velocity[0]
OpenRTM_aist.setTimestamp(self._d_target_velocity)
self._target_velocityOut.write()
return RTC.RTC_OK
示例8: load
def load(self, file_name, init_func=None):
if not self._rtcout:
self._rtcout = self._mgr.getLogbuf("ModuleManager")
self._rtcout.RTC_TRACE("load(fname = %s)", file_name)
if file_name == "":
raise ModuleManager.InvalidArguments, "Invalid file name."
if OpenRTM_aist.isURL(file_name):
if not self._downloadAllowed:
raise ModuleManager.NotAllowedOperation, "Downloading module is not allowed."
else:
raise ModuleManager.NotFound, "Not implemented."
import_name = os.path.split(file_name)[-1]
pathChanged=False
file_path = None
if OpenRTM_aist.isAbsolutePath(file_name):
if not self._absoluteAllowed:
raise ModuleManager.NotAllowedOperation, "Absolute path is not allowed"
else:
splitted_name = os.path.split(file_name)
save_path = sys.path[:]
sys.path.append(splitted_name[0])
pathChanged = True
import_name = splitted_name[-1]
file_path = file_name
else:
file_path = self.findFile(file_name, self._loadPath)
if not file_path:
raise ModuleManager.InvalidArguments, "Invalid file name."
if not self.fileExist(file_path):
raise ModuleManager.FileNotFound, file_name
if not pathChanged:
splitted_name = os.path.split(file_path)
sys.path.append(splitted_name[0])
ext_pos = import_name.find(".py")
if ext_pos > 0:
import_name = import_name[:ext_pos]
mo = __import__(str(import_name))
if pathChanged:
sys.path = save_path
dll = self.DLLEntity(mo,OpenRTM_aist.Properties())
dll.properties.setProperty("file_path",file_path)
self._modules.registerObject(dll)
if init_func is None:
return file_name
self.symbol(file_path,init_func)(self._mgr)
return file_name
示例9: updateExportedPortsList
def updateExportedPortsList(self):
plist = self._rtobj.getProperties().getProperty("conf.default.exported_ports")
if plist:
p = [plist]
OpenRTM_aist.eraseBlank(p)
self._expPorts = p[0].split(",")
return
示例10: onExecute
def onExecute(self, ec_id):
#self._data.data = "Guten tag"
#self._data.data = "Einen schönen Tag."
self._data.data = "Ich habe Zwillinge, Danke, Danke."
OpenRTM_aist.setTimestamp(self._data)
self._outport.write()
time.sleep(5)
return RTC.RTC_OK
示例11: onDeactivated
def onDeactivated(self, ec_id):
#停止する
self._d_target_velocity.data.vx = 0
self._d_target_velocity.data.vy = 0
self._d_target_velocity.data.va = 0
OpenRTM_aist.setTimestamp(self._d_target_velocity)
self._target_velocityOut.write()
return RTC.RTC_OK
示例12: __call__
def __call__(self, info, cdrdata):
data = OpenRTM_aist.ConnectorDataListenerT.__call__(self, info, cdrdata, RTC.TimedFloatSeq(RTC.Time(0,0),[]))
if len(data.data) >= 2:
self._out.data.vx = data.data[1] * self._velocity_by_position[0]
self._out.data.vy = 0
self._out.data.va = data.data[0] * self._rotation_by_position[0]
OpenRTM_aist.setTimestamp(self._out)
self._outOut.write()
示例13: onExecute
def onExecute(self, ec_id):
sys.stdin.readline()
OpenRTM_aist.setTimestamp(self._data)
self._data.data = "Base"
self._outport.write()
return RTC.RTC_OK
示例14: send_data
def send_data(self, data):
if len(data) == 4:
self.motion_data = data
elif len(data) == 3:
print('Servo ON/OFF: %s' % data)
self._d_on_off.data = data
OpenRTM_aist.setTimestamp(self._d_on_off)
self._on_offOut.write()
示例15: onExecute
def onExecute(self, ec_id):
self._data.data = "good morning"
OpenRTM_aist.setTimestamp(self._data)
self._outport.write()
time.sleep(5)
self._data.data = "good afternoon"
OpenRTM_aist.setTimestamp(self._data)
self._outport.write()
time.sleep(5)
return RTC.RTC_OK