Week 31. 23/3/2021

4 minute read

Hello!

This week I had done:

  • I made a video for kibotics ‘Busca Objecto con Drones’ it will be uploaded on friday.

  • Gripper now works for D1 Kibotics Gripper parts are child, static for mbot in the config_gripper.json file HAL API controls the open and close of the grippers.

  • Little improvement the grippers are more open for taking the can.

-Also Roomba is refactored by David so now all is ok

changes in files:

   brains/miniproxy-worker.js
    @@ -32,6 +32,14 @@ export class miniProxy {
                    await eval("myRobot." + message.function + "()");
                    worker.postMessage({message: "finished"});
                    break;
                case "takeObject":
                    await eval("myRobot." + message.function + "()");
                    worker.postMessage({message: "finished"});
                    break;
                case "leaveObject":
                    await eval("myRobot." + message.function + "()");
                    worker.postMessage({message: "finished"});
                    break;
                    
                    
  simcore/robots/interfacesRobot.js
          @@ -1,7 +1,7 @@
          import {simEnabled} from '../globals';
          import {
              advance, advanceTo, setV, setW, setL, move, upTo, downTo, turnUpTo, land, takeOff, getV, getW, getL,
              getDistance, getDistances, readIR
              getDistance, getDistances, readIR, takeObject, leaveObject
          } from './robotAPI/HALRobotAPI'
          import {
              getImage/*, getColoredObject, getObjectColorRGB, getObjectColorPositionRGB, getColorCode*/
          @@ -515,6 +515,8 @@ RobotI.prototype.getL = getL;
          RobotI.prototype.getDistance = getDistance;
          RobotI.prototype.getDistances = getDistances;
          RobotI.prototype.readIR = readIR;
          RobotI.prototype.takeObject = takeObject;
          RobotI.prototype.leaveObject = leaveObject
         
         
         
         
  simcore/robots/robotAPI/HALRobotAPI.js
      @@ -215,7 +215,29 @@ export function readIR() {
          }
          return outputVal;
      }
      export async function takeObject() {
          let thread = getThread(this.myRobotID);
          thread.blocking_instruction = true;
          let gripperLeft = document.querySelector("#gripper-left")
          let gripperLeftPos = gripperLeft.object3D.position
          let gripperRight = document.querySelector("#gripper-right")
          let gripperRightPos = gripperRight.object3D.position
          let val = 0.025
          while (getThread(this.myRobotID).status !== "RELOADING" && gripperLeftPos.x < -0.010 && gripperRightPos.x > 0.010) {
              val = val - 0.001
              await document.querySelector("#gripper-left").setAttribute('position', {x: -val, y:0 , z: -0.05})
              await document.querySelector("#gripper-right").setAttribute('position', {x: val, y:0 , z: -0.05})
              await this.sleep(1);
          }
          thread.blocking_instruction = false;

      }

      export async function leaveObject() {
          await document.querySelector("#gripper-left").setAttribute('position', {x: -0.030, y:0 , z: -0.05})
          await document.querySelector("#gripper-right").setAttribute('position', {x: 0.030, y:0 , z: -0.05})

      }
      module.exports = {
          advance,
          advanceTo,
      @@ -232,5 +254,7 @@ module.exports = {
          getW,
          getDistance,
          getDistances,
          readIR
      };
          readIR,
          takeObject,
          leaveObject
      };
      17 simcore/robots/robotAPIWW/HALRobotAPIWW.js
      @@ -173,6 +173,23 @@ function addHALMethods(myRobot) {
              postMessage({message: "lineal", function: "setW", parameter: turningSpeed});
          };

          myRobot.takeObject = async function() {
              postMessage({message: "takeObject", function: "takeObject"});
          };

          myRobot.cogerObjeto = async function() {
              this.takeObject();
          };
          myRobot.leaveObject = async function() {
              postMessage({message: "leaveObject", function: "leaveObject"});
          };

          myRobot.dejarObjeto = async function() {
              this.leaveObject();
          };

          return myRobot;
      }
      
      
      
      I add new gripper models made in Blender and the config file is:
      
      
      
       assets/config/config_gripper.json
        @@ -0,0 +1,227 @@
        {
          "scene-parent-id": "myIFrame",
          "scene": {
            "id": "scene",
            "gravity": -9.8,
            "ground": "../assets/textures/handkerchief.png",
            "sky": "../assets/textures/sky.png",
            "background": "color: gray;",
            "inspector": "url: https://aframe.io/releases/0.4.0/aframe-inspector.min.js",
            "embedded": true,
            "physics": "debug: true; friction:0.0001",
            "renderer":"colorManagement: true"
          },
          "robots_config": [
            {
              "controller": "user1",
              "id": "a-pibot"
            }
          ],
          "assets": [
            {
              "tag": "img",
              "attr": {
                "id": "ground",
                "alt": "Texture for the scene ground",
                "src": "../assets/textures/handkerchief.png"
              }
            },
            {
              "tag": "a-asset-item",
              "attr": {
                "id": "model-pibot"
              }
            },
            {
              "tag": "a-asset-item",
              "attr": {
                "id": "model-can"
              }
            },
        {
              "tag": "a-asset-item",
              "attr": {
                "id": "model-gripper"
              }
            },
            {
              "tag": "img",
              "attr": {
                "id": "sky",
                "alt": "Texture for the scene ground",
                "src": "../assets/textures/sky.png"
              }
            }
          ],
          "objects":[
            {
              "tag": "a-entity",
              "attr": {
                "id":"object",
                "gltf-model":"../assets/models/can.gltf",
                "position": { "x":-32, "y":0.5, "z":-6},
                "scale": { "x":0.3, "y":0.3, "z":0.3},
                "body":{"type": "dynamic", "mass": 1000, "shape":"cylinder"}

              }
            },



            {
              "tag": "a-entity",
              "attr": {
                "id": "sceneCamWrapper",
                "position":{ "x":1, "y":9, "z":15},
                "rotation": { "x":0, "y":0, "z":0},
                "movement-controls": "fly:true"
              },
              "childs": [
                {
                  "tag": "a-camera",
                  "attr": {
                    "id": "sceneCam",
                    "position": { "x":0, "y":0, "z":0},
                    "rotation": { "x":0, "y":0, "z":0},
                    "active": true,
                    "wasd-controls-enabled": true,
                    "look-controls-enabled": true
                  }
                }
              ]
            },
            {
              "tag": "a-robot",
              "attr": {
                "id": "a-pibot",
                "gltf-model":"../assets/models/mbot_base.gltf",
                "scale": { "x":25, "y":25, "z":25},
                "position": { "x":-35, "y":0.5, "z":-6},
                "rotation": { "x":0, "y":0, "z":0},
                "dynamic-body":{"mass": 100,"shape":"none"},
                "shape__main":{"shape": "box",
                  "halfExtents": "0.055 0.04 0.05",
                  "offset": "-0.025 0.04 0"}


              },
              "childs": [
                {
                  "tag": "a-entity",
                  "attr": {
                    "id": "a-pibotCamera1Wrapper",
                    "position": { "x": 0.02, "y": 0.025, "z": 0},
                    "rotation": { "x": 0, "y":-90, "z":0}
                  },
                  "childs": [
                    {
                      "tag": "a-camera",
                      "attr": {
                        "id": "a-pibotCamera1",
                        "position": { "x":0, "y":0, "z":0},
                        "rotation": { "x":0, "y":0, "z":0},
                        "active": false,
                        "spectator": "canvas:#spectatorDiv; canvasID: a-pibotCamera1Canvas;",
                        "wasd-controls-enabled": false,
                        "look-controls-enabled": false
                      }
                    },

                    {
                      "tag": "a-entity",
                      "attr": {
                        "id":"gripper-left",
            "gltf-model":"../assets/models/gripperv4.gltf",
                        "position": { "x":-0.033, "y":0, "z":-0.05},
                        "scale": { "x":0.005, "y":0.005, "z":0.006},
                        "rotation": { "x": 0, "y":-8, "z":180},
                        "body":{"type": "static", "mass": 10, "shape":"none"},
                        "shape__main":{"shape": "box",
                     "halfExtents": "1.5 1.5 6.5",
                                       "offset": "0 0 0"},
            "shape__handle":{"shape": "box",
                                 "halfExtents": "1.5 1 1",
                                 "offset": "-2.2 -0.2 1.75"}
                      }
                    },
                    {
                      "tag": "a-box",

                      "attr": {
                        "id":"gripper-right",
            "gltf-model":"../assets/models/gripperv4.gltf",
                        "position": { "x":0.033, "y":0, "z":-0.05},
                        "scale": { "x":0.005, "y":0.005, "z":0.006},
                        "rotation": { "x": 0, "y":8, "z":0},
                        "body":{"type": "static", "mass": 10, "shape":"none"},
                        "shape__main":{"shape": "box",
                     "halfExtents": "1.5 1.5 6.5",
                                       "offset": "0 0 0"},
            "shape__handle":{"shape": "box",
                                 "halfExtents": "1.5 1 1",
                                 "offset": "-2.2 -0.2 1.75"}
                      }

                    },

                    {
                      "tag": "a-camera-IR",
                      "attr": {
                        "id": "camera-IR",
                        "position": { "x":0, "y":-0.02, "z":0.01},
                        "rotation": { "x":-40, "y":0, "z":0},
                        "active": false,
                        "wasd-controls-enabled": false,
                        "look-controls-enabled": false
                      }
                    }
                  ]
                }
              ]
            },
            {
              "tag": "a-plane",
              "attr": {
                "static-body": {
                  "mass": 10
                },
                "position": { "x":0, "y":0, "z":-4 },
                "rotation": { "x":-90, "y":0, "z":0 },
                "width": "100",
                "height": "100",
                "src":"#ground"


              }
            },
            {
              "tag": "a-entity",
              "attr": {
                "iterations": {
                  "id": "a-componentAux",
                  "count": "0",
                  "position": {"x": 0, "y": 0, "z":0}
                }
              }
            },
            {
              "tag": "a-sky",
              "attr": {
                "src": "#sky"
              }
            },
            {
              "tag": "a-entity",
              "attr": {
                "light": {"type":"ambient","color":"#fff"}
              }
            },
            {
              "tag": "a-entity",
              "attr": {
                "light": {"type":"point","color":"#fff"}
              }
            }

          ]
        }