Best Python code snippet using pyatom_python
sensors.py
Source:sensors.py  
...113    def __init__(self, id):114        self._id = id115        self._def_op_mode = sim.simx_opmode_oneshot_wait116    def proximity(self, name: str) -> ProximitySensor:117        handle = self._get_object_handle(name)118        if handle is not None:119            if self._check_object_type(handle, sim.sim_object_proximitysensor_type):120                return ProximitySensor(self._id, handle)121            else:122                raise MatchObjTypeError(name)123        else:124            raise NotFoundComponentError(name)125    def position(self, name: str) -> PositionSensor:126        handle = self._get_object_handle(name)127        if handle is not None:128            return PositionSensor(self._id, handle)129        else:130            raise NotFoundComponentError(name)131    def vision(self, name: str) -> VisionSensor:132        handle = self._get_object_handle(name)133        if handle is not None:134            if self._check_object_type(handle, sim.sim_object_visionsensor_type):135                return VisionSensor(self._id, handle)136            else:137                raise MatchObjTypeError(name)138        else:139            raise NotFoundComponentError(name)140    def force(self, name: str) -> ForceSensor:141        handle = self._get_object_handle(name)142        if handle is not None:143            if self._check_object_type(handle, sim.sim_object_forcesensor_type):144                return ForceSensor(self._id, handle)145            else:146                raise MatchObjTypeError(name)147        else:148            raise NotFoundComponentError(name)149    def _get_sensor(self, name, sensor_type, ctr):150        handle = self._get_object_handle(name)151        if handle is not None:152            if self._check_object_type(handle, sensor_type):153                return ctr(self._id, handle)154            else:155                raise MatchObjTypeError(name)156        else:157            raise NotFoundComponentError(name)158    def _check_object_type(self, handle, obj_type):159        code, handles, _, _, _ = sim.simxGetObjectGroupData(160            self._id, obj_type, 0, self._def_op_mode)161        return handles.__contains__(handle)162    def _get_object_handle(self, name):163        code, handle = sim.simxGetObjectHandle(self._id, name, self._def_op_mode)164        if code == sim.simx_return_ok:165            return handle166        else:167            return None...vrepController.py
Source:vrepController.py  
...18            'x': self._start_float_signal('accX'),19            'y': self._start_float_signal('accY'),20            'z': self._start_float_signal('accZ')21        }22        self.wheel_handle = self._get_object_handle('JuntaRoda_MT')23        self.weight_handle = self._get_object_handle('JuntaGiros_MT')24        self.body_handle = self._get_object_handle('RoboGiros')25        self.target_handle = self._get_object_handle('Target')26        self.floor_handle = self._get_object_handle('FloorElement')27        self.get_robot_position()28        self.set_target([self.robot_position[0], self.robot_position[1], 0])29        self.started = False30        self.wheel_vel = 031        self.update_wheel()32        self.weight_pos = 033        self.update_weight()34    def _start_float_signal(self, name):35        returnCode, data = vrep.simxGetFloatSignal(self.clientID, name,36                                                   vrep.simx_opmode_streaming)37        return data38    def _get_float_signal(self, name):39        returnCode, data = vrep.simxGetFloatSignal(self.clientID, name,40                                                   self.default_opmode)41        return data42    def _get_object_handle(self, name):43        returnCode, handle = vrep.simxGetObjectHandle(self.clientID, name,44                                                      self.default_opmode)45        return handle46    def _set_joint_velocity(self, handle, val):47        returnCode = vrep.simxSetJointTargetVelocity(self.clientID, handle, val,48                                                     self.default_opmode)49        return returnCode50    def _set_joint_position(self, handle, val):51        returnCode = vrep.simxSetJointTargetPosition(self.clientID, handle, val,52                                                     self.default_opmode)53        return returnCode54    def _get_object_position(self, handle, relativeTo=-1):55        returnCode, position = vrep.simxGetObjectPosition(self.clientID, handle, relativeTo,56                                                          self.default_opmode)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
