コード例 #1
0
    def startSensors(self, timestep):

        # Instantiate objects and start up GPS, Gyro, and Compass sensors
        # For more details, refer to the Webots documentation
        self.gps = GPS("gps")
        self.gps.enable(timestep)

        self.gyro = Gyro("gyro")
        self.gyro.enable(timestep)

        self.compass = Compass("compass")
        self.compass.enable(timestep)
コード例 #2
0
    def startSensors(self, timestep):
        """ Start sensors.

        Instantiate objects and start up GPS, Gyro, IMU sensors.

        For more details, refer to the Webots documentation.

        Args: 
            timestep (int): time step of the current world.

        """
        self.gps = GPS("gps")
        self.gps.enable(timestep)

        self.gyro = Gyro("gyro")
        self.gyro.enable(timestep)

        self.imu = InertialUnit("inertial unit")
        self.imu.enable(timestep)

        self.timestep = timestep
コード例 #3
0
ファイル: my_controller.py プロジェクト: ex7763/step
def move_forward():
    motor_lst[1 + 0*3].setPosition(math.pi * -1 / 8)
    motor_lst[1 + 0*3].setVelocity(1.0)
    
def rotate(angle):
    for i in range(6):
        motor_lst[0 + i*3].setPosition(angle)
        motor_lst[0 + i*3].setVelocity(1.0)

camera = Camera("camera_d435i")
camera.enable(15)
print(camera.getSamplingPeriod())
camera.saveImage("~/test.png", 100)

gyro = Gyro("gyro")
gyro.enable(60)

inertial_unit = InertialUnit("inertial_unit")
inertial_unit.enable(60)

# Main loop:
# - perform simulation steps until Webots is stopping the controller
def default_low_pos():
    for i in range(6):
        motor_lst[0 + i*3].setPosition(0)
        motor_lst[0 + i*3].setVelocity(1.0)
    
        motor_lst[1 + i*3].setPosition(math.pi * 1 / 8)
        motor_lst[1 + i*3].setVelocity(1.0)