Since the motor may get hot during continuous playback of the application or making animation during development, development may stop in the middle, so I made a box that will take a break without permission before getting tired. If you put it in the Init or Main of the app, even if you get heat during playback, it will not stop in the middle, just take a break on your own and try to make it feel like it will start moving again when the heat cools down.
getIdlePostureEnabled(const std::string& pChainName) setIdlePostureEnabled(const std::string& pChainName, const bool& pEnable)
If you want to stop this function by putting it in the management / monitoring box, fire an event to stop it.
Example.py
def onLoad(self):
self.timer = None
self.memory = ALProxy("ALMemory")
self.motion = ALProxy("ALMotion")
self.parts = ["Head", "LArm", "RArm", "Legs"]
def onTimer(self):
partList = []
tempList = []
partCount = { "Head":False, "LArm":False, "RArm":False, "Legs":False }
sNameList = ["HeadPitch", "HeadYaw", "LElbowRoll", "LElbowYaw", "LHand", "LShoulderPitch", "LShoulderRoll", "LWristYaw", "RElbowRoll", "RElbowYaw", "RHand", "RShoulderPitch", "RShoulderRoll", "RWristYaw", "KneePitch", "HipRoll", "HipPitch"]
for sName in sNameList:
sKeyName = "Device/SubDeviceList/%s/Temperature/Sensor/Value" % sName
try:
partList.append(sName)
tempList.append(int( self.memory.getData(sKeyName) ))
except:
self.logger.error("No temperature found for this hardware: " + str(sName))
for pName in partList:
if ( "Head" in pName ):
act = "Head"
elif ( "LElbow" in pName or "LHand" in pName or "LShoulder" in pName or "LWrist" in pName ):
act = "LArm"
elif ( "RElbow" in pName or "RHand" in pName or "RShoulder" in pName or "RWrist" in pName ):
act = "RArm"
elif ( "Ankle" in pName or "Hip" in pName or "Knee"):
act = "Legs"
i = tempList[partList.index(pName)]
if i >= int(self.getParameter("Motion stop temperature(or more)")):
if partCount[act] == False:
partCount[act] = True
for part in self.parts:
if partCount[part] and self.motion.getIdlePostureEnabled(part) == False:
self.logger.warn("%s Motion Stopped" % part)
self.motion.setIdlePostureEnabled(part, True)
elif partCount[part] == False and self.motion.getIdlePostureEnabled(part):
self.logger.info("%s Motion Start" % part)
self.motion.setIdlePostureEnabled(part, False)
The sauce is dirty, but please forgive me.
Robot Start's Robot Library https://robo-lib.com/repositories/summary/49
Recommended Posts