当前位置: 首页>>代码示例>>Python>>正文


Python carla.VehicleControl方法代码示例

本文整理汇总了Python中carla.VehicleControl方法的典型用法代码示例。如果您正苦于以下问题:Python carla.VehicleControl方法的具体用法?Python carla.VehicleControl怎么用?Python carla.VehicleControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在carla的用法示例。


在下文中一共展示了carla.VehicleControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_vehicle_control

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def on_vehicle_control(self, data):
        """
        callback if a new vehicle control command is received
        """
        cmd = carla.VehicleControl()
        cmd.throttle = data.throttle
        cmd.steer = data.steer
        cmd.brake = data.brake
        cmd.hand_brake = data.hand_brake
        cmd.reverse = data.reverse
        cmd.gear = data.gear
        cmd.manual_gear_shift = data.manual_gear_shift
        self.current_control = cmd
        if not self.vehicle_control_event.is_set():
            self.vehicle_control_event.set()
        # After the first vehicle control is sent out, it is possible to use the stepping mode
        self.step_mode_possible = True 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:19,代码来源:ros_agent.py

示例2: _reset_world

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def _reset_world(self, soft=False):
        # init actor
        if not soft:
            spawn_point = env_utils.random_spawn_point(self.map)
        else:
            spawn_point = self.spawn_point

        if self.vehicle is None:
            blueprint = env_utils.random_blueprint(self.world, actor_filter=self.vehicle_filter)
            self.vehicle = env_utils.spawn_actor(self.world, blueprint, spawn_point)  # type: carla.Vehicle

            self._create_sensors()
            self.synchronous_context = CARLASyncContext(self.world, self.sensors, fps=self.fps)
        else:
            self.vehicle.apply_control(carla.VehicleControl())
            self.vehicle.set_velocity(carla.Vector3D(x=0.0, y=0.0, z=0.0))
            self.vehicle.set_transform(spawn_point)

        # reset reward variables
        self.collision_penalty = 0.0 
开发者ID:tensorforce,项目名称:tensorforce,代码行数:22,代码来源:carla_environment.py

示例3: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self, input_data, timestamp):
        # Get the current directions for following the route
        directions = self._get_current_direction(input_data['GPS'][1])
        logging.debug("Directions {}".format(directions))

        # Take the forward speed and normalize it for it to go from 0-1
        norm_speed = input_data['can_bus'][1]['speed'] / g_conf.SPEED_FACTOR
        norm_speed = torch.cuda.FloatTensor([norm_speed]).unsqueeze(0)
        directions_tensor = torch.cuda.LongTensor([directions])
        # Compute the forward pass processing the sensors got from CARLA.
        model_outputs = self._model.forward_branch(self._process_sensors(input_data['rgb'][1]),
                                                   norm_speed,
                                                   directions_tensor)

        steer, throttle, brake = self._process_model_outputs(model_outputs[0])
        control = carla.VehicleControl()
        control.steer = float(steer)
        control.throttle = float(throttle)
        control.brake = float(brake)
        logging.debug("Output ", control)
        # There is the posibility to replace some of the predictions with oracle predictions.
        self.first_iter = False
        return control 
开发者ID:felipecode,项目名称:coiltraine,代码行数:25,代码来源:CoILBaseline.py

示例4: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self, target_speed, waypoint):
        """
        Execute one step of control invoking both lateral and longitudinal PID controllers to reach a target waypoint
        at a given target_speed.

        :param target_speed: desired vehicle speed
        :param waypoint: target location encoded as a waypoint
        :return: distance (in meters) to the waypoint
        """
        throttle = self._lon_controller.run_step(target_speed)
        steering = self._lat_controller.run_step(waypoint)

        control = carla.VehicleControl()
        control.steer = steering
        control.throttle = throttle
        control.brake = 0.0
        control.hand_brake = False
        control.manual_gear_shift = False

        return control 
