Pytorch integration with terramechanics (#5684)
* Added sparse map reprsentation * Added pytorch for terramechanics modules * Added saving loading particles in independent thread * Added blank space at the EOF * Added texture creation lambda * Moving function to component * Added input/output architecture for neural network * Filling heightmap with particles data. Adding Logging to debug * Updating Texture data at realtime * Connected 3 stages, using MPC Position to Update and Texture * Added square particle sampling. Added second model input/output scheme. Fixed start up crash. * Added new flags and fixes * Position to update not updating in material but yes in MPC * Fixed coordinate frame issues and crashes * Prepared to follow position in the 1st vehicle in map * Fixed height map alignment * Fixed large map and terrain tiles alignment * Fixed inputs for new model * Added scale factor * Fixed slow read write operations * Bug fixes * Removed debug output * Removed nvidia profinling marks * Preparing merge debug code removed, runtime working by rounding the loading data properly * Made pytorch optional module * Added TRACE_CPUPROFILER_EVENT_SCOPE to Update and UpdateTexture * Added optional pytorch conditions and macros * Removed static Path * Fixed #ifdef clause. Added missing include. * Deformation on vehicle working. Ready to start optimisation * First optimsation done. Heightmap per Tile * Updated tiles'heightmap to make their size relative to texture and tilesize * Fixed slow frames. Added functionality * Removed unecessary library links * Fixed pytorch link * Limited search to relevant tiles * Added multithreaded particle search. Fixed cuda architectures compilation * Deformation plane added * Added missing resources * Updated particle movement update methods * Spawn on runtime deformation plane * Added cachemap lock when initializing a region * Added UHeightMapDataAsset to hold heightmap data * Fixing some settings Co-authored-by: Aaron <samaniegoaaron112@gmail.com> Co-authored-by: bernatx <bernatx@gmail.com>
This commit is contained in:
parent
634066c19c
commit
a6be1a67f3
|
@ -429,7 +429,7 @@ Client constructor.
|
|||
- `port` (_int_) - TCP port where the CARLA Simulator instance is running. Default are 2000 and the subsequent 2001.
|
||||
- `worker_threads` (_int_) - Number of working threads used for background updates. If 0, use all available concurrency.
|
||||
- <a name="carla.Client.apply_batch"></a>**<font color="#7fb800">apply_batch</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**commands**</font>)
|
||||
Executes a list of commands on a single simulation step and retrieves no information. If you need information about the response of each command, use the __<font color="#7fb800">apply_batch_sync()</font>__ method. [Here](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/generate_traffic.py) is an example on how to delete the actors that appear in [carla.ActorList](#carla.ActorList) all at once.
|
||||
Executes a list of commands on a single simulation step and retrieves no information. If you need information about the response of each command, use the __<font color="#7fb800">apply_batch_sync()</font>__ method. [Here](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/generate_traffic.py) is an example on how to delete the actors that appear in [carla.ActorList](#carla.ActorList) all at once.
|
||||
- **Parameters:**
|
||||
- `commands` (_list_) - A list of commands to execute in batch. Each command is different and has its own parameters. They appear listed at the bottom of this page.
|
||||
- <a name="carla.Client.apply_batch_sync"></a>**<font color="#7fb800">apply_batch_sync</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**commands**</font>, <font color="#00a6ed">**due_tick_cue**=False</font>)<button class="SnipetButton" id="carla.Client.apply_batch_sync-snipet_button">snippet →</button>
|
||||
|
@ -1377,7 +1377,7 @@ Changes the color of each element in `lights` to the corresponding in `colors`.
|
|||
- <a name="carla.LightManager.set_day_night_cycle"></a>**<font color="#7fb800">set_day_night_cycle</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**active**</font>)
|
||||
All scene lights have a day-night cycle, automatically turning on and off with the altitude of the sun. This interferes in cases where full control of the scene lights is required, so setting this to __False__ deactivates it. It can reactivated by setting it to __True__.
|
||||
- **Parameters:**
|
||||
- `active` (_bool_) - (De)activation of the day-night cycle.
|
||||
- `active` (_bool_) - (De)activation of the day-night cycle.
|
||||
- <a name="carla.LightManager.set_intensities"></a>**<font color="#7fb800">set_intensities</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**lights**</font>, <font color="#00a6ed">**intensities**</font>)
|
||||
Changes the intensity of each element in `lights` to the corresponding in `intensities`.
|
||||
- **Parameters:**
|
||||
|
@ -2357,12 +2357,6 @@ Turns on or off lane changing behaviour for a vehicle.
|
|||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The vehicle whose settings are changed.
|
||||
- `enable` (_bool_) - __True__ is default and enables lane changes. __False__ will disable them.
|
||||
- <a name="carla.TrafficManager.auto_update_lights"></a>**<font color="#7fb800">auto_update_lights</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**do_update**</font>)
|
||||
Sets if the Traffic Manager is responsible of updating the vehicle lights, or not.
|
||||
Default is __False__. The traffic manager will not change the vehicle light status of a vehicle, unless its auto_update_status is st to __True__.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lights status is being changed.
|
||||
- `do_update` (_bool_) - If __True__ the traffic manager will manage the vehicle lights for the specified vehicle.
|
||||
- <a name="carla.TrafficManager.collision_detection"></a>**<font color="#7fb800">collision_detection</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**reference_actor**</font>, <font color="#00a6ed">**other_actor**</font>, <font color="#00a6ed">**detect_collision**</font>)
|
||||
Tunes on/off collisions between a vehicle and another specific actor. In order to ignore all other vehicles, traffic lights or walkers, use the specific __ignore__ methods described in this same section.
|
||||
- **Parameters:**
|
||||
|
@ -2404,6 +2398,17 @@ During the collision detection stage, which runs every frame, this method sets a
|
|||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The vehicle that is going to ignore walkers on scene.
|
||||
- `perc` (_float_) - Between 0 and 100. Amount of times collisions will be ignored.
|
||||
- <a name="carla.TrafficManager.keep_right_rule_percentage"></a>**<font color="#7fb800">keep_right_rule_percentage</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**perc**</font>)
|
||||
During the localization stage, this method sets a percent chance that vehicle will follow the *keep right* rule, and stay in the right lane.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose behaviour is being changed.
|
||||
- `perc` (_float_) - Between 0 and 100. Amount of times the vehicle will follow the keep right rule.
|
||||
- <a name="carla.TrafficManager.update_vehicle_lights"></a>**<font color="#7fb800">update_vehicle_lights</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**do_update**</font>)
|
||||
Sets if the Traffic Manager is responsible of updating the vehicle lights, or not.
|
||||
Default is __False__. The traffic manager will not change the vehicle light status of a vehicle, unless its auto_update_status is st to __True__.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lights status is being changed.
|
||||
- `do_update` (_bool_) - If __True__ the traffic manager will manage the vehicle lights for the specified vehicle.
|
||||
- <a name="carla.TrafficManager.vehicle_percentage_speed_difference"></a>**<font color="#7fb800">vehicle_percentage_speed_difference</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**percentage**</font>)
|
||||
Sets the difference the vehicle's intended speed and its current speed limit. Speed limits can be exceeded by setting the `perc` to a negative value.
|
||||
Default is 30. Exceeding a speed limit can be done using negative percentages.
|
||||
|
@ -2444,12 +2449,7 @@ With hybrid physics on, changes the radius of the area of influence where physic
|
|||
- <a name="carla.TrafficManager.set_osm_mode"></a>**<font color="#7fb800">set_osm_mode</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**mode_switch**=True</font>)
|
||||
Enables or disables the OSM mode. This mode allows the user to run TM in a map created with the [OSM feature](tuto_G_openstreetmap.md). These maps allow having dead-end streets. Normally, if vehicles cannot find the next waypoint, TM crashes. If OSM mode is enabled, it will show a warning, and destroy vehicles when necessary.
|
||||
- **Parameters:**
|
||||
- `mode_switch` (_bool_) – If __True__, the OSM mode is enabled.
|
||||
- <a name="carla.TrafficManager.keep_right_rule_percentage"></a>**<font color="#7fb800">keep_right_rule_percentage</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**perc**</font>)
|
||||
During the localization stage, this method sets a percent chance that vehicle will follow the *keep right* rule, and stay in the right lane.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose behaviour is being changed.
|
||||
- `perc` (_float_) - Between 0 and 100. Amount of times the vehicle will follow the keep right rule.
|
||||
- `mode_switch` (_bool_) - If __True__, the OSM mode is enabled.
|
||||
- <a name="carla.TrafficManager.set_random_device_seed"></a>**<font color="#7fb800">set_random_device_seed</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**value**</font>)
|
||||
Sets a specific random seed for the Traffic Manager, thereby setting it to be deterministic.
|
||||
- **Parameters:**
|
||||
|
@ -2462,7 +2462,7 @@ If __True__, vehicles in large maps will respawn near the hero vehicle when they
|
|||
Sets the Traffic Manager to [synchronous mode](adv_traffic_manager.md#synchronous-mode). In a [multiclient situation](adv_traffic_manager.md#multiclient), only the TM-Server can tick. Similarly, in a [multiTM situation](adv_traffic_manager.md#multitm), only one TM-Server must tick. Use this method in the client that does the world tick, and right after setting the world to synchronous mode, to set which TM will be the master while in sync.
|
||||
- **Parameters:**
|
||||
- `mode_switch` (_bool_) - If __True__, the TM synchronous mode is enabled.
|
||||
- **Warning:** <font color="#ED2F2F">_If the server is set to synchronous mode, the TM <b>must</b> be set to synchronous mode too in the same client that does the tick.
|
||||
- **Warning:** <font color="#ED2F2F">_If the server is set to synchronous mode, the TM <b>must</b> be set to synchronous mode too in the same client that does the tick.
|
||||
_</font>
|
||||
|
||||
---
|
||||
|
@ -3152,7 +3152,7 @@ Rain intensity values range from 0 to 100, being 0 none at all and 100 a heavy r
|
|||
- <a name="carla.WeatherParameters.precipitation_deposits"></a>**<font color="#f8805a">precipitation_deposits</font>** (_float_)
|
||||
Determines the creation of puddles. Values range from 0 to 100, being 0 none at all and 100 a road completely capped with water. Puddles are created with static noise, meaning that they will always appear at the same locations.
|
||||
- <a name="carla.WeatherParameters.wind_intensity"></a>**<font color="#f8805a">wind_intensity</font>** (_float_)
|
||||
Controls the strength of the wind with values from 0, no wind at all, to 100, a strong wind. The wind does affect rain direction and leaves from trees, so this value is restricted to avoid animation issues.
|
||||
Controls the strenght of the wind with values from 0, no wind at all, to 100, a strong wind. The wind does affect rain direction and leaves from trees, so this value is restricted to avoid animation issues.
|
||||
- <a name="carla.WeatherParameters.sun_azimuth_angle"></a>**<font color="#f8805a">sun_azimuth_angle</font>** (_float<small> - degrees</small>_)
|
||||
The azimuth angle of the sun. Values range from 0 to 360. Zero is an origin point in a sphere determined by Unreal Engine.
|
||||
- <a name="carla.WeatherParameters.sun_altitude_angle"></a>**<font color="#f8805a">sun_altitude_angle</font>** (_float<small> - degrees</small>_)
|
||||
|
@ -3172,7 +3172,7 @@ Controls interaction of light with large particles like pollen or air pollution
|
|||
- <a name="carla.WeatherParameters.rayleigh_scattering_scale"></a>**<font color="#f8805a">rayleigh_scattering_scale</font>** (_float_)
|
||||
Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening.
|
||||
- <a name="carla.WeatherParameters.dust_storm"></a>**<font color="#f8805a">dust_storm</font>** (_float_)
|
||||
Determines the strength of the dust storm weather. Values range from 0 to 100.
|
||||
Determines the strength of the dust storm weather. Values range from 0 to 100.
|
||||
|
||||
### Methods
|
||||
- <a name="carla.WeatherParameters.__init__"></a>**<font color="#7fb800">\__init__</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**cloudiness**=0.0</font>, <font color="#00a6ed">**precipitation**=0.0</font>, <font color="#00a6ed">**precipitation_deposits**=0.0</font>, <font color="#00a6ed">**wind_intensity**=0.0</font>, <font color="#00a6ed">**sun_azimuth_angle**=0.0</font>, <font color="#00a6ed">**sun_altitude_angle**=0.0</font>, <font color="#00a6ed">**fog_density**=0.0</font>, <font color="#00a6ed">**fog_distance**=0.0</font>, <font color="#00a6ed">**wetness**=0.0</font>, <font color="#00a6ed">**fog_falloff**=0.0</font>, <font color="#00a6ed">**scattering_intensity**=0.0</font>, <font color="#00a6ed">**mie_scattering_scale**=0.0</font>, <font color="#00a6ed">**rayleigh_scattering_scale**=0.0331</font>)
|
||||
|
@ -3191,8 +3191,7 @@ Method to initialize an object defining weather conditions. This class has some
|
|||
- `scattering_intensity` (_float_) - Controls how much the light will contribute to volumetric fog. When set to 0, there is no contribution.
|
||||
- `mie_scattering_scale` (_float_) - Controls interaction of light with large particles like pollen or air pollution resulting in a hazy sky with halos around the light sources. When set to 0, there is no contribution.
|
||||
- `rayleigh_scattering_scale` (_float_) - Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening.
|
||||
- `dust_storm` (_float_) - 0 is no dust at all, 100 a heavy dust/sand storm.
|
||||
- **Note:** <font color="#8E8E8E">_ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset, DustStorm.
|
||||
- **Note:** <font color="#8E8E8E">_ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset.
|
||||
_</font>
|
||||
|
||||
##### Dunder methods
|
||||
|
@ -3931,6 +3930,223 @@ document.getElementById("snipets-container").innerHTML = null;
|
|||
}
|
||||
</script>
|
||||
|
||||
<div id ="carla.Sensor.listen-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Sensor.listen
|
||||
</p>
|
||||
<div id="carla.Sensor.listen-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe applies a color conversion to the image taken by a camera sensor,
|
||||
# so it is converted to a semantic segmentation image.
|
||||
|
||||
# ...
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.semantic_segmentation')
|
||||
# ...
|
||||
cc = carla.ColorConverter.CityScapesPalette
|
||||
camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame, cc))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Sensor.listen-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Vehicle.set_wheel_steer_direction-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Vehicle.set_wheel_steer_direction
|
||||
</p>
|
||||
<div id="carla.Vehicle.set_wheel_steer_direction-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# Sets the appearance of the vehicles front wheels to 40°. Vehicle physics will not be affected.
|
||||
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FR_Wheel, 40.0)
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FL_Wheel, 40.0)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Vehicle.set_wheel_steer_direction-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_string-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_string
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_string-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe is a modification of lane_explorer.py example.
|
||||
# It draws the path of an actor through the world, printing information at each waypoint.
|
||||
|
||||
# ...
|
||||
current_w = map.get_waypoint(vehicle.get_location())
|
||||
while True:
|
||||
|
||||
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
|
||||
# Check if the vehicle is moving
|
||||
if next_w.id != current_w.id:
|
||||
vector = vehicle.get_velocity()
|
||||
# Check if the vehicle is on a sidewalk
|
||||
if current_w.lane_type == carla.LaneType.Sidewalk:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
|
||||
else:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
|
||||
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
|
||||
draw_transform(debug, current_w.transform, white, 60)
|
||||
|
||||
# Update the current waypoint and sleep for some time
|
||||
current_w = next_w
|
||||
time.sleep(args.tick_time)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_string-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.spawn_actor-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.spawn_actor
|
||||
</p>
|
||||
<div id="carla.World.spawn_actor-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe attaches different camera / sensors to a vehicle with different attachments.
|
||||
|
||||
# ...
|
||||
camera = world.spawn_actor(rgb_camera_bp, transform, attach_to=vehicle, attachment_type=Attachment.Rigid)
|
||||
# Default attachment: Attachment.Rigid
|
||||
gnss_sensor = world.spawn_actor(sensor_gnss_bp, transform, attach_to=vehicle)
|
||||
collision_sensor = world.spawn_actor(sensor_collision_bp, transform, attach_to=vehicle)
|
||||
lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, attach_to=vehicle)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.spawn_actor-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
</p>
|
||||
<div id="carla.World.enable_environment_objects-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe turn visibility off and on for two specifc buildings on the map
|
||||
|
||||
# Get the buildings in the world
|
||||
world = client.get_world()
|
||||
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
|
||||
|
||||
# Access individual building IDs and save in a set
|
||||
building_01 = env_objs[0]
|
||||
building_02 = env_objs[1]
|
||||
objects_to_toggle = {building_01.id, building_02.id}
|
||||
|
||||
# Toggle buildings off
|
||||
world.enable_environment_objects(objects_to_toggle, False)
|
||||
# Toggle buildings on
|
||||
world.enable_environment_objects(objects_to_toggle, True)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.TrafficLight.set_state-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.TrafficLight.set_state
|
||||
</p>
|
||||
<div id="carla.TrafficLight.set_state-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes from red to green the traffic light that affects the vehicle.
|
||||
# This is done by detecting if the vehicle actor is at a traffic light.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...# ...
|
||||
if vehicle_actor.is_at_traffic_light():
|
||||
traffic_light = vehicle_actor.get_traffic_light()
|
||||
if traffic_light.get_state() == carla.TrafficLightState.Red:
|
||||
# world.hud.notification("Traffic light changed! Good to go!")
|
||||
traffic_light.set_state(carla.TrafficLightState.Green)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.TrafficLight.set_state-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.TrafficLight.set_state.gif">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Map.get_waypoint-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Map.get_waypoint
|
||||
</p>
|
||||
<div id="carla.Map.get_waypoint-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows the current traffic rules affecting the vehicle.
|
||||
# Shows the current lane type and if a lane change can be done in the actual lane or the surrounding ones.
|
||||
|
||||
# ...
|
||||
waypoint = world.get_map().get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
|
||||
print("Current lane type: " + str(waypoint.lane_type))
|
||||
# Check current lane change allowed
|
||||
print("Current Lane change: " + str(waypoint.lane_change))
|
||||
# Left and Right lane markings
|
||||
print("L lane marking type: " + str(waypoint.left_lane_marking.type))
|
||||
print("L lane marking change: " + str(waypoint.left_lane_marking.lane_change))
|
||||
print("R lane marking type: " + str(waypoint.right_lane_marking.type))
|
||||
print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Map.get_waypoint-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.Map.get_waypoint.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.load_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.load_map_layer
|
||||
|
@ -3959,40 +4175,6 @@ world.load_map_layer(carla.MapLayer.ParkedVehicles)
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.ActorBlueprint.set_attribute-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.ActorBlueprint.set_attribute
|
||||
</p>
|
||||
<div id="carla.ActorBlueprint.set_attribute-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes attributes of different type of blueprint actors.
|
||||
|
||||
# ...
|
||||
walker_bp = world.get_blueprint_library().filter('walker.pedestrian.0002')
|
||||
walker_bp.set_attribute('is_invincible', True)
|
||||
|
||||
# ...
|
||||
# Changes attribute randomly by the recommended value
|
||||
vehicle_bp = wolrd.get_blueprint_library().filter('vehicle.bmw.*')
|
||||
color = random.choice(vehicle_bp.get_attribute('color').recommended_values)
|
||||
vehicle_bp.set_attribute('color', color)
|
||||
|
||||
# ...
|
||||
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.rgb')
|
||||
camera_bp.set_attribute('image_size_x', 600)
|
||||
camera_bp.set_attribute('image_size_y', 600)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.ActorBlueprint.set_attribute-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Client.apply_batch_sync-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Client.apply_batch_sync
|
||||
|
@ -4066,148 +4248,6 @@ for i in range(0, len(all_actors), 2):
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.WalkerAIController.stop-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.WalkerAIController.stop
|
||||
</p>
|
||||
<div id="carla.WalkerAIController.stop-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
|
||||
|
||||
# stop pedestrians (list is [controller, actor, controller, actor ...])
|
||||
for i in range(0, len(all_id), 2):
|
||||
all_actors[i].stop()
|
||||
|
||||
# destroy pedestrian (actor and controller)
|
||||
client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.WalkerAIController.stop-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_string-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_string
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_string-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe is a modification of lane_explorer.py example.
|
||||
# It draws the path of an actor through the world, printing information at each waypoint.
|
||||
|
||||
# ...
|
||||
current_w = map.get_waypoint(vehicle.get_location())
|
||||
while True:
|
||||
|
||||
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
|
||||
# Check if the vehicle is moving
|
||||
if next_w.id != current_w.id:
|
||||
vector = vehicle.get_velocity()
|
||||
# Check if the vehicle is on a sidewalk
|
||||
if current_w.lane_type == carla.LaneType.Sidewalk:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
|
||||
else:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
|
||||
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
|
||||
draw_transform(debug, current_w.transform, white, 60)
|
||||
|
||||
# Update the current waypoint and sleep for some time
|
||||
current_w = next_w
|
||||
time.sleep(args.tick_time)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_string-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Map.get_waypoint-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Map.get_waypoint
|
||||
</p>
|
||||
<div id="carla.Map.get_waypoint-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows the current traffic rules affecting the vehicle.
|
||||
# Shows the current lane type and if a lane change can be done in the actual lane or the surrounding ones.
|
||||
|
||||
# ...
|
||||
waypoint = world.get_map().get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
|
||||
print("Current lane type: " + str(waypoint.lane_type))
|
||||
# Check current lane change allowed
|
||||
print("Current Lane change: " + str(waypoint.lane_change))
|
||||
# Left and Right lane markings
|
||||
print("L lane marking type: " + str(waypoint.left_lane_marking.type))
|
||||
print("L lane marking change: " + str(waypoint.left_lane_marking.lane_change))
|
||||
print("R lane marking type: " + str(waypoint.right_lane_marking.type))
|
||||
print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Map.get_waypoint-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.Map.get_waypoint.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.TrafficLight.set_state-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.TrafficLight.set_state
|
||||
</p>
|
||||
<div id="carla.TrafficLight.set_state-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes from red to green the traffic light that affects the vehicle.
|
||||
# This is done by detecting if the vehicle actor is at a traffic light.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...# ...
|
||||
if vehicle_actor.is_at_traffic_light():
|
||||
traffic_light = vehicle_actor.get_traffic_light()
|
||||
if traffic_light.get_state() == carla.TrafficLightState.Red:
|
||||
# world.hud.notification("Traffic light changed! Good to go!")
|
||||
traffic_light.set_state(carla.TrafficLightState.Green)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.TrafficLight.set_state-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.TrafficLight.set_state.gif">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.unload_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.unload_map_layer
|
||||
|
@ -4234,37 +4274,6 @@ world.unload_map_layer(carla.MapLayer.ParkedVehicles)
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_box-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_box
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_box-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows how to draw traffic light actor bounding boxes from a world snapshot.
|
||||
|
||||
# ....
|
||||
debug = world.debug
|
||||
world_snapshot = world.get_snapshot()
|
||||
|
||||
for actor_snapshot in world_snapshot:
|
||||
actual_actor = world.get_actor(actor_snapshot.id)
|
||||
if actual_actor.type_id == 'traffic.traffic_light':
|
||||
debug.draw_box(carla.BoundingBox(actor_snapshot.get_transform().location,carla.Vector3D(0.5,0.5,2)),actor_snapshot.get_transform().rotation, 0.05, carla.Color(255,0,0,0),0)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_box-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.DebugHelper.draw_box.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Client.__init__-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Client.__init__
|
||||
|
@ -4310,102 +4319,27 @@ Snippet for carla.Client.__init__
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Vehicle.set_wheel_steer_direction-snipet" style="display: none;">
|
||||
<div id ="carla.WalkerAIController.stop-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Vehicle.set_wheel_steer_direction
|
||||
Snippet for carla.WalkerAIController.stop
|
||||
</p>
|
||||
<div id="carla.Vehicle.set_wheel_steer_direction-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# Sets the appearance of the vehicles front wheels to 40°. Vehicle physics will not be affected.
|
||||
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FR_Wheel, 40.0)
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FL_Wheel, 40.0)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Vehicle.set_wheel_steer_direction-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Sensor.listen-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Sensor.listen
|
||||
</p>
|
||||
<div id="carla.Sensor.listen-code" class="SnipetContent">
|
||||
<div id="carla.WalkerAIController.stop-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe applies a color conversion to the image taken by a camera sensor,
|
||||
# so it is converted to a semantic segmentation image.
|
||||
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
|
||||
|
||||
# ...
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.semantic_segmentation')
|
||||
# ...
|
||||
cc = carla.ColorConverter.CityScapesPalette
|
||||
camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame, cc))
|
||||
# ...
|
||||
# stop pedestrians (list is [controller, actor, controller, actor ...])
|
||||
for i in range(0, len(all_id), 2):
|
||||
all_actors[i].stop()
|
||||
|
||||
# destroy pedestrian (actor and controller)
|
||||
client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Sensor.listen-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
</p>
|
||||
<div id="carla.World.enable_environment_objects-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe turn visibility off and on for two specifc buildings on the map
|
||||
|
||||
# Get the buildings in the world
|
||||
world = client.get_world()
|
||||
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
|
||||
|
||||
# Access individual building IDs and save in a set
|
||||
building_01 = env_objs[0]
|
||||
building_02 = env_objs[1]
|
||||
objects_to_toggle = {building_01.id, building_02.id}
|
||||
|
||||
# Toggle buildings off
|
||||
world.enable_environment_objects(objects_to_toggle, False)
|
||||
# Toggle buildings on
|
||||
world.enable_environment_objects(objects_to_toggle, True)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.spawn_actor-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.spawn_actor
|
||||
</p>
|
||||
<div id="carla.World.spawn_actor-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe attaches different camera / sensors to a vehicle with different attachments.
|
||||
|
||||
# ...
|
||||
camera = world.spawn_actor(rgb_camera_bp, transform, attach_to=vehicle, attachment_type=Attachment.Rigid)
|
||||
# Default attachment: Attachment.Rigid
|
||||
gnss_sensor = world.spawn_actor(sensor_gnss_bp, transform, attach_to=vehicle)
|
||||
collision_sensor = world.spawn_actor(sensor_collision_bp, transform, attach_to=vehicle)
|
||||
lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, attach_to=vehicle)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.spawn_actor-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.WalkerAIController.stop-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -4444,6 +4378,71 @@ spectator.set_transform(actor_snapshot.get_transform())
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_box-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_box
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_box-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows how to draw traffic light actor bounding boxes from a world snapshot.
|
||||
|
||||
# ....
|
||||
debug = world.debug
|
||||
world_snapshot = world.get_snapshot()
|
||||
|
||||
for actor_snapshot in world_snapshot:
|
||||
actual_actor = world.get_actor(actor_snapshot.id)
|
||||
if actual_actor.type_id == 'traffic.traffic_light':
|
||||
debug.draw_box(carla.BoundingBox(actor_snapshot.get_transform().location,carla.Vector3D(0.5,0.5,2)),actor_snapshot.get_transform().rotation, 0.05, carla.Color(255,0,0,0),0)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_box-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.DebugHelper.draw_box.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.ActorBlueprint.set_attribute-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.ActorBlueprint.set_attribute
|
||||
</p>
|
||||
<div id="carla.ActorBlueprint.set_attribute-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes attributes of different type of blueprint actors.
|
||||
|
||||
# ...
|
||||
walker_bp = world.get_blueprint_library().filter('walker.pedestrian.0002')
|
||||
walker_bp.set_attribute('is_invincible', True)
|
||||
|
||||
# ...
|
||||
# Changes attribute randomly by the recommended value
|
||||
vehicle_bp = wolrd.get_blueprint_library().filter('vehicle.bmw.*')
|
||||
color = random.choice(vehicle_bp.get_attribute('color').recommended_values)
|
||||
vehicle_bp.set_attribute('color', color)
|
||||
|
||||
# ...
|
||||
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.rgb')
|
||||
camera_bp.set_attribute('image_size_x', 600)
|
||||
camera_bp.set_attribute('image_size_y', 600)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.ActorBlueprint.set_attribute-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -4480,4 +4479,4 @@ for (let i = 0; i < buttons.length; i++) {
|
|||
buttons[i].addEventListener("click",function(){ButtonAction(buttons[i].id);},true);
|
||||
}
|
||||
window.onresize = WindowResize;
|
||||
</script>
|
||||
</script>
|
|
@ -23,11 +23,13 @@ if (CMAKE_BUILD_TYPE STREQUAL "Client")
|
|||
add_subdirectory("client")
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Server")
|
||||
add_subdirectory("server")
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Pytorch")
|
||||
add_subdirectory("pytorch")
|
||||
else ()
|
||||
message(FATAL_ERROR "Unknown build type '${CMAKE_BUILD_TYPE}'")
|
||||
endif ()
|
||||
|
||||
# GTest is not compiled on Windows.
|
||||
if ((LIBCARLA_BUILD_TEST) AND (NOT WIN32))
|
||||
if ((LIBCARLA_BUILD_TEST) AND (NOT WIN32) AND (NOT (CMAKE_BUILD_TYPE STREQUAL "Pytorch")))
|
||||
add_subdirectory("test")
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
cmake_minimum_required(VERSION 3.5.1)
|
||||
project(libcarla-pytorch)
|
||||
|
||||
# Install headers.
|
||||
|
||||
file(GLOB libcarla_carla_pytorch_headers "${libcarla_source_path}/carla/pytorch/*.h")
|
||||
install(FILES ${libcarla_carla_pytorch_headers} DESTINATION include/carla/pytorch)
|
||||
|
||||
# carla_pytorch library.
|
||||
|
||||
file(GLOB libcarla_pytorch_sources
|
||||
"${libcarla_source_path}/carla/pytorch/*.h"
|
||||
"${libcarla_source_path}/carla/pytorch/*.cpp")
|
||||
|
||||
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
|
||||
find_package(Torch REQUIRED)
|
||||
find_package(TorchScatter REQUIRED)
|
||||
find_package(TorchCluster REQUIRED)
|
||||
find_package(Python3 REQUIRED)
|
||||
|
||||
# @todo These flags need to be compatible with setup.py compilation.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG -std=c++14 -O2 -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" CACHE STRING "" FORCE)
|
||||
|
||||
# ==============================================================================
|
||||
# Create targets for debug and release in the same build type.
|
||||
# ==============================================================================
|
||||
|
||||
if (LIBCARLA_BUILD_RELEASE)
|
||||
|
||||
add_library(carla_pytorch STATIC ${libcarla_pytorch_sources})
|
||||
|
||||
target_include_directories(carla_pytorch SYSTEM PRIVATE
|
||||
"${BOOST_INCLUDE_PATH}"
|
||||
"${RPCLIB_INCLUDE_PATH}")
|
||||
|
||||
target_include_directories(carla_pytorch PRIVATE SYSTEM "${TORCH_INCLUDE_DIRS}")
|
||||
target_include_directories(carla_pytorch PRIVATE SYSTEM "${TorchScatter_INCLUDE_DIR}")
|
||||
target_include_directories(carla_pytorch PRIVATE SYSTEM "${TorchCluster_INCLUDE_DIR}")
|
||||
target_include_directories(carla_pytorch PRIVATE SYSTEM "${TorchSparse_INCLUDE_DIR}")
|
||||
target_include_directories(carla_pytorch PRIVATE SYSTEM "${Python3_INCLUDE_DIRS}")
|
||||
target_link_libraries(carla_pytorch "${TORCH_LIBRARIES}")
|
||||
|
||||
install(TARGETS carla_pytorch DESTINATION lib OPTIONAL)
|
||||
|
||||
set_target_properties(carla_pytorch PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
endif()
|
||||
|
||||
if (LIBCARLA_BUILD_DEBUG)
|
||||
|
||||
add_library(carla_pytorch_debug STATIC ${libcarla_pytorch_sources})
|
||||
|
||||
target_include_directories(carla_pytorch_debug SYSTEM PRIVATE
|
||||
"${BOOST_INCLUDE_PATH}"
|
||||
"${RPCLIB_INCLUDE_PATH}")
|
||||
|
||||
install(TARGETS carla_pytorch_debug DESTINATION lib OPTIONAL)
|
||||
|
||||
set_target_properties(carla_pytorch_debug PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
target_compile_definitions(carla_pytorch_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
endif()
|
|
@ -0,0 +1,300 @@
|
|||
// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#define _GLIBCXX_USE_CXX11_ABI 0
|
||||
|
||||
#include "pytorch.h"
|
||||
|
||||
#include <torch/torch.h>
|
||||
#include <torch/script.h>
|
||||
#include <torchscatter/scatter.h>
|
||||
#include <torchcluster/cluster.h>
|
||||
#include <torch/csrc/jit/passes/tensorexpr_fuser.h>
|
||||
#include <c10/cuda/CUDACachingAllocator.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
void add_mark(const std::string &text) {
|
||||
|
||||
}
|
||||
|
||||
namespace carla {
|
||||
namespace learning {
|
||||
|
||||
void test_learning()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
std::cout << "cuda version " << cluster::cuda_version() << std::endl;
|
||||
std::cout << "cuda version " << scatter::cuda_version() << std::endl;
|
||||
// torch::Tensor tensor = torch::eye(3);
|
||||
// std::cout << tensor << std::endl;
|
||||
}
|
||||
|
||||
torch::jit::IValue GetWheelTensorInputs(WheelInput& wheel) {
|
||||
at::Tensor particles_position_tensor =
|
||||
torch::from_blob(wheel.particles_positions,
|
||||
{wheel.num_particles, 3}, torch::kFloat32);
|
||||
|
||||
at::Tensor particles_velocity_tensor =
|
||||
torch::from_blob(wheel.particles_velocities,
|
||||
{wheel.num_particles, 3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_positions_tensor =
|
||||
torch::from_blob(wheel.wheel_positions,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_oritentation_tensor =
|
||||
torch::from_blob(wheel.wheel_oritentation,
|
||||
{4}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_linear_velocity_tensor =
|
||||
torch::from_blob(wheel.wheel_linear_velocity,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_angular_velocity_tensor =
|
||||
torch::from_blob(wheel.wheel_angular_velocity,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
std::vector<torch::jit::IValue> Tuple
|
||||
{particles_position_tensor, particles_velocity_tensor, wheel_positions_tensor,
|
||||
wheel_oritentation_tensor, wheel_linear_velocity_tensor, wheel_angular_velocity_tensor};
|
||||
return torch::ivalue::Tuple::create(Tuple);
|
||||
}
|
||||
|
||||
WheelOutput GetWheelTensorOutput(
|
||||
const at::Tensor &particle_forces,
|
||||
const at::Tensor &wheel_forces) {
|
||||
std::ostringstream oss;
|
||||
std::cout << oss.str() << std::endl;
|
||||
WheelOutput result;
|
||||
const float* wheel_forces_data = wheel_forces.data_ptr<float>();
|
||||
result.wheel_forces_x = wheel_forces_data[0];
|
||||
result.wheel_forces_y = wheel_forces_data[1];
|
||||
result.wheel_forces_z = wheel_forces_data[2];
|
||||
result.wheel_torque_x = wheel_forces_data[3];
|
||||
result.wheel_torque_y = wheel_forces_data[4];
|
||||
result.wheel_torque_z = wheel_forces_data[5];
|
||||
const float* particle_forces_data = particle_forces.data_ptr<float>();
|
||||
int num_dimensions = 3;
|
||||
int num_particles = particle_forces.sizes()[0];
|
||||
result._particle_forces.reserve(num_particles*num_dimensions);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 0]);
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 1]);
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 2]);
|
||||
}
|
||||
if(num_particles > 0)
|
||||
{
|
||||
std::cout << particle_forces_data[0] << " " << particle_forces_data[1] << " " << particle_forces_data[0] << std::endl;
|
||||
}
|
||||
std::cout << "Output: " << result._particle_forces.size()/3 << " particles" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
WheelOutput GetWheelTensorOutputDynamic(
|
||||
const at::Tensor &particle_forces,
|
||||
const at::Tensor &wheel_forces) {
|
||||
WheelOutput result;
|
||||
const float* wheel_forces_data = wheel_forces.data_ptr<float>();
|
||||
result.wheel_forces_x = wheel_forces_data[0];
|
||||
result.wheel_forces_y = wheel_forces_data[1];
|
||||
result.wheel_forces_z = wheel_forces_data[2];
|
||||
const float* particle_forces_data = particle_forces.data_ptr<float>();
|
||||
int num_dimensions = 3;
|
||||
int num_particles = particle_forces.sizes()[0];
|
||||
result._particle_forces.reserve(num_particles*num_dimensions);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 0]);
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 1]);
|
||||
result._particle_forces.emplace_back(
|
||||
particle_forces_data[i*num_dimensions + 2]);
|
||||
}
|
||||
if(num_particles > 0)
|
||||
{
|
||||
std::cout << particle_forces_data[0] << " " << particle_forces_data[1] << " " << particle_forces_data[0] << std::endl;
|
||||
}
|
||||
// std::cout << "Output: " << result._particle_forces.size()/3 << " particles" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
// holds the neural network
|
||||
struct NeuralModelImpl
|
||||
{
|
||||
NeuralModelImpl(){
|
||||
// std::cout << "Creating model" << std::endl;
|
||||
}
|
||||
torch::jit::script::Module module;
|
||||
~NeuralModelImpl(){
|
||||
// std::cout << "Destroying model" << std::endl;
|
||||
}
|
||||
std::vector<at::Tensor> particles_position_tensors;
|
||||
std::vector<at::Tensor> particles_velocity_tensors;
|
||||
torch::jit::IValue GetWheelTensorInputsCUDA(WheelInput& wheel, int wheel_idx);
|
||||
};
|
||||
torch::jit::IValue NeuralModelImpl::GetWheelTensorInputsCUDA(WheelInput& wheel, int wheel_idx)
|
||||
{
|
||||
at::Tensor particles_position_tensor =
|
||||
torch::from_blob(wheel.particles_positions,
|
||||
{wheel.num_particles, 3}, torch::kFloat32);
|
||||
|
||||
at::Tensor particles_velocity_tensor =
|
||||
torch::from_blob(wheel.particles_velocities,
|
||||
{wheel.num_particles, 3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_positions_tensor =
|
||||
torch::from_blob(wheel.wheel_positions,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_oritentation_tensor =
|
||||
torch::from_blob(wheel.wheel_oritentation,
|
||||
{4}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_linear_velocity_tensor =
|
||||
torch::from_blob(wheel.wheel_linear_velocity,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
at::Tensor wheel_angular_velocity_tensor =
|
||||
torch::from_blob(wheel.wheel_angular_velocity,
|
||||
{3}, torch::kFloat32);
|
||||
|
||||
std::vector<torch::jit::IValue> Tuple
|
||||
{particles_position_tensor.cuda(), particles_velocity_tensor.cuda(), wheel_positions_tensor.cuda(),
|
||||
wheel_oritentation_tensor.cuda(), wheel_linear_velocity_tensor.cuda(), wheel_angular_velocity_tensor.cuda(),
|
||||
wheel.num_particles};
|
||||
return torch::ivalue::Tuple::create(Tuple);
|
||||
}
|
||||
|
||||
NeuralModel::NeuralModel() {
|
||||
Model = std::make_unique<NeuralModelImpl>();
|
||||
}
|
||||
void NeuralModel::LoadModel(char* filename, int device) {
|
||||
torch::jit::setTensorExprFuserEnabled(false);
|
||||
std::string filename_str(filename);
|
||||
std::cout << "loading " << filename_str << std::endl;
|
||||
try {
|
||||
Model->module = torch::jit::load(filename_str);
|
||||
std::string cuda_str = "cuda:" + std::to_string(device);
|
||||
std::cout << "Using CUDA device " << cuda_str << std::endl;
|
||||
Model->module.to(at::Device(cuda_str));
|
||||
} catch (const c10::Error& e) {
|
||||
std::cout << "Error loading model: " << e.msg() << std::endl;
|
||||
}
|
||||
std::cout << "loaded " << filename_str << std::endl;
|
||||
}
|
||||
|
||||
void NeuralModel::SetInputs(Inputs input) {
|
||||
_input = input;
|
||||
}
|
||||
|
||||
|
||||
void NeuralModel::Forward() {
|
||||
std::vector<torch::jit::IValue> TorchInputs;
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel0));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel1));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel2));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel3));
|
||||
auto drv_inputs = torch::tensor(
|
||||
{_input.steering, _input.throttle, _input.braking}, torch::kFloat32); //steer, throtle, brake
|
||||
TorchInputs.push_back(drv_inputs);
|
||||
TorchInputs.push_back(_input.verbose);
|
||||
|
||||
torch::jit::IValue Output;
|
||||
try {
|
||||
Output = Model->module.forward(TorchInputs);
|
||||
} catch (const c10::Error& e) {
|
||||
std::cout << "Error running model: " << e.msg() << std::endl;
|
||||
}
|
||||
|
||||
std::vector<torch::jit::IValue> Tensors = Output.toTuple()->elements();
|
||||
_output.wheel0 = GetWheelTensorOutput(
|
||||
Tensors[0].toTensor().cpu(), Tensors[4].toTensor().cpu());
|
||||
_output.wheel1 = GetWheelTensorOutput(
|
||||
Tensors[1].toTensor().cpu(), Tensors[5].toTensor().cpu());
|
||||
_output.wheel2 = GetWheelTensorOutput(
|
||||
Tensors[2].toTensor().cpu(), Tensors[6].toTensor().cpu());
|
||||
_output.wheel3 = GetWheelTensorOutput(
|
||||
Tensors[3].toTensor().cpu(), Tensors[7].toTensor().cpu());
|
||||
|
||||
}
|
||||
void NeuralModel::ForwardDynamic() {
|
||||
{
|
||||
|
||||
std::vector<torch::jit::IValue> TorchInputs;
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel0));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel1));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel2));
|
||||
TorchInputs.push_back(GetWheelTensorInputs(_input.wheel3));
|
||||
auto drv_inputs = torch::tensor(
|
||||
{_input.steering, _input.throttle, _input.braking}, torch::kFloat32); //steer, throtle, brake
|
||||
TorchInputs.push_back(drv_inputs);
|
||||
TorchInputs.push_back(_input.verbose);
|
||||
|
||||
torch::jit::IValue Output;
|
||||
try {
|
||||
Output = Model->module.forward(TorchInputs);
|
||||
} catch (const c10::Error& e) {
|
||||
std::cout << "Error running model: " << e.msg() << std::endl;
|
||||
}
|
||||
|
||||
std::vector<torch::jit::IValue> Tensors = Output.toTuple()->elements();
|
||||
_output.wheel0 = GetWheelTensorOutputDynamic(
|
||||
Tensors[0].toTensor().cpu(), Tensors[4].toTensor().cpu());
|
||||
_output.wheel1 = GetWheelTensorOutputDynamic(
|
||||
Tensors[1].toTensor().cpu(), Tensors[5].toTensor().cpu());
|
||||
_output.wheel2 = GetWheelTensorOutputDynamic(
|
||||
Tensors[2].toTensor().cpu(), Tensors[6].toTensor().cpu());
|
||||
_output.wheel3 = GetWheelTensorOutputDynamic(
|
||||
Tensors[3].toTensor().cpu(), Tensors[7].toTensor().cpu());
|
||||
|
||||
}
|
||||
|
||||
c10::cuda::CUDACachingAllocator::emptyCache();
|
||||
|
||||
}
|
||||
|
||||
void NeuralModel::ForwardCUDATensors()
|
||||
{
|
||||
std::vector<torch::jit::IValue> TorchInputs;
|
||||
TorchInputs.push_back(Model->GetWheelTensorInputsCUDA(_input.wheel0, 0));
|
||||
TorchInputs.push_back(Model->GetWheelTensorInputsCUDA(_input.wheel1, 1));
|
||||
TorchInputs.push_back(Model->GetWheelTensorInputsCUDA(_input.wheel2, 2));
|
||||
TorchInputs.push_back(Model->GetWheelTensorInputsCUDA(_input.wheel3, 3));
|
||||
auto drv_inputs = torch::tensor(
|
||||
{_input.steering, _input.throttle, _input.braking}, torch::kFloat32); //steer, throtle, brake
|
||||
TorchInputs.push_back(drv_inputs.cuda());
|
||||
TorchInputs.push_back(_input.verbose);
|
||||
|
||||
torch::jit::IValue Output;
|
||||
try {
|
||||
Output = Model->module.forward(TorchInputs);
|
||||
} catch (const c10::Error& e) {
|
||||
std::cout << "Error running model: " << e.msg() << std::endl;
|
||||
}
|
||||
|
||||
std::vector<torch::jit::IValue> Tensors = Output.toTuple()->elements();
|
||||
_output.wheel0 = GetWheelTensorOutput(
|
||||
Tensors[0].toTensor().cpu(), Tensors[4].toTensor().cpu());
|
||||
_output.wheel1 = GetWheelTensorOutput(
|
||||
Tensors[1].toTensor().cpu(), Tensors[5].toTensor().cpu());
|
||||
_output.wheel2 = GetWheelTensorOutput(
|
||||
Tensors[2].toTensor().cpu(), Tensors[6].toTensor().cpu());
|
||||
_output.wheel3 = GetWheelTensorOutput(
|
||||
Tensors[3].toTensor().cpu(), Tensors[7].toTensor().cpu());
|
||||
}
|
||||
|
||||
Outputs& NeuralModel::GetOutputs() {
|
||||
return _output;
|
||||
}
|
||||
|
||||
NeuralModel::~NeuralModel() {}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
#define _GLIBCXX_USE_CXX11_ABI 0
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace carla {
|
||||
namespace learning {
|
||||
|
||||
void test_learning();
|
||||
|
||||
struct NeuralModelImpl;
|
||||
|
||||
struct WheelInput {
|
||||
public:
|
||||
int num_particles = 0;
|
||||
float* particles_positions;
|
||||
float* particles_velocities;
|
||||
float* wheel_positions;
|
||||
float* wheel_oritentation;
|
||||
float* wheel_linear_velocity;
|
||||
float* wheel_angular_velocity;
|
||||
int terrain_type = 0;
|
||||
};
|
||||
|
||||
struct Inputs {
|
||||
public:
|
||||
WheelInput wheel0;
|
||||
WheelInput wheel1;
|
||||
WheelInput wheel2;
|
||||
WheelInput wheel3;
|
||||
float steering = 0;
|
||||
float throttle = 0;
|
||||
float braking = 0;
|
||||
bool verbose = false;
|
||||
};
|
||||
|
||||
struct WheelOutput {
|
||||
public:
|
||||
float wheel_forces_x = 0;
|
||||
float wheel_forces_y = 0;
|
||||
float wheel_forces_z = 0;
|
||||
float wheel_torque_x = 0;
|
||||
float wheel_torque_y = 0;
|
||||
float wheel_torque_z = 0;
|
||||
std::vector<float> _particle_forces;
|
||||
};
|
||||
struct Outputs {
|
||||
public:
|
||||
WheelOutput wheel0;
|
||||
WheelOutput wheel1;
|
||||
WheelOutput wheel2;
|
||||
WheelOutput wheel3;
|
||||
};
|
||||
|
||||
// Interface with the torch implementation
|
||||
class NeuralModel {
|
||||
public:
|
||||
|
||||
NeuralModel();
|
||||
void LoadModel(char* filename, int device);
|
||||
|
||||
void SetInputs(Inputs input);
|
||||
void Forward();
|
||||
void ForwardDynamic();
|
||||
void ForwardCUDATensors();
|
||||
Outputs& GetOutputs();
|
||||
|
||||
~NeuralModel();
|
||||
|
||||
private:
|
||||
std::unique_ptr<NeuralModelImpl> Model;
|
||||
Inputs _input;
|
||||
Outputs _output;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -1239,7 +1239,7 @@ def game_loop(args):
|
|||
|
||||
try:
|
||||
client = carla.Client(args.host, args.port)
|
||||
client.set_timeout(20.0)
|
||||
client.set_timeout(2000.0)
|
||||
|
||||
sim_world = client.get_world()
|
||||
if args.sync:
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,6 +8,7 @@ public class Carla : ModuleRules
|
|||
{
|
||||
bool UsingCarSim = false;
|
||||
bool UsingChrono = false;
|
||||
bool UsingPytorch = false;
|
||||
private bool IsWindows(ReadOnlyTargetRules Target)
|
||||
{
|
||||
return (Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32);
|
||||
|
@ -43,6 +44,13 @@ public class Carla : ModuleRules
|
|||
PublicDefinitions.Add("WITH_CHRONO");
|
||||
PrivateDefinitions.Add("WITH_CHRONO");
|
||||
}
|
||||
if (line.Contains("Pytorch ON"))
|
||||
{
|
||||
Console.WriteLine("Enabling pytorch");
|
||||
UsingPytorch = true;
|
||||
PublicDefinitions.Add("WITH_PYTORCH");
|
||||
PrivateDefinitions.Add("WITH_PYTORCH");
|
||||
}
|
||||
}
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
|
@ -219,6 +227,81 @@ public class Carla : ModuleRules
|
|||
bUseRTTI = true;
|
||||
bEnableExceptions = true;
|
||||
}
|
||||
|
||||
if (UsingPytorch)
|
||||
{
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("carla_pytorch")));
|
||||
|
||||
string LibTorchPath = LibCarlaInstallPath;
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libonnx_proto.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libfbgemm.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgloo.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libXNNPACK.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libprotobuf-lite.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libprotobuf.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libasmjit.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libcpuinfo_internals.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libclog.a"));
|
||||
// PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libbreakpad_common.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libbenchmark.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libtensorpipe.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libpytorch_qnnpack.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libtensorpipe_cuda.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libnnpack_reference_layers.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgmock.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libdnnl.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libpthreadpool.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libcpuinfo.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libqnnpack.a"));
|
||||
// PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libbreakpad.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libkineto.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libprotoc.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgtest.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgmock_main.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgtest_main.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libbenchmark_main.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libfmt.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libtensorpipe_uv.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libfoxi_loader.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libgloo_cuda.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libnnpack.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libcaffe2_protos.a"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibTorchPath, "lib", "libonnx.a"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libnnapi_backend.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libbackend_with_compiler.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libcaffe2_nvrtc.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch_cuda_cpp.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libc10_cuda.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorchbind_test.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libjitbackend_test.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libc10.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch_cuda.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch_global_deps.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch_cpu.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libshm.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorch_cuda_cu.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorchscatter.so"));
|
||||
AddDynamicLibrary(Path.Combine(LibTorchPath, "lib", "libtorchcluster.so"));
|
||||
// AddDynamicLibrary("/usr/local/cuda/lib64/stubs/libcuda.so");
|
||||
// AddDynamicLibrary("/usr/local/cuda/lib64/libnvrtc.so");
|
||||
// AddDynamicLibrary("/usr/local/cuda/lib64/libnvToolsExt.so");
|
||||
// AddDynamicLibrary("/usr/local/cuda/lib64/libcudart.so");
|
||||
// AddDynamicLibrary("/usr/lib/llvm-10/lib/libgomp.so");
|
||||
PublicAdditionalLibraries.Add("/usr/local/cuda/lib64/stubs/libcuda.so");
|
||||
PublicAdditionalLibraries.Add("/usr/local/cuda/lib64/libnvrtc.so");
|
||||
PublicAdditionalLibraries.Add("/usr/local/cuda/lib64/libnvToolsExt.so");
|
||||
PublicAdditionalLibraries.Add("/usr/local/cuda/lib64/libcudart.so");
|
||||
PublicAdditionalLibraries.Add("/usr/lib/llvm-10/lib/libgomp.so");
|
||||
RuntimeDependencies.Add(Path.Combine(LibTorchPath, "lib", "libcudart-a7b20f20.so.11.0"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibTorchPath, "lib", "libgomp-a34b3233.so.1"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibTorchPath, "lib", "libnvrtc-builtins-4730a239.so.11.3"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibTorchPath, "lib", "libnvrtc-1ea278b5.so.11.2"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibTorchPath, "lib", "libnvToolsExt-24de1d56.so.1"));
|
||||
PublicAdditionalLibraries.Add("stdc++");
|
||||
PublicAdditionalLibraries.Add("/usr/lib/x86_64-linux-gnu/libpython3.9.so");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Include path.
|
||||
|
|
|
@ -567,6 +567,12 @@ FCarlaMapTile* ALargeMapManager::GetCarlaMapTile(FIntVector TileVectorID)
|
|||
return Tile;
|
||||
}
|
||||
|
||||
FCarlaMapTile* ALargeMapManager::GetCarlaMapTile(TileID TileID)
|
||||
{
|
||||
FCarlaMapTile* Tile = MapTiles.Find(TileID);
|
||||
return Tile;
|
||||
}
|
||||
|
||||
FCarlaMapTile& ALargeMapManager::LoadCarlaMapTile(FString TileMapPath, TileID TileId) {
|
||||
TRACE_CPUPROFILER_EVENT_SCOPE(ALargeMapManager::LoadCarlaMapTile);
|
||||
// Need to generate a new Tile
|
||||
|
|
|
@ -164,8 +164,6 @@ public:
|
|||
|
||||
float GetActorStreamingDistance() const;
|
||||
|
||||
protected:
|
||||
|
||||
FIntVector GetTileVectorID(FVector TileLocation) const;
|
||||
|
||||
FIntVector GetTileVectorID(FDVector TileLocation) const;
|
||||
|
@ -192,9 +190,13 @@ protected:
|
|||
FCarlaMapTile& GetCarlaMapTile(ULevel* InLevel);
|
||||
|
||||
FCarlaMapTile* GetCarlaMapTile(FIntVector TileVectorID);
|
||||
|
||||
FCarlaMapTile* GetCarlaMapTile(TileID TileID);
|
||||
|
||||
FCarlaMapTile& LoadCarlaMapTile(FString TileMapPath, TileID TileId);
|
||||
|
||||
protected:
|
||||
|
||||
void UpdateTilesState();
|
||||
|
||||
void RemovePendingActorsToRemove();
|
||||
|
|
|
@ -79,6 +79,14 @@ struct FDVector
|
|||
return FDVector(X + V.X, Y + V.Y, Z + V.Z);
|
||||
}
|
||||
|
||||
FDVector& operator+=(float Scalar)
|
||||
{
|
||||
this->X += Scalar;
|
||||
this->Y += Scalar;
|
||||
this->Z += Scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FDVector operator-(const FDVector& V) const
|
||||
{
|
||||
return FDVector(X - V.X, Y - V.Y, Z - V.Z);
|
||||
|
@ -108,4 +116,19 @@ struct FDVector
|
|||
return FDVector(X * Scale, Y * Scale, Z * Scale);
|
||||
}
|
||||
|
||||
FDVector operator*=(float Scale)
|
||||
{
|
||||
this->X *= Scale;
|
||||
this->Y *= Scale;
|
||||
this->Z *= Scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FDVector operator*=(double Scale)
|
||||
{
|
||||
this->X *= Scale;
|
||||
this->Y *= Scale;
|
||||
this->Z *= Scale;
|
||||
return *this;
|
||||
}
|
||||
};
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "Components/SkeletalMeshComponent.h"
|
||||
#include <vector>
|
||||
|
||||
// disable warnings for eigen 3.1.0
|
||||
#if defined(__clang__)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,29 +12,54 @@
|
|||
|
||||
#include "Carla/Math/DVector.h"
|
||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||
#include "Engine/TextureRenderTarget2D.h"
|
||||
#include "Carla/MapGen/LargeMapManager.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#ifdef WITH_PYTORCH
|
||||
THIRD_PARTY_INCLUDES_START
|
||||
#include <carla/pytorch/pytorch.h>
|
||||
THIRD_PARTY_INCLUDES_END
|
||||
#endif
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "Misc/ScopeLock.h"
|
||||
#include <string>
|
||||
|
||||
#include "CustomTerrainPhysicsComponent.generated.h"
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class UHeightMapDataAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HeightMapDataAsset)
|
||||
int SizeX = 0;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HeightMapDataAsset)
|
||||
int SizeY = 0;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HeightMapDataAsset)
|
||||
TArray<float> HeightValues;
|
||||
};
|
||||
|
||||
struct FParticle
|
||||
{
|
||||
// It formats particle data to "XValue YValue ZValue RadiusValue \n"
|
||||
std::string ToString() const;
|
||||
|
||||
// String received must have format "XValue YValue ZValue RadiusValue \n"
|
||||
void ModifyDataFromString(const std::string& BaseString);
|
||||
|
||||
FDVector Position; // position in m
|
||||
FVector Velocity;
|
||||
float Radius = 0.02f;
|
||||
|
||||
};
|
||||
|
||||
struct FHeightMapData
|
||||
{
|
||||
void InitializeHeightmap(UTexture2D* Texture, FDVector Size, FDVector Origin);
|
||||
void InitializeHeightmap(
|
||||
UTexture2D* Texture, FDVector Size, FDVector Origin,
|
||||
float MinHeight, float MaxHeight, FDVector Tile0, float ScaleZ);
|
||||
void InitializeHeightmapFloat(
|
||||
UTexture2D* Texture, FDVector Size, FDVector Origin,
|
||||
float MinHeight, float MaxHeight, FDVector Tile0, float ScaleZ);
|
||||
void InitializeHeightmap(
|
||||
UHeightMapDataAsset* DataAsset, FDVector Size, FDVector Origin,
|
||||
FDVector Tile0, float ScaleZ);
|
||||
float GetHeight(FDVector Position) const; // get height at a given global 2d position
|
||||
void Clear();
|
||||
// private:
|
||||
|
@ -42,35 +67,65 @@ struct FHeightMapData
|
|||
FDVector Offset;
|
||||
uint32_t Size_X;
|
||||
uint32_t Size_Y;
|
||||
float MinHeight = 0.0f;
|
||||
float MaxHeight = 10.0f;
|
||||
float Scale_Z = 1;
|
||||
FDVector Tile0Position;
|
||||
std::vector<float> Pixels;
|
||||
};
|
||||
|
||||
struct FDenseTile
|
||||
{
|
||||
void InitializeTile(float ParticleSize, float Depth,
|
||||
FDenseTile();
|
||||
~FDenseTile();
|
||||
FDenseTile(const FDenseTile& Origin);
|
||||
FDenseTile(FDenseTile&& Origin);
|
||||
FDenseTile& operator=(FDenseTile&& Origin);
|
||||
|
||||
void InitializeTile(uint32_t TextureSize, float AffectedRadius, float ParticleSize, float Depth,
|
||||
FDVector TileOrigin, FDVector TileEnd, const FString& SavePath, const FHeightMapData &HeightMap);
|
||||
std::vector<FParticle*> GetParticlesInRadius(FDVector Position, float Radius);
|
||||
|
||||
// Format DenseTile to "PosX PosY PosZ\n Particles"
|
||||
// WARNING LookAt ParticlesFormat
|
||||
std::string ToString() const;
|
||||
|
||||
// String received must have format "PosX PosY PosZ\n ParticlesList"
|
||||
void ModifyDataFromString(const std::string& BaseString);
|
||||
void GetParticlesInRadius(FDVector Position, float Radius, std::vector<FParticle*> &ParticlesInRadius);
|
||||
void GetParticlesInBox(const FOrientedBox& OBox, std::vector<FParticle*> &ParticlesInRadius);
|
||||
void GetAllParticles(std::vector<FParticle*> &ParticlesInRadius);
|
||||
|
||||
void UpdateLocalHeightmap();
|
||||
std::vector<FParticle> Particles;
|
||||
std::vector<float> ParticlesHeightMap;
|
||||
//std::vector<std::vector<float>> ParticlesZOrdered;
|
||||
std::vector<std::multiset<float,std::greater<float>>> ParticlesZOrdered;
|
||||
FDVector TilePosition;
|
||||
|
||||
FString SavePath;
|
||||
bool bHeightmapNeedToUpdate = false;
|
||||
};
|
||||
|
||||
class FSparseHighDetailMap
|
||||
{
|
||||
public:
|
||||
friend struct FTilesWorker;
|
||||
|
||||
FSparseHighDetailMap(float ParticleDiameter = 0.02f, float Depth = 0.4f)
|
||||
: ParticleSize(ParticleDiameter), TerrainDepth(Depth) {};
|
||||
|
||||
void Init( uint32 NewTextureSize, float NewAffectedRadius, float ParticleDiameter, float Depth)
|
||||
{
|
||||
ParticleSize = ParticleDiameter;
|
||||
TerrainDepth = Depth;
|
||||
TextureSize = NewTextureSize;
|
||||
AffectedRadius = NewAffectedRadius;
|
||||
UE_LOG(LogCarla, Warning,
|
||||
TEXT("ParticleSize %f"), ParticleSize);
|
||||
}
|
||||
|
||||
inline float GetTileSize() const {
|
||||
return TileSize;
|
||||
}
|
||||
|
||||
std::vector<FParticle*> GetParticlesInRadius(FDVector Position, float Radius);
|
||||
std::vector<FParticle*> GetParticlesInTileRadius(FDVector Position, float Radius);
|
||||
std::vector<FParticle*> GetParticlesInBox(const FOrientedBox& OBox);
|
||||
std::vector<uint64_t> GetIntersectingTiles(const FOrientedBox& OBox);
|
||||
std::vector<float> GetParticlesHeightMapInTileRadius(FDVector Position, float Radius);
|
||||
|
||||
FDenseTile& GetTile(uint32_t Tile_X, uint32_t Tile_Y);
|
||||
FDenseTile& GetTile(FDVector Position);
|
||||
|
@ -78,34 +133,67 @@ public:
|
|||
|
||||
FDenseTile& InitializeRegion(uint32_t Tile_X, uint32_t Tile_Y);
|
||||
FDenseTile& InitializeRegion(uint64_t TileId);
|
||||
FDenseTile& InitializeRegionInCache(uint64_t TileId);
|
||||
|
||||
uint64_t GetTileId(uint32_t Tile_X, uint32_t Tile_Y);
|
||||
uint64_t GetTileId(uint64_t TileId);
|
||||
uint64_t GetTileId(FDVector Position);
|
||||
FIntVector GetVectorTileId(FDVector Position);
|
||||
FDVector GetTilePosition(uint64_t TileId);
|
||||
FDVector GetTilePosition(uint32_t Tile_X, uint32_t Tile_Y);
|
||||
|
||||
void InitializeMap(UTexture2D* HeightMapTexture,
|
||||
FDVector Origin, FDVector MapSize, float Size = 1.f);
|
||||
float GetHeight(FDVector Position) {
|
||||
return Heightmap.GetHeight(Position);
|
||||
}
|
||||
|
||||
void InitializeMap(UTexture2D* HeightMapTexture,
|
||||
FDVector Origin, FDVector MapSize, float Size, float MinHeight, float MaxHeight,
|
||||
float ScaleZ);
|
||||
void InitializeMap(UHeightMapDataAsset* DataAsset,
|
||||
FDVector Origin, FDVector MapSize, float Size, float ScaleZ);
|
||||
|
||||
void UpdateHeightMap(UTexture2D* HeightMapTexture,
|
||||
FDVector Origin, FDVector MapSize, float Size, float MinHeight, float MaxHeight,
|
||||
float ScaleZ);
|
||||
void UpdateHeightMap(UHeightMapDataAsset* DataAsset,
|
||||
FDVector Origin, FDVector MapSize, float Size, float ScaleZ);
|
||||
|
||||
void LoadTilesAtPositionFromCache(FDVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
void UnLoadTilesAtPositionToCache(FDVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
void ReloadCache(FDVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
|
||||
void LoadTilesAtPosition(FDVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
|
||||
void Update(FVector Position, float RadiusX, float RadiusY);
|
||||
|
||||
void SaveMap();
|
||||
|
||||
void Clear();
|
||||
|
||||
void LockMutex()
|
||||
{
|
||||
Lock_Map.Lock();
|
||||
}
|
||||
|
||||
void UnLockMutex()
|
||||
{
|
||||
Lock_Map.Unlock();
|
||||
}
|
||||
|
||||
std::unordered_map<uint64_t, FDenseTile> Map;
|
||||
std::unordered_map<uint64_t, FDenseTile> CacheMap;
|
||||
FString SavePath;
|
||||
private:
|
||||
std::unordered_map<uint64_t, FDenseTile> Map;
|
||||
std::unordered_map<uint64_t, FDenseTile> TilesToWrite;
|
||||
FDVector Tile0Position;
|
||||
FDVector Extension;
|
||||
float TileSize = 1.f; // 1m per tile
|
||||
FHeightMapData Heightmap;
|
||||
float ParticleSize = 0.02f;
|
||||
float TerrainDepth = 0.4f;
|
||||
uint32 TextureSize = 0;
|
||||
float AffectedRadius = 0.0f;
|
||||
FVector PositionToUpdate;
|
||||
FCriticalSection Lock_Map; // UE4 Mutex
|
||||
FCriticalSection Lock_CacheMap; // UE4 Mutex
|
||||
FCriticalSection Lock_Position; // UE4 Mutex
|
||||
|
||||
};
|
||||
|
@ -121,20 +209,18 @@ struct FForceAtLocation
|
|||
FVector Location;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class UCustomTerrainPhysicsComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
friend struct FTilesWorker;
|
||||
public:
|
||||
|
||||
UCustomTerrainPhysicsComponent();
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
|
||||
virtual void TickComponent(float DeltaTime,
|
||||
ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction);
|
||||
|
||||
|
@ -144,28 +230,119 @@ public:
|
|||
UFUNCTION(BlueprintCallable)
|
||||
void AddForces(const TArray<FForceAtLocation> &Forces);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<float> BuildLandscapeHeightMap(ALandscapeProxy* Landscape, int Resolution);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
static void BuildLandscapeHeightMapTexture(ALandscapeProxy* Landscape,
|
||||
int Resolution, FVector MapSize, FString TexturePath, FString TextureName);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
static void BuildLandscapeHeightMapDataAasset(ALandscapeProxy* Landscape,
|
||||
int Resolution, FVector MapSize, FString AssetPath, FString AssetName);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
float GetHeightAtLocation(ALandscapeProxy * Landscape, FVector Location);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<FVector> GetParticlesInRadius(FVector Position, float Radius);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<FVector> GetParticlesInTileRadius(FVector Position, float Radius);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FVector GetTileCenter(FVector Position);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Tiles")
|
||||
void LoadTilesAtPosition(FVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Tiles")
|
||||
void UnloadTilesAtPosition(FVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Tiles")
|
||||
void ReloadCache(FVector Position, float RadiusX = 100.0f, float RadiusY = 100.0f);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Texture")
|
||||
void InitTexture();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Texture")
|
||||
void UpdateTexture();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Texture")
|
||||
void UpdateTextureData();
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UHeightMapDataAsset* DataAsset;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UTexture2D *HeightMap;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
|
||||
UTexture2D* TextureToUpdate;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
|
||||
UMaterialParameterCollection* MPC;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FString NeuralModelFile = "";
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FVector NextPositionToUpdate = FVector(0,0,0);
|
||||
|
||||
FVector LastUpdatedPosition;
|
||||
|
||||
FString SavePath;
|
||||
FString SavePath;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float ForceMulFactor = 1.0;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool NNVerbose = false;
|
||||
|
||||
private:
|
||||
|
||||
void RunNNPhysicsSimulation(
|
||||
ACarlaWheeledVehicle *Vehicle, float DeltaTime);
|
||||
// TArray<FParticle*> GetParticlesInRange(...);
|
||||
void SetUpParticleArrays(std::vector<FParticle*>& ParticlesIn,
|
||||
TArray<float>& ParticlePosOut,
|
||||
TArray<float>& ParticleVelOut);
|
||||
void SetUpWheelArrays(ACarlaWheeledVehicle *Vehicle, int WheelIdx,
|
||||
TArray<float>& WheelPos,
|
||||
TArray<float>& WheelOrientation,
|
||||
TArray<float>& WheelLinearVelocity,
|
||||
TArray<float>& WheelAngularVelocity);
|
||||
void UpdateParticles(
|
||||
std::vector<FParticle*> Particles, std::vector<float> Forces,
|
||||
float DeltaTime);
|
||||
void ApplyForcesToVehicle(
|
||||
ACarlaWheeledVehicle *Vehicle,
|
||||
FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3,
|
||||
FVector TorqueWheel0, FVector TorqueWheel1, FVector TorqueWheel2, FVector TorqueWheel3);
|
||||
void ApplyMeanAccelerationToVehicle(
|
||||
ACarlaWheeledVehicle *Vehicle,
|
||||
FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3);
|
||||
void ApplyAccelerationToVehicle(
|
||||
ACarlaWheeledVehicle *Vehicle,
|
||||
FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3);
|
||||
|
||||
void ApplyForces();
|
||||
void LimitParticlesPerWheel(std::vector<FParticle*> &Particles);
|
||||
void DrawParticles(UWorld* World, std::vector<FParticle*>& Particles);
|
||||
void DrawOrientedBox(UWorld* World, const TArray<FOrientedBox>& Boxes);
|
||||
void DrawTiles(UWorld* World, const std::vector<uint64_t>& TilesIds, float Height = 0);
|
||||
void GenerateBenchmarkParticles(std::vector<FParticle>& BenchParticles,
|
||||
std::vector<FParticle*> &ParticlesWheel0, std::vector<FParticle*> &ParticlesWheel1,
|
||||
std::vector<FParticle*> &ParticlesWheel2, std::vector<FParticle*> &ParticlesWheel3,
|
||||
FOrientedBox &BboxWheel0, FOrientedBox &BboxWheel1,
|
||||
FOrientedBox &BboxWheel2, FOrientedBox &BboxWheel3);
|
||||
|
||||
void UpdateParticlesDebug(std::vector<FParticle*> Particles);
|
||||
|
||||
void UpdateTilesHeightMaps( const std::vector<FParticle*>& Particles);
|
||||
void RemoveParticlesFromOrderedContainer(const std::vector<FParticle*>& Particles);
|
||||
void AddParticlesToOrderedContainer(const std::vector<FParticle*>& Particles);
|
||||
void UpdateTilesHeightMapsInRadius(FDVector Position, uint32 Rad );
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TArray<FForceAtLocation> ForcesToApply;
|
||||
UPROPERTY(EditAnywhere)
|
||||
|
@ -173,16 +350,124 @@ private:
|
|||
UPROPERTY(EditAnywhere)
|
||||
float RayCastRange = 10.0f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector WorldSize = FVector(1000,1000,1000);
|
||||
FVector WorldSize = FVector(200000,200000,0);
|
||||
|
||||
// Radius of the data loaded in memory
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
FVector TileRadius = FVector( 5, 5, 0 );
|
||||
// Radius of the data loaded in memory
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
FVector CacheRadius = FVector( 50, 50, 0 );
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
int32 TileSize = 1;
|
||||
// TimeToTriggerCacheReload In seconds
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
float TimeToTriggerCacheReload = 20.0f;
|
||||
// TimeToTriggerLoadTiles in MS
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
float TimeToTriggerLoadTiles = 1.0f;
|
||||
UPROPERTY(EditAnywhere, Category="Tiles")
|
||||
float TimeToTriggerUnLoadTiles = 5.0f;
|
||||
// Radius of the data collected by the texture in METERS
|
||||
UPROPERTY(EditAnywhere, Category="MaterialParameters")
|
||||
float TextureRadius = 4.0f;
|
||||
// Scalar Factor of deformation effect applied in the landscape
|
||||
UPROPERTY(EditAnywhere, Category="MaterialParameters")
|
||||
float EffectMultiplayer = 10.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="DeformationMesh")
|
||||
UStaticMesh* DeformationPlaneMesh = nullptr;
|
||||
UPROPERTY(EditAnywhere, Category="DeformationMesh")
|
||||
UMaterialInstance* DeformationPlaneMaterial = nullptr;
|
||||
UPROPERTY(VisibleAnywhere, Category="DeformationMesh")
|
||||
AStaticMeshActor* DeformationPlaneActor = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
UMaterialParameterCollectionInstance* MPCInstance;
|
||||
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float SearchRadius = 100;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float ParticleDiameter = 2;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float TerrainDepth = 40;
|
||||
UPROPERTY(EditAnywhere)
|
||||
AActor *FloorActor = nullptr;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bUpdateParticles = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bUseDynamicModel = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bUseCUDAModel = false;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float TireRadius = 33.0229f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float TireWidth = 21.21f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float BoxSearchForwardDistance = 114.39f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float BoxSearchLateralDistance = 31.815f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float BoxSearchDepthDistance = 20.f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bDisableVehicleGravity = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float MaxForceMagnitude = 1000000.f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float FloorHeight = 0.f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bUseImpulse = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool DrawDebugInfo = true;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bUseMeanAcceleration = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bShowForces = true;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float MinHeight = 0;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float MaxHeight = 10;
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector Tile0Origin;
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bDrawHeightMap = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector DrawStart = FVector(0);
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector DrawEnd = FVector(1000, 1000, 0);
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector DrawInterval = FVector(100,100,0);
|
||||
UPROPERTY(EditAnywhere)
|
||||
int CUDADevice = 0;
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector HeightMapScaleFactor = FVector(1, 1, 1);
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector HeightMapOffset = FVector(0, 0, 0);
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool bBenchMark = false;
|
||||
UPROPERTY(EditAnywhere)
|
||||
int MaxParticlesPerWheel = 6000;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector Radius = FVector(10,10,10);
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
FIntVector CurrentLargeMapTileId = FIntVector(-1,-1,0);
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
ALargeMapManager* LargeMapManager = nullptr;
|
||||
|
||||
|
||||
FSparseHighDetailMap SparseMap;
|
||||
TArray<ACarlaWheeledVehicle*> Vehicles;
|
||||
FSparseHighDetailMap SparseMap;
|
||||
TArray<uint8> Data;
|
||||
#ifdef WITH_PYTORCH
|
||||
carla::learning::NeuralModel TerramechanicsModel;
|
||||
#endif
|
||||
|
||||
class FRunnableThread* Thread;
|
||||
struct FTilesWorker* TilesWorker;
|
||||
class FRunnableThread* Thread;
|
||||
struct FTilesWorker* TilesWorker;
|
||||
};
|
||||
|
||||
struct FTilesWorker : public FRunnable
|
||||
|
@ -195,7 +480,9 @@ struct FTilesWorker : public FRunnable
|
|||
|
||||
class UCustomTerrainPhysicsComponent* CustomTerrainComp;
|
||||
FVector Position;
|
||||
float RadiusX;
|
||||
float RadiusY;
|
||||
|
||||
double RadiusX;
|
||||
double RadiusY;
|
||||
|
||||
bool bShouldContinue = true;
|
||||
};
|
||||
|
|
|
@ -14,12 +14,13 @@ BUILD_CARLAUE4=false
|
|||
LAUNCH_UE4_EDITOR=false
|
||||
USE_CARSIM=false
|
||||
USE_CHRONO=false
|
||||
USE_PYTORCH=false
|
||||
EDITOR_FLAGS=""
|
||||
|
||||
GDB=
|
||||
RHI="-vulkan"
|
||||
|
||||
OPTS=`getopt -o h --long help,build,rebuild,launch,clean,hard-clean,gdb,opengl,carsim,chrono,editor-flags: -n 'parse-options' -- "$@"`
|
||||
OPTS=`getopt -o h --long help,build,rebuild,launch,clean,hard-clean,gdb,opengl,carsim,pytorch,chrono,editor-flags: -n 'parse-options' -- "$@"`
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -57,6 +58,9 @@ while [[ $# -gt 0 ]]; do
|
|||
--chrono )
|
||||
USE_CHRONO=true
|
||||
shift ;;
|
||||
--pytorch )
|
||||
USE_PYTORCH=true;
|
||||
shift ;;
|
||||
-h | --help )
|
||||
echo "$DOC_STRING"
|
||||
echo "$USAGE_STRING"
|
||||
|
@ -138,6 +142,11 @@ if ${BUILD_CARLAUE4} ; then
|
|||
else
|
||||
OPTIONAL_MODULES_TEXT="Chrono OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
||||
fi
|
||||
if ${USE_PYTORCH} ; then
|
||||
OPTIONAL_MODULES_TEXT="Pytorch ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
||||
else
|
||||
OPTIONAL_MODULES_TEXT="Pytorch OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
||||
fi
|
||||
echo ${OPTIONAL_MODULES_TEXT} > ${PWD}/Config/OptionalModules.ini
|
||||
|
||||
if [ ! -f Makefile ]; then
|
||||
|
|
|
@ -33,8 +33,9 @@ BUILD_OPTION_DEBUG=false
|
|||
BUILD_OPTION_RELEASE=false
|
||||
BUILD_OPTION_DUMMY=false
|
||||
BUILD_RSS_VARIANT=false
|
||||
USE_PYTORCH=false
|
||||
|
||||
OPTS=`getopt -o h --long help,rebuild,server,client,clean,debug,release,rss,carsim -n 'parse-options' -- "$@"`
|
||||
OPTS=`getopt -o h --long help,rebuild,server,client,clean,debug,release,rss,pytorch,carsim -n 'parse-options' -- "$@"`
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -63,6 +64,9 @@ while [[ $# -gt 0 ]]; do
|
|||
--release )
|
||||
BUILD_OPTION_RELEASE=true;
|
||||
shift ;;
|
||||
--pytorch )
|
||||
USE_PYTORCH=true;
|
||||
shift ;;
|
||||
--rss )
|
||||
BUILD_RSS_VARIANT=true;
|
||||
shift ;;
|
||||
|
@ -100,6 +104,7 @@ if ${REMOVE_INTERMEDIATE} ; then
|
|||
log "Cleaning intermediate files and folders."
|
||||
|
||||
rm -Rf ${LIBCARLA_BUILD_SERVER_FOLDER}* ${LIBCARLA_BUILD_CLIENT_FOLDER}*
|
||||
rm -Rf ${LIBCARLA_BUILD_PYTORCH_FOLDER}* ${LIBCARLA_BUILD_PYTORCH_FOLDER}*
|
||||
rm -Rf ${LIBCARLA_INSTALL_SERVER_FOLDER} ${LIBCARLA_INSTALL_CLIENT_FOLDER}
|
||||
|
||||
fi
|
||||
|
@ -124,6 +129,10 @@ function build_libcarla {
|
|||
M_TOOLCHAIN=${LIBSTDCPP_TOOLCHAIN_FILE}
|
||||
M_BUILD_FOLDER=${LIBCARLA_BUILD_CLIENT_FOLDER}.$(echo "$2" | tr '[:upper:]' '[:lower:]')
|
||||
M_INSTALL_FOLDER=${LIBCARLA_INSTALL_CLIENT_FOLDER}
|
||||
elif [ $1 == Pytorch ] ; then
|
||||
M_TOOLCHAIN=${LIBSTDCPP_TOOLCHAIN_FILE}
|
||||
M_BUILD_FOLDER=${LIBCARLA_BUILD_PYTORCH_FOLDER}.$(echo "$2" | tr '[:upper:]' '[:lower:]')
|
||||
M_INSTALL_FOLDER=${LIBCARLA_INSTALL_SERVER_FOLDER}
|
||||
elif [ $1 == ClientRSS ] ; then
|
||||
BUILD_TYPE='Client'
|
||||
M_TOOLCHAIN=${LIBSTDCPP_TOOLCHAIN_FILE}
|
||||
|
@ -197,6 +206,9 @@ fi
|
|||
if { ${BUILD_SERVER} && ${BUILD_OPTION_RELEASE}; }; then
|
||||
|
||||
build_libcarla Server Release
|
||||
if ${USE_PYTORCH} ; then
|
||||
build_libcarla Pytorch Release
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
|
|
|
@ -113,19 +113,19 @@ LibCarla.release: LibCarla.server.release LibCarla.client.release
|
|||
|
||||
LibCarla.server: LibCarla.server.debug LibCarla.server.release
|
||||
LibCarla.server.debug: setup
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --debug
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --debug $(ARGS)
|
||||
LibCarla.server.release: setup
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --release
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --release $(ARGS)
|
||||
|
||||
LibCarla.client: LibCarla.client.debug LibCarla.client.release
|
||||
LibCarla.client.debug: setup
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --debug
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --debug $(ARGS)
|
||||
LibCarla.client.release: setup
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --release
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --release $(ARGS)
|
||||
|
||||
LibCarla.client.rss: LibCarla.client.rss.debug LibCarla.client.rss.release
|
||||
LibCarla.client.rss.debug: setup ad-rss
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --debug --rss
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --debug --rss
|
||||
LibCarla.client.rss.release: setup ad-rss
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --release --rss
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ DOC_STRING="Download and install the required libraries for carla."
|
|||
|
||||
USAGE_STRING="Usage: $0 [--python-version=VERSION]"
|
||||
|
||||
OPTS=`getopt -o h --long help,chrono,python-version: -n 'parse-options' -- "$@"`
|
||||
OPTS=`getopt -o h --long help,chrono,pytorch,python-version: -n 'parse-options' -- "$@"`
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
PY_VERSION_LIST=3
|
||||
USE_CHRONO=false
|
||||
USE_PYTORCH=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
|
@ -23,6 +24,9 @@ while [[ $# -gt 0 ]]; do
|
|||
--chrono )
|
||||
USE_CHRONO=true;
|
||||
shift ;;
|
||||
--pytorch )
|
||||
USE_PYTORCH=true;
|
||||
shift ;;
|
||||
-h | --help )
|
||||
echo "$DOC_STRING"
|
||||
echo "$USAGE_STRING"
|
||||
|
@ -586,7 +590,6 @@ if ${USE_CHRONO} ; then
|
|||
mkdir -p ${LIBCARLA_INSTALL_SERVER_FOLDER}/include/
|
||||
cp -p ${CHRONO_INSTALL_DIR}/lib/*.so ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
cp -p -r ${CHRONO_INSTALL_DIR}/include/* ${LIBCARLA_INSTALL_SERVER_FOLDER}/include/
|
||||
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
|
@ -723,6 +726,85 @@ fi
|
|||
mkdir -p ${LIBCARLA_INSTALL_CLIENT_FOLDER}/bin/
|
||||
cp ${PATCHELF_EXE} ${LIBCARLA_INSTALL_CLIENT_FOLDER}/bin/
|
||||
|
||||
# ==============================================================================
|
||||
# -- Download libtorch and dependencies --------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
if ${USE_PYTORCH} ; then
|
||||
|
||||
LIBTORCH_BASENAME=libtorch
|
||||
|
||||
LIBTORCH_PATH=${PWD}/${LIBTORCH_BASENAME}
|
||||
LIBTORCH_INCLUDE=${LIBTORCH_PATH}/include
|
||||
LIBTORCH_LIB=${LIBTORCH_PATH}/lib
|
||||
LIBTORCH_ZIPFILE=libtorch-shared-with-deps-1.11.0+cu113.zip
|
||||
LIBTORCH_REPO=https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.11.0%2Bcu113.zip
|
||||
if [[ ! -d ${LIBTORCH_PATH} ]] ; then
|
||||
wget ${LIBTORCH_REPO}
|
||||
unzip ${LIBTORCH_ZIPFILE}
|
||||
fi
|
||||
|
||||
function build_torch_extension {
|
||||
|
||||
LIB_SOURCE=$1
|
||||
LIB_INSTALL=$2
|
||||
LIB_REPO=$3
|
||||
if [[ ! -d ${LIB_INSTALL} ]] ; then
|
||||
if [[ ! -d ${LIB_SOURCE} ]] ; then
|
||||
mkdir -p ${LIB_SOURCE}
|
||||
log "${LIB_REPO}"
|
||||
git clone ${LIB_REPO} ${LIB_SOURCE}
|
||||
mkdir -p ${LIB_SOURCE}/build
|
||||
fi
|
||||
pushd ${LIB_SOURCE}/build >/dev/null
|
||||
|
||||
cmake -DCMAKE_PREFIX_PATH="${LIBTORCH_PATH}" \
|
||||
-DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \
|
||||
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL}" \
|
||||
-DCMAKE_CUDA_FLAGS="-gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_53,code=sm_53 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_62,code=sm_62 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_72,code=sm_72 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_86,code=sm_86 -gencode=arch=compute_87,code=sm_87 -Wno-deprecated-gpu-targets" \
|
||||
-DWITH_CUDA=ON \
|
||||
..
|
||||
make
|
||||
make install
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
log "Build libtorch scatter"
|
||||
#LibtorchScatter
|
||||
LIBTORCHSCATTER_BASENAME=libtorchscatter
|
||||
LIBTORCHSCATTER_SOURCE_DIR=${PWD}/${LIBTORCHSCATTER_BASENAME}-source
|
||||
LIBTORCHSCATTER_INSTALL_DIR=${PWD}/${LIBTORCHSCATTER_BASENAME}-install
|
||||
LIBTORCHSCATTER_INCLUDE=${LIBTORCHSCATTER_INSTALL_DIR}/include
|
||||
LIBTORCHSCATTER_LIB=${LIBTORCHSCATTER_INSTALL_DIR}/lib
|
||||
LIBTORCHSCATTER_REPO="https://github.com/rusty1s/pytorch_scatter.git"
|
||||
|
||||
build_torch_extension ${LIBTORCHSCATTER_SOURCE_DIR} ${LIBTORCHSCATTER_INSTALL_DIR} "${LIBTORCHSCATTER_REPO}"
|
||||
|
||||
log "Build libtorch cluster"
|
||||
LIBTORCHCLUSTER_BASENAME=libtorchcluster
|
||||
LIBTORCHCLUSTER_SOURCE_DIR=${PWD}/${LIBTORCHCLUSTER_BASENAME}-source
|
||||
LIBTORCHCLUSTER_INSTALL_DIR=${PWD}/${LIBTORCHCLUSTER_BASENAME}-install
|
||||
LIBTORCHCLUSTER_INCLUDE=${LIBTORCHCLUSTER_INSTALL_DIR}/include
|
||||
LIBTORCHCLUSTER_LIB=${LIBTORCHCLUSTER_INSTALL_DIR}/lib
|
||||
LIBTORCHCLUSTER_REPO="https://github.com/rusty1s/pytorch_cluster.git"
|
||||
|
||||
build_torch_extension ${LIBTORCHCLUSTER_SOURCE_DIR} ${LIBTORCHCLUSTER_INSTALL_DIR} "${LIBTORCHCLUSTER_REPO}"
|
||||
|
||||
mkdir -p ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
cp -p ${LIBTORCH_LIB}/*.a ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
cp -p ${LIBTORCH_LIB}/*.so* ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
cp -p ${LIBTORCHSCATTER_LIB}/*.so ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
cp -p ${LIBTORCHCLUSTER_LIB}/*.so ${LIBCARLA_INSTALL_SERVER_FOLDER}/lib/
|
||||
|
||||
mkdir -p ${CARLAUE4_PLUGIN_ROOT_FOLDER}/Binaries/Linux/
|
||||
cp -p ${LIBTORCH_LIB}/*.so* ${CARLAUE4_PLUGIN_ROOT_FOLDER}/Binaries/Linux/
|
||||
cp -p ${LIBTORCHSCATTER_LIB}/*.so* ${CARLAUE4_PLUGIN_ROOT_FOLDER}/Binaries/Linux/
|
||||
cp -p ${LIBTORCHCLUSTER_LIB}/*.so* ${CARLAUE4_PLUGIN_ROOT_FOLDER}/Binaries/Linux/
|
||||
fi
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# -- Generate Version.h --------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
@ -810,6 +892,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Server")
|
|||
set(RPCLIB_LIB_PATH "${RPCLIB_LIBCXX_LIBPATH}")
|
||||
set(GTEST_INCLUDE_PATH "${GTEST_LIBCXX_INCLUDE}")
|
||||
set(GTEST_LIB_PATH "${GTEST_LIBCXX_LIBPATH}")
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Pytorch")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${LIBTORCH_PATH}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${LIBTORCHSCATTER_INSTALL_DIR}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${LIBTORCHCLUSTER_INSTALL_DIR}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${LIBTORCHSPARSE_INSTALL_DIR}")
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Client")
|
||||
# Here libraries linking libstdc++.
|
||||
set(RPCLIB_INCLUDE_PATH "${RPCLIB_LIBSTDCXX_INCLUDE}")
|
||||
|
|
|
@ -15,6 +15,7 @@ CARLA_PYTHONAPI_SOURCE_FOLDER=${CARLA_PYTHONAPI_ROOT_FOLDER}/carla
|
|||
|
||||
LIBCARLA_ROOT_FOLDER=${CURDIR}/LibCarla
|
||||
LIBCARLA_BUILD_SERVER_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-server-build
|
||||
LIBCARLA_BUILD_PYTORCH_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-pytorch-build
|
||||
LIBCARLA_BUILD_CLIENT_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-client-build
|
||||
LIBCARLA_INSTALL_SERVER_FOLDER=${CARLAUE4_PLUGIN_ROOT_FOLDER}/CarlaDependencies
|
||||
LIBCARLA_INSTALL_CLIENT_FOLDER=${CARLA_PYTHONAPI_SOURCE_FOLDER}/dependencies
|
||||
|
|
Loading…
Reference in New Issue