PmxPythonLib V1.0.2.0
読み取り中…
検索中…
一致する文字列を見つけられません
PmxPySerialClass.PmxPySerialClass クラス

PMXで使用する関数や定義をひとまとまりにしたもので、PySerialを使用して動作します。 [詳解]

PmxLib.PmxLibを継承しています。

公開メンバ関数

def __init__ (self)
 
def logOutput (self)
 
def logOutput (self, value)
 通信のログを16進数で出力する設定をする
 
def synchronize (self, txBuf, rxLen)
 PySerialを使用してtxBufのコマンドを送受信します
 
def synchronizeVariableRead (self, txBuf)
 PySerialを使用してtxBufのコマンドを送受信します 返信データ数がわからない場合に使用します。
 
def synchronizeNoRead (self, txBuf)
 ブロードキャストIDなどでデータの返事がないとわかっている時に送信をします。
 
def setSerialParameters (self, baudrate=None, parity=None, timeout=None)
 PySerialで使用する通信速度、パリティ、タイムアウトなどのシリアル パラメータを設定します。
 
def open (self, comName, baudrate=115200, parity=serial.PARITY_NONE, timeout=1.0)
 SerialポートをPMXの設定に合わせて開く
 
def close (self)
 開いている_comポートを閉じる
 
- 基底クラス PmxLib.PmxLib に属する継承公開メンバ関数
def synchronize (self, txBuf, rxLen)
 「synchronize」関数は、サブクラスでオーバーライドする必要があるプレースホルダーです。 txBufのコマンドを送受信させます。
 
def synchronizeVariableRead (self, txBuf)
 「synchronizeVariableRead」関数は、サブクラスでオーバーライドする必要があるプレースホルダーです。 受信データ数がわからない場合でも送受信したい場合に使用します。
 
def synchronizeNoRead (self, txBuf)
 「synchronizeNoRead」関数は、サブクラスでオーバーライドする必要があるプレースホルダーです。 ブロードキャストIDなどデータが返ってこない時に使用します。
 
def setSerialParameters (self, int baudrate, parity, int timeout)
 「setSerialParameters」関数は、サブクラスでオーバーライドする必要があります。 通信速度、パリティ、タイムアウトでPC等上位側の通信設定を変更する際に使用します。
 
def MemREAD (self, int id, int addr, int size)
 MemREADコマンドでPMXサーボモータからデータを取得します。
 
def MemREADToByte (self, int id, int addr)
 MemREADで取得したデータをbyte(符号なし1byte)に変換して取得します。
 
def MemREADToInt16 (self, int id, int addr)
 MemREADで取得したデータをint16(符号あり2byte)に変換して取得します。
 
def MemREADToUint16 (self, int id, int addr)
 MemREADで取得したデータをUint16(符号なし2byte)に変換して取得します。
 
def MemREADToInt32 (self, int id, int addr)
 MemREADで取得したデータをint32(符号あり4byte)に変換して取得します。
 
def MemREADToUint32 (self, int id, int addr)
 MemREADで取得したデータをUint32(符号なし4byte)に変換して取得します。
 
def MemWRITE (self, int id, int baseAddr, dataByteArray, writeOpt=0)
 PMXサーボモータにMemWRITEコマンドを発行し、結果を取得します。
 
def MemWRITEToByte (self, int id, int baseAddr, int data, writeOpt=0)
 MemWRITEでbyte(符号なし1byte)のデータを書き込みます。 その結果のステータス情報を返信します。
 
def MemWRITEToInt16 (self, int id, int baseAddr, int data, writeOpt=0)
 MemWRITEでint16(符号あり2byte)のデータを書き込みます。 その結果のステータス情報を返信します。
 
def MemWRITEToUint16 (self, int id, int baseAddr, int data, writeOpt=0)
 MemWRITEでint16(符号なし2byte)のデータを書き込みます。 その結果のステータス情報を返信します。
 
def MemWRITEToInt32 (self, int id, int baseAddr, int data, writeOpt=0)
 MemWRITEでint32(符号あり4byte)のデータを書き込みます。 その結果のステータス情報を返信します。
 
def MemWRITEToUint32 (self, int id, int baseAddr, int data, writeOpt=0)
 MemWRITEでUint32(符号なし4byte)のデータを書き込みます。 その結果のステータス情報を返信します。
 
def LOAD (self, int id)
 PMXサーボモータのLOADコマンドを発行し、ステータス結果を取得します。
 
def SAVE (self, int id)
 PMXサーボモータのSAVEコマンドを発行し、ステータス結果を取得します。
 
