0
$\begingroup$

I am trying to navigate a drone moves towards target(car) using PPO algo. after 1320 episodes, I got this message:

      WARNING: supervisor_manager: The process crashed some time after starting successfully.
Fail to allocate bitmap

in the supervisor controller, after every episode the initial position of both target and drone changes.

def reset(self):
        """
        Used to reset the world to an initial state.
        Default, problem-agnostic, implementation of reset method,
        using Webots-provided methods.
        *Note that this works properly only with Webots versions >R2020b
        and must be overridden with a custom reset method when using
        """
        
        self.simulationReset()
        self.simulationResetPhysics()
        # super.reset()
        super(Supervisor,self).step(int(self.getBasicTimeStep()))
        # Getting Car Node
        quadrant_map = {0: [7, 7], 1: [-7, 7], 2: [-7, -7], 3: [7, -7]}
        car=self.getFromDef('bmw')
        # Getting the Tranlation Field
        car_translation =car.getField('translation')
        
        # print(f'[********************car spawning in episode {self.episodeCount}]')
        # print("self.target_quadrant=",self.target_quadrant)
        
        # if self.target_quadrant % 1 == 0:
        # if self.episodeCount % 1 == 0:
        # print(f'[car spawning in quadrant {self.target_quadrant}]')
        self.x, self.y = quadrant_map[self.target_quadrant]
        self.target_quadrant = (self.target_quadrant + 1) % 4
        
        # #Translation Function   for car
        vector= [self.x,self.y,self.z]
        car_translation.setSFVec3f(vector)  # this actually changes position defined
      
      
        ###################################
        ####### Drone Rotation Code #######
        ###################################
        
        drone = self.getFromDef('Drone')
        drone_rotation = drone.getField('rotation')
        x, y, z, angle = drone_rotation.getSFRotation()
        self.angle = angle if self.angle is None else self.angle
        self.angle = np.degrees(self.angle)
        # print(self.angle)
        self.angle = self.angle + 45
        self.angle = self.angle - 360 if self.angle > 180 else self.angle
        self.angle = self.angle + 360 if self.angle < -180 else self.angle
        # print(self.angle)
        self.angle = float(np.radians(self.angle))

        vector = [x, y, z, self.angle]
        # print(vector)
        drone_rotation.setSFRotation(vector)

        return self.get_default_observation()
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.