Code Monkey home page Code Monkey logo

Comments (7)

Blyron avatar Blyron commented on June 13, 2024

This a code example for collision sensor, could you check if this is working for you? The attachment type is not necesary for sensors. After that could you check the logs? If you are not using a package they should be located in "CARLA_ROOT/Unreal/CarlaUE4/Saved/Logs"


from __future__ import print_function

import argparse
import glob
import math
import os
import sys
import time
try:
    sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
        sys.version_info.major,
        sys.version_info.minor,
        'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
    pass
try:
    sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/carla')
except IndexError:
    pass

import carla


def _on_collision(event):
    print(f"Collision with {event.other_actor.type_id}")

def main():

    client = carla.Client()
    world = client.get_world()
    bp_lib = world.get_blueprint_library()
    spectator = world.get_spectator()

    # Spawn the actor
    bp = bp_lib.filter("*walker*")[0]
    # bp.set_attribute('is_invincible', 'false')
    walker = world.spawn_actor(bp, carla.Transform(carla.Location(200.7, 199.3, 0.2), carla.Rotation()))

    bp = bp_lib.filter("*mkz_2020*")[0]
    vehicle = world.spawn_actor(bp, carla.Transform(carla.Location(177.7, 198.8, 0.2), carla.Rotation()))
    spectator.set_transform(carla.Transform(carla.Location(205.9, 193.2, 3.9), carla.Rotation(pitch=-29, yaw=135)))

    collision_bp = bp_lib.find('sensor.other.collision')
    sensor_collision = world.spawn_actor(collision_bp, carla.Transform(), attach_to=vehicle)
    sensor_collision.listen(lambda event: _on_collision(event))

    vehicle.apply_control(carla.VehicleControl(throttle=1))

    for _ in range(400):
        world.tick()

    walker.destroy()
    sensor_collision.destroy()
    vehicle.destroy()

if __name__ == '__main__':
    main()

from carla.

Blyron avatar Blyron commented on June 13, 2024

We have updated dev branch, could you update your code and then try this again to know if that is working now?

from carla.

Blyron avatar Blyron commented on June 13, 2024

Hello again, any updates? otherwise I will close this issue

from carla.

SExpert12 avatar SExpert12 commented on June 13, 2024

Okay. Thanks. Let me check this.

from carla.

Blyron avatar Blyron commented on June 13, 2024

Any updates?

from carla.

SExpert12 avatar SExpert12 commented on June 13, 2024

Hi, currently I switched to imitation learning in CARLA. So I may not need it now. But really grateful for your support. Do you have any work experience for imitation learning in CARLA?

from carla.

Blyron avatar Blyron commented on June 13, 2024

No but maybe someone does. Open a discussion or search for it in the discussions. I will be closing this issue for now.

from carla.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.