def MotorREAD (self, int id, int receiveMode, controlMode=0x01)
 MotorREAD関数を発行し、応答モードに応じてデータを取得します。
 
def MotorWRITE (self, int id, int mototWRITEopt, controlMode=0x01, receiveMode=0, sendDataList=[])
 MotorWRITE 機能は、モータの制御やトルクのオン/オフを切り替えるコマンドを送信し、モーターからステータスとデータを受信します。
 
def MotorWRITESingle (self, int id, int controlMode, int receiveMode, int targetVal)
 MotorWRITEでデータ指示一つの場合に使用します
 
def MotorWRITEDouble (self, int id, int controlMode, int receiveMode, int targetVal1, int targetVal2)
 MotorWriteを使用して2変数を指示するときに使用します。
 
def MotorWRITETriple (self, int id, int controlMode, int receiveMode, int targetVal1, int targetVal2, int targetVal3)
 MotorWriteを使用して3変数を指示するときに使用します。
 
def SystemREAD (self, int id)
 SystemREAD 関数は、サーボからシステム情報を読み取ります。
 
def SystemWRITE (self, int id, serialNum=None, newId=None, newBaudrateVal=None, newParityVal=None, newResponseTime=None)
 SystemWRITEコマンドを使用してID、ボーレート、パリティ、および応答時間を設定します。
 
def ReBoot (self, int id, resetTime=0)
 サーボモータを再起動させます。
 
def FactoryReset (self, int id, serialNum=None)
 サーボを工場出荷時の設定にリセットします
 
def getPosition (self, int id, contolMode=0x01)
 指定したIDの現在の位置を取得します。
 
def getSpeed (self, int id)
 指定した ID の現在の速度を取得します。
 
def getCurrent (self, int id)
 指定した ID の現在の電流を取得します。
 
def getTorque (self, int id)
 指定した ID の現在のトルクを取得します。
 
def getPwm (self, int id)
 指定した ID の現在のPWMを取得します。
 
def getMotorTemp (self, int id)
 指定した ID の現在のモータ温度を取得します。
 
def getCPUTemp (self, int id)
 指定した ID の現在のCPU温度を取得します。
 
def getTrajectoryTime (self, int id)
 指定した ID の現在の補間時間を取得します。
 
def getInputVoltage (self, int id)
 指定した ID の現在の電圧を取得します。
 
def getEncoder (self, int id)
 指定した ID のエンコーダを取得します。
 
def getStatus (self, int id)
 指定した ID のステータスを取得します。
 
def getSystemStatus (self, int id)
 指定した ID のシステムステータスを取得します。
 
def getMotorStatus (self, int id)
 指定した ID のモータステータスを取得します。
 
def getRamAccessStatus (self, int id)
 指定した ID のRAMアクセスステータスを取得します。
 
def getFullStatus (self, int id)
 指定した ID の全てのステータス情報を取得します。
 
def getTorqueSwitch (self, int id)
 指定した ID のトルク ON 値を取得します。
 
def getControlMode (self, int id)
 指定した ID の制御モードを取得します。
 
def getMotorReceive (self, int id)
 指定した ID の応答データ指定値を取得します。
 
def getTrajectory (self, int id)
 指定した ID の補間制御軌道生成タイプ指定を取得します。
 
def getCenterOffset (self, int id)
 指定した ID の中央値オフセット値を取得します。
 
def getReverse (self, int id)
 指定した ID のリバース状態を取得します。
 
def getCloneReverse (self, int id)
 指定した ID のクローン/リバース値を取得します。
 
def getMinVoltageLimit (self, int id)
 指定したIDの下限電圧リミット値を取得します。
 
def getMinVoltageLimitPower (self, int id)
 指定したIDの下限リミット電圧を下回った場合の出力割合を取得します。
 
def getMaxVoltageLimit (self, int id)
 指定したIDの上限リミット電圧を取得します。
 
def getMaxVoltageLimitPower (self, int id)
 指定したIDの上限リミット電圧を超えた場合の出力割合を取得します。
 
def getCurrentLimit (self, int id)
 指定したIDの電流リミット値を取得します。
 
def getCurrentLimitPower (self, int id)
 指定したIDの電流リミットを超えた時の出力割合を取得します。
 
def getMotorTempLimit (self, int id)
 指定したIDのモータ温度リミット値を取得します。
 
def getMotorTempLimitPower (self, int id)
 指定したIDのモータ温度リミットを超えた時の出力割合を取得します。
 
def getCpuTempLimit (self, int id)
 指定したIDのCPU温度リミット値を取得します。
 
def getCpuTempLimitPower (self, int id)
 指定したIDのCPU温度リミットを超えた時の出力割合を取得します。
 
