###### tags: `工作紀錄` # 工作紀錄 / 廖軒裕 ## W7D5 0814 ### Trace code (endpoint_env.py => class EndP_env3D(object): \_\_init\_\_(self)) #### 跟 webots 手臂有關的 variable `rm1_init_position` : 第 1 個 motor 的起始位置 `rm2_init_position` : 第 2 個 motor 的起始位置 `rm3_init_position` : 第 3 個 motor 的起始位置 `rm4_init_position` : 第 4 個 motor 的起始位置 `HJ2` : jointParameters of HingeJoint 2 `HJ4` : jointParameters of HingeJoint 4 `JP2_GP` : anchor of HingeJoint 2 `JP4_GP` : anchor of HingeJoint 4 `ENDP` : endpoint node `base` : 神秘的 [0, 0, -0.02] `origin` : JP2_GP + base `goal_np_p` : 隨機出來的 goal position (based on 轉成 x, -z, y 的 origin) `HJN1` : jointParameters of HingeJoint 1 `HJN2` : jointParameters of HingeJoint 2 `HJN3` : jointParameters of HingeJoint 3 `HJN4` : jointParameters of HingeJoint 4 `JP1` : position of HingeJoint 1 `JP2` : position of HingeJoint 2 `JP3` : position of HingeJoint 3 `JP4` : position of HingeJoint 4 #### note `HJ2` 跟 `HJN2` 其實是一樣的 `lives` 不會用到但 return 時會回傳 `P2`, `P4`, `accumulated_reward`, `arrival_time`, `start_time` 都完全不會用到,看要不要刪掉 ## W6D2 0804 ### Trace Code [學長的code (Dopamine to Webots) in our github](https://github.com/CT-Lab/Dopamine_Webots/tree/master/controllers) #### endpoint_env.py ##### class EndP_env3D(object): _get_reward(self) - 初始化 reward : r = $-\sqrt{d[0] ^ 2 + d[1] ^ 2 + d[2] ^ 2}$ > d = goal_position - endpoint_position > goal_position 在 EndP_env3D init 時會隨機賦值 - 決定是否更新 reward 並維護 done : 若 endpoint_position 的 x, y, z 值分別都介於 goal_position 正負 0.1 之間,則 `reward += 1` 並且 `on_goal += 1` ,反之 `on_goal = 0` > on_goal 超過 100 時, `done = True` (連續超過 100 次維持在範圍內才判定為成功到達目標) - return reward 值 ##### class EndP_env3D(object): step(self, action_dict) - 將傳進來的 `action_dict` 進行 [clip](https://numpy.org/doc/stable/reference/generated/numpy.clip.html) - 利用 `action_dict` 以 `setPosition` 更新各個 joint 的角度 - 檢查各個 joint 的角度是否超過界線 (arm_position_max, arm_position_min) ,若超過則 `done = True` 、`reward -= 1` - return information > `lives` 在 code 中完全沒有作用,可以無視 ## W5D2 0728 設計兩種運動軌跡,[連結](https://github.com/CT-Lab/IKcontrol/tree/motion-adjustment)內有 code, README 發現 step 好像會影響模擬蠻多的,先把 reference 放著方便之後查找 https://cyberbotics.com/doc/reference/robot?tab-language=python#wb_robot_step https://cyberbotics.com/doc/reference/worldinfo?tab-language=python ## W4D5 0724 使用 inverse_kinematics_frame (相較於 inverse_kinematics 多考慮每一個 joint 的 position) 的 controller code : http://codepad.org/tAvpj7De ## W4D3 0722 ### 看範例 controller code - 為何 Chain 中只到 E motor ,但 motors 中卻到 F motor - DEF 找不到 ```python # Get the arm and target nodes. target = supervisor.getFromDef('TARGET') arm = supervisor.getFromDef('ARM') ``` > ARM : 整隻手臂 ( DEF ARM Robot ) > TARGET : 球 ( DEF TARGET Solid ) - 為何只需要 the 3 first arm motors ```python # Actuate the 3 first arm motors with the IK results. for i in range(3): motors[i].setPosition(ikResults[i + 1]) ``` ## W4D2 0721 ### [Webots C++/Java/Python APIs](https://cyberbotics.com/doc/guide/cpp-java-python) 重點整理 - The controller class should derive from the `Robot` class if the `supervisor` field of the Robot node is `FALSE` and from the `Supervisor` class if it is `TRUE`. - `Supervisor` is a subclass of the `Robot` class, hence it is possible to call the `Robot`'s methods from the `Supervisor` controllers. - user-defined controller (python) : 1. create an instance of the user-defined controller class > robot = Robot() 2. main controller loop - controller should never create more than one instance of a derived class, otherwise the results are undefined. - In C++/Java/Python, each Webots device is implemented as a separate class, the various devices instances can be obtained with dedicated methods of the `Robot` class, like the `getDistanceSensor` or the `getTouchSensor` functions. There is no `WbDeviceTag` in C++/Java/Python. ## W4D1 0720 ### 可能會用到的資料 https://cyberbotics.com/doc/guide/cpp-java-python https://cyberbotics.com/doc/reference/supervisor?tab-language=python https://cyberbotics.com/doc/reference/robot?tab-language=python https://cyberbotics.com/doc/guide/supervisor-programming ### docs 中對於範例 code 用到的 attribute 的說明 translation_vector : In URDF, attribute “xyz” of the “origin” element orientation : In URDF, attribute “rpy” of the “origin” element rotation : In URDF, attribute “xyz” of the “axis” element ### 疑問 在 [此網頁的 3.3](https://www.guyuehome.com/372) 中可以看到, origin.xyz, origin.rpy, axis.xyz 是 joint 的 parameters 但在 docs 中應是用在 link 上 ### 對應 translation_vector <=> jointParameters.anchor (還是 endPoint.translation ? ) > 結果我們的手臂的 anchor 都是 0 (先用 endPoint.translation 試試) orientation <=> 暫時用 [0, 0, 0] rotation <=> jointParameters.axis bounds <=> RotationalMotor.(minPosition, maxPosition) ## W3D5 0717 ~~matlab robotics toolbox 中的 SerialLink 有現成的函數,可以對機器人模型進行正逆向運動學分析~~ 嘗試參考 [docs](https://github.com/Phylliade/ikpy/wiki#creating-a-chain-manually) 模仿 [這段 code](https://ikpy.readthedocs.io/en/latest/link.html#ikpy.link.URDFLink) 手動 create 我們要的 chain (機器手臂) ? ### 可能會用到的資料 https://www.guyuehome.com/372 https://www.itread01.com/content/1547858716.html https://wiki.ros.org/urdf/XML/link https://wiki.ros.org/urdf/XML/joint ## W2D4 0709 [機器手臂資料 1](https://www.generationrobots.com/media/panda-franka-emika-datasheet.pdf)、[機器手臂資料 2](https://wiredworkers.io/wp-content/uploads/2019/06/Franka-Emika-Panda-Datasheet-may-2019.pdf) [工程師提供官網機械手臂物理參數](https://frankaemika.github.io/docs/control_parameters.html) ### 參考 gazebo 文章 [MeshLab](https://www.meshlab.net/) : 可簡化 3D 模型並以 .stl, .obj, .vrml 等格式輸出 mass, friction 皆為估計出來的 ### 參考六軸機械手臂的設定 #### JointParameters - minStop, maxStop 對應 joint position limit - springConstant, dampingConstant, staticFriction 範例都直接設定為 0 (??) ## W2D3 0708 在 webots 中設定 boundingObject 以及 physics 1. 將 DEF __1 transform to Robot 2. 對 boundingObject 右鍵 >> Add New >> 選擇作為碰撞判定方式的物體 3. physics Physics 中有 mass, centorOfMass 等數值能進行設定