开发者ID:praveen-palanisamy,项目名称:macad-gym,代码行数:22,代码来源:controller.py

示例5: control_command_updated

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def control_command_updated(self, ros_vehicle_control, manual_override):
        """
        Receive a CarlaEgoVehicleControl msg and send to CARLA

        This function gets called whenever a ROS CarlaEgoVehicleControl is received.
        If the mode is valid (either normal or manual), the received ROS message is
        converted into carla.VehicleControl command and sent to CARLA.
        This bridge is not responsible for any restrictions on velocity or steering.
        It's just forwarding the ROS input to CARLA

        :param manual_override: manually override the vehicle control command
        :param ros_vehicle_control: current vehicle control input received via ROS
        :type ros_vehicle_control: carla_msgs.msg.CarlaEgoVehicleControl
        :return:
        """
        if manual_override == self.vehicle_control_override:
            vehicle_control = VehicleControl()
            vehicle_control.hand_brake = ros_vehicle_control.hand_brake
            vehicle_control.brake = ros_vehicle_control.brake
            vehicle_control.steer = ros_vehicle_control.steer
            vehicle_control.throttle = ros_vehicle_control.throttle
            vehicle_control.reverse = ros_vehicle_control.reverse
            self.carla_actor.apply_control(vehicle_control)
            self._vehicle_control_applied_callback(self.get_id()) 
开发者ID:carla-simulator,项目名称:ros-bridge,代码行数:26,代码来源:ego_vehicle.py

示例6: __init__

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def __init__(self, world, transform=carla.Transform(),
                 on_collision_fn=None, on_invasion_fn=None,
                 vehicle_type="vehicle.lincoln.mkz2017"):
        # Setup vehicle blueprint
        vehicle_bp = world.get_blueprint_library().find(vehicle_type)
        color = vehicle_bp.get_attribute("color").recommended_values[0]
        vehicle_bp.set_attribute("color", color)

        # Create vehicle actor
        actor = world.spawn_actor(vehicle_bp, transform)
        print("Spawned actor \"{}\"".format(actor.type_id))
            
        super().__init__(world, actor)

        # Maintain vehicle control
        self.control = carla.VehicleControl()

        if callable(on_collision_fn):
            self.collision_sensor = CollisionSensor(world, self, on_collision_fn=on_collision_fn)
        if callable(on_invasion_fn):
            self.lane_sensor = LaneInvasionSensor(world, self, on_invasion_fn=on_invasion_fn) 
开发者ID:bitsauce,项目名称:Carla-ppo,代码行数:23,代码来源:wrappers.py

示例7: parse_input

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def parse_input(self, clock):
        self._parse_events()
        self._parse_mouse()
        if not self._autopilot_enabled:
            if isinstance(self.control, carla.VehicleControl):
                self._parse_keys(clock.get_time())
                self.control.reverse = self.control.gear < 0
            world = module_manager.get_module(MODULE_WORLD)
            if (world.hero_actor is not None):
                world.hero_actor.apply_control(self.control) 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:12,代码来源:no_rendering_mode.py

示例8: __init__

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def __init__(self, actor, actor_reference, target_location, gain=1, name="SyncArrival"):
        """
        Setup required parameters
        """
        super(SyncArrival, self).__init__(name, actor)
        self.logger.debug("%s.__init__()" % (self.__class__.__name__))
        self._control = carla.VehicleControl()
        self._actor_reference = actor_reference
        self._target_location = target_location
        self._gain = gain

        self._control.steering = 0 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:14,代码来源:atomic_behaviors.py

示例9: setup

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def setup(self, path_to_conf_file):
        """
        Setup the agent parameters
        """

        self.agent_engaged = False
        self.current_control = carla.VehicleControl()
        self.current_control.steer = 0.0
        self.current_control.throttle = 1.0
        self.current_control.brake = 0.0
        self.current_control.hand_brake = False
        self._hic = HumanInterface(self)
        self._thread = Thread(target=self._hic.run)
        self._thread.start() 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:16,代码来源:human_agent.py