def getCwPositionLimit (self, int id)
 指定したIDのCW方向の動作角度リミット値を取得します。
 
def getCwPositionLimitPower (self, int id)
 指定したIDのCW側の角度を超えた時の出力の割合を取得します。
 
def getCcwPositionLimit (self, int id)
 指定したIDのCCW方向の動作角度リミット値を取得します。
 
def getCcwPositionLimitPower (self, int id)
 指定したIDのCCW側の角度を超えた時の出力の割合を取得します。
 
def getMaxGoalSpeed (self, int id)
 指定したIDの指令可能な最大速度値を取得します。
 
def getMaxGoalCurrent (self, int id)
 指定したIDの指令可能な最大電流値を取得します。
 
def getMaxGoalTorque (self, int id)
 指定したIDの指令可能な最大推定トルク値を取得します。
 
def getTotalPowerRate (self, int id)
 指定したIDのモータに出力する割合を取得します。
 
def getLockDetectTime (self, int id)
 指定したIDのロック検知を認識するまでの時間を取得します。
 
def getLockThresholdPower (self, int id)
 指定したIDのロック検知を開始する出力指示の閾値を取得します。
 
def getLockDetectOutputPower (self, int id)
 指定したIDがロック検知が起きた時の出力の割合を取得します。
 
def getCenterOffsetRange (self, int id)
 指定したIDの中央値オフセット(CenterOffset)の設定可能な最小/最大の範囲を取得します。
 
def getMinVoltageLimitRange (self, int id)
 指定したIDの入力最小電圧リミット値(MinVoltageLimit)の設定可能な最小/最大の範囲を取得します。
 
def getMaxVoltageLimitRange (self, int id)
 指定した ID の最大電圧(MaxVoltage)の設定可能な範囲を取得します。
 
def getCurrentLimitRange (self, int id)
 指定した ID の電流(Current)の設定可能な範囲を取得します。
 
def getMotorTempLimitRange (self, int id)
 指定した ID のモータ温度(MotorTemp)の範囲を取得します。
 
def getCpuTempLimitRange (self, int id)
 指定した ID のCPU温度の範囲(CpuTemp)を取得します。
 
def getMaxGoalSpeedRange (self, int id)
 指定した ID の最大速度指令値(MaxGoalSpeed)の設定可能な範囲を取得します。
 
def getMaxGoalCurrentRange (self, int id)
 指定した ID の最大電流指令値(MaxGoalCurrent)の設定可能な範囲を取得します。
 
def getMaxGoalTorqueRange (self, int id)
 指定した ID の最大トルク指令値(MaxGoalTorque)の設定可能な範囲を取得します。
 
def getCwPositionLimitRange (self, int id)
 指定したIDの指定したCW方向の動作角度リミット値(CwPosition)の設定可能な範囲を取得します。
 
def getCcwPositionLimitRange (self, int id)
 指定したIDの指定したCCW方向の動作角度リミット値(CcwPosition)の設定可能な範囲を取得します。
 
def printAllRange (self, int id)
 指定した ID の設定データの範囲を表示する関数
 
def getDafaultPidGain (self, int id, int pAddr)
 指定した ID の PIDゲインを取得します。
 
def getPresetAllPidGains (self, int id, int presetNum)
 指定した ID 、プリセット番号の PID ゲインを位置からトルクまで全て取得します。
 
def getPresetPidGains (self, int id, int presetNum, int gainType)
 指定した ID 、プリセット番号、ゲインタイプのPID ゲインを取得します。
 
def getAllPresetNum (self, int id)
 指定した ID のすべてのプリセット番号を取得します。
 
def getLedMode (self, int id)
 指定したID のLED点灯モードを取得します。
 
def setTorqueSwitch (self, int id, int data, writeOpt=0)
 MemWriteを利用したデータのset関数一覧
 
def setMotorReceive (self, int id, int receiveOpt, writeOpt=0)
 指定した ID のmotorREADやMotorWRITEから返信される応答モードを設定します。
 
def setControlMode (self, int id, int controlMode, writeOpt=0)
 指定した ID の位置制御などの制御モードを設定します。
 
def setDafaultPidGain (self, int id, int pidAddr, int kp, int ki, int kd, st=None, writeOpt=0)
 指定した ID のPIDゲインを変更します。
 
def setPositionPidGain (self, int id, int kp, int ki, int kd, int st, writeOpt=0)
 指定した ID のプリセット1の位置制御のPIDゲインを変更します。
 
def setSpeedPidGain (self, int id, int kp, int ki, int kd, writeOpt=0)
 指定した ID のプリセット1の速度制御のPIDゲインを変更します。
 
def setCurrentPidGain (self, int id, int kp, int ki, int kd, writeOpt=0)
 指定した ID のプリセット1の電流制御のPIDゲインを変更します。
 
def setTorquePidGain (self, int id, int kp, int ki, int kd, writeOpt=0)
 指定した ID のプリセット1のトルク制御のPIDゲインを変更します。
 
def setCenterOffset (self, int id, int CenterOffset, writeOpt=0)
 指定した ID の中央値オフセット値を設定します。
 
def setCloneReverse (self, int id, int crVal)
 指定した ID のクローン/リバースを設定します。
 
def setMinVoltageLimit (self, int id, int minVol, int limPower, writeOpt=0)
 指定した ID の下限電圧を下回った時の挙動を設定します。
 
def setMaxVoltageLimit (self, int id, int maxVol, int limPower, writeOpt=0)
 指定した ID の上限電圧を上回った時の挙動を設定します。
 
def setCurrentLimit (self, int id, int maxCur, int limPower, writeOpt=0)
 指定した ID のモータ消費電流最大値を上回った時の挙動を設定します。
 
def setMotorTempLimit (self, int id, int maxTemp, int limPower, writeOpt=0)
 指定した ID のモータ温度最大値を上回った時の挙動を設定します。
 
def setCpuTempLimit (self, int id, int maxTemp, int limPower, writeOpt=0)
 指定した ID のCPU温度最大値を上回った時の挙動を設定します。
 
def setPositionLimit (self, int id, int cwPos, int ccwPos, int limitPower, writeOpt=0)
 指定した ID の最大角を上回った時の挙動を設定します。
 
def setMaxGoalSpeed (self, int id, int maxDesSpd, writeOpt=0)
 指定した ID の最大速度指令値を設定します。
 
def setMaxGoalCurrent (self, int id, int maxDesCur, writeOpt=0)
 指定した ID の最大電流指令値を設定します。
 
def setMaxGoalTorque (self, int id, int maxDesTrq, writeOpt=0)
 指定した ID の最大動推定トルク指令値を設定します。
 
def setTotalPowerRate (self, int id, int rate, writeOpt=0)
 指定した ID のモータ出力制限%値を設定します。
 
def setLockDetect (self, int id, int time, int power, int outputPower, writeOpt=0)
 指定した ID のロック時間、ロックと認識される出力割合、およびロック時間の出力%値を設定します。
 
def setTrajectory (self, int id, int data, writeOpt=0)
 指定した ID の補間制御軌道生成タイプ指定を設定します。
 
def setAllPresetNum (self, int id, int presetNum, writeOpt=0)
 指定した ID の全てのプリセット番号を設定します。
 
def setPidGains (self, int id, int presetNum, int gainType, int kp, int ki, int kd, st=None, writeOpt=0)
 ID、プリセット番号、ゲインタイプを指定し、PIDゲインを変更します。
 
def setLedMode (self, int id, int ledVal)
 指定した ID のLEDモードを設定します。
 
def setMotorTorqueOn (self, int id, int receiveMode, controlMode=0x00)
 MotorWRITEを利用したデータのset関数一覧
 
def setMotorFree (self, int id, int receiveMode, controlMode=0x00)
 指定した ID のモータをフリーにし、ステータス、モータのON/OFF、受信データを取得します。
 
def setMotorBrake (self, int id, int receiveMode, controlMode=0x00)
 指定した ID のモータをブレーキにし、ステータス、モータのON/OFF、受信データを取得します。
 
def setMotorHold (self, int id, int receiveMode, controlMode=0x00)
 指定した ID のモータをホールドにし、ステータス、モータのON/OFF、受信データを取得します。
 
def setPosition (self, int id, int receiveMode, int position, speed=None, current=None, torque=None, time=None)
 指定した ID のモータの位置、速度、電流、トルク、および時間パラメーターを設定し、データをモーター コントローラーに送信します。
 
def getSerialNumber (self, int id)
 指定したIDのサーボからシリアル番号を取得します。
 
def getModelNum (self, int id)
 指定したIDのサーボからモデル番号を取得します。
 
def getVersion (self, int id)
 指定したIDからファームウェアのバージョン番号を取得します。
 
def getResponseTime (self, int id)
 システム読み取り操作のステータスと応答時間を取得します。
 
def setId (self, int id, int newId, serialNum=None)
 SystemWriteを利用したデータのset関数一覧
 
def setBaudrate (self, int id, int newBaudrate, serialNum=None)
 指定したIDの通信速度を設定します
 
def setParity (self, int id, int newParity, serialNum=None)
 指定したIDのパリティを設定します
 