示例10: __init__

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def __init__(self):
        """
        Init
        """
        self._control = carla.VehicleControl()
        self._steer_cache = 0.0 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:8,代码来源:human_agent.py

示例11: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self, input_data, timestamp):
        """
        Execute one step of navigation.
        """
        control = carla.VehicleControl()
        control.steer = 0.0
        control.throttle = 0.0
        control.brake = 0.0
        control.hand_brake = False

        if not self._agent:
            hero_actor = None
            for actor in CarlaDataProvider.get_world().get_actors():
                if 'role_name' in actor.attributes and actor.attributes['role_name'] == 'hero':
                    hero_actor = actor
                    break
            if hero_actor:
                self._agent = BasicAgent(hero_actor)

            return control

        if not self._route_assigned:
            if self._global_plan:
                plan = []

                for transform, road_option in self._global_plan_world_coord:
                    wp = CarlaDataProvider.get_map().get_waypoint(transform.location)
                    plan.append((wp, road_option))

                self._agent._local_planner.set_global_plan(plan)  # pylint: disable=protected-access
                self._route_assigned = True

        else:
            control = self._agent.run_step()

        return control 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:38,代码来源:npc_agent.py

示例12: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self, input_data, timestamp):
        """
        Execute one step of navigation.
        :return: control
        """
        control = carla.VehicleControl()
        control.steer = 0.0
        control.throttle = 0.0
        control.brake = 0.0
        control.hand_brake = False

        return control 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:14,代码来源:autonomous_agent.py

示例13: step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def step(self, actions):
        if not self.autopilot:
            self.vehicle.apply_control(carla.VehicleControl(throttle=actions[0], steer=actions[1], brake=actions[2],
                                                            hand_brake=actions[3], reverse=actions[4],
                                                            manual_gear_shift=actions[5], gear=actions[6]))
        else:
            self.vehicle.apply_control(
                carla.VehicleControl(throttle=1, steer=0, brake=0,
                                     hand_brake=0, reverse=0,
                                     manual_gear_shift=0, gear=0))
        if len(self.fines) <= 0:
            return 1
        else:
            return self.fines.pop() 
开发者ID:garlicdevs,项目名称:Fruit-API,代码行数:16,代码来源:cl.py

示例14: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self):
        transform = self._vehicle.get_transform()

        if self.waypoints:
            # If too far off course, reset waypoint queue.
            if distance_vehicle(self.waypoints[0], transform) > 5.0 * self.radius:
                self.waypoints = []

        # Get more waypoints.
        if len(self.waypoints) < self.max_waypoints // 2:
            self.add_next_waypoints()

        # If no more waypoints, stop.
        if not self.waypoints:
            print('Ran out of waypoints; stopping.')
            control = carla.VehicleControl()
            control.throttle = 0.0
            return control


        # Remove waypoints we've reached.
        while distance_vehicle(self.waypoints[0], transform) < self.min_dist:
            self.waypoints = self.waypoints[1:]

        # Draw next waypoint
        draw_waypoints(self._vehicle.get_world(),
                           self.waypoints[:1],
                           self._vehicle.get_location().z + 1.0)

        return self.controller.run_step(self.target_speed, self.waypoints[0]) 
开发者ID:BerkeleyLearnVerify,项目名称:VerifAI,代码行数:32,代码来源:pid_agent.py

示例15: run_step

# 需要导入模块: import carla [as 别名]
# 或者: from carla import VehicleControl [as 别名]
def run_step(self):
        control = carla.VehicleControl()
        control.throttle = 0.0
        control.brake = 1.0
        control.hand_brake = True
        return control 
开发者ID:BerkeleyLearnVerify,项目名称:VerifAI,代码行数:8,代码来源:brake_agent.py


注:本文中的carla.VehicleControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。