def setResponseTime (self, int id, int newResponseTime, serialNum=None)
 指定したIDの応答時間を設定します
 

限定公開変数類

 _isSynchronize
 
 _logOutput
 
 _com
 

静的限定公開変数類

bool _isSynchronize = False
 
int _com = 0
 
bool _logOutput = False
 

その他の継承メンバ

- 基底クラス PmxLib.PmxLib に属する継承静的公開メンバ関数
def defaultMakeCmd (int id, int cmd, header=0xfe)
 通常のPMXのコマンドを作る関数です。
 
def checkRecv (rxBuff, int cmd, header=0xfe)
 checkRecv関数は、受信パケットのヘッダー、パケット長、およびコマンドをチェックします。
 

詳解

PMXで使用する関数や定義をひとまとまりにしたもので、PySerialを使用して動作します。

・PMXの固有値の定義 ・PMXのコマンドの生成、チェックおよび送受信(送信部分は外部依存) ・PMXで必要だと思われる機能の関数化 ・通信部分はPySerialを使用しています をしています

注意
PySerialは別途インポートしてください。

構築子と解体子

◆ __init__()

def PmxPySerialClass.PmxPySerialClass.__init__ (   self)

メソッド詳解

◆ close()

def PmxPySerialClass.PmxPySerialClass.close (   self)

開いている_comポートを閉じる

戻り値
閉じるのが成功したかどうかの状態を返す

◆ logOutput() [1/2]

def PmxPySerialClass.PmxPySerialClass.logOutput (   self)

◆ logOutput() [2/2]

def PmxPySerialClass.PmxPySerialClass.logOutput (   self,
  value 
)

通信のログを16進数で出力する設定をする

引数
valueTrue:ログ出力,False:ログを出力しない

◆ open()

def PmxPySerialClass.PmxPySerialClass.open (   self,
  comName,
  baudrate = 115200,
  parity = serial.PARITY_NONE,
  timeout = 1.0 
)

SerialポートをPMXの設定に合わせて開く

引数
comNameポートの名前
baudrate通信速度
parityパリティ
timeout受信タイムアウト
戻り値
True:Open成功 False:Open失敗
覚え書き
Serialポートを開く openできなかったらFalseを返す

◆ setSerialParameters()

def PmxPySerialClass.PmxPySerialClass.setSerialParameters (   self,
  baudrate = None,
  parity = None,
  timeout = None 
)

PySerialで使用する通信速度、パリティ、タイムアウトなどのシリアル パラメータを設定します。

引数
baudrate通信速度
parityパリティ
timeoutタイムアウト(sec単位(float型))

PmxLib.PmxLibを再実装しています。

◆ synchronize()

def PmxPySerialClass.PmxPySerialClass.synchronize (   self,
  txBuf,
  rxLen 
)

PySerialを使用してtxBufのコマンドを送受信します

引数
txBuf送信データ
rxLen受信データ数
戻り値
受信データ

PmxLib.PmxLibを再実装しています。

◆ synchronizeNoRead()

def PmxPySerialClass.PmxPySerialClass.synchronizeNoRead (   self,
  txBuf 
)

ブロードキャストIDなどでデータの返事がないとわかっている時に送信をします。

引数
txBuf送信データ
戻り値
True:送信成功、False:送信失敗

PmxLib.PmxLibを再実装しています。

◆ synchronizeVariableRead()

def PmxPySerialClass.PmxPySerialClass.synchronizeVariableRead (   self,
  txBuf 
)

PySerialを使用してtxBufのコマンドを送受信します 返信データ数がわからない場合に使用します。

引数
txBuf送信データ
戻り値
受信データ
覚え書き
データを読む際、6byte目にLengthがあるので、まずは6byte取得する
Lengthを取得できたらそのデータをもとに全てのデータを取得する
データが来ない場合もあるのでTimeoutでエラー処理も行う

PmxLib.PmxLibを再実装しています。

メンバ詳解

◆ _com [1/2]

int PmxPySerialClass.PmxPySerialClass._com = 0
staticprotected

◆ _com [2/2]

PmxPySerialClass.PmxPySerialClass._com
protected

◆ _isSynchronize [1/2]

bool PmxPySerialClass.PmxPySerialClass._isSynchronize = False
staticprotected

◆ _isSynchronize [2/2]

PmxPySerialClass.PmxPySerialClass._isSynchronize
protected

◆ _logOutput [1/2]

bool PmxPySerialClass.PmxPySerialClass._logOutput = False
staticprotected

◆ _logOutput [2/2]

PmxPySerialClass.PmxPySerialClass._logOutput
protected

このクラス詳解は次のファイルから抽出されました: