-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add working lidar and camera export to kitti format
- Loading branch information
Showing
5 changed files
with
240 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
""" | ||
This file includes a number of helper functions for the main loop of the carla simulator. | ||
This includes printing measurements and steering.0 | ||
""" | ||
|
||
from carla.client import VehicleControl | ||
from carla.util import print_over_same_line | ||
|
||
try: | ||
from pygame.locals import K_DOWN | ||
from pygame.locals import K_LEFT | ||
from pygame.locals import K_RIGHT | ||
from pygame.locals import K_SPACE | ||
from pygame.locals import K_UP | ||
from pygame.locals import K_a | ||
from pygame.locals import K_d | ||
from pygame.locals import K_p | ||
from pygame.locals import K_q | ||
from pygame.locals import K_r | ||
from pygame.locals import K_s | ||
from pygame.locals import K_w | ||
except ImportError: | ||
raise RuntimeError('cannot import pygame, make sure pygame package is installed') | ||
|
||
class KeyboardHelper: | ||
|
||
def get_keyboard_control(keys, is_on_reverse, enable_autopilot): | ||
if keys[K_r]: | ||
return None | ||
control = VehicleControl() | ||
if keys[K_LEFT] or keys[K_a]: | ||
control.steer = -1.0 | ||
if keys[K_RIGHT] or keys[K_d]: | ||
control.steer = 1.0 | ||
if keys[K_UP] or keys[K_w]: | ||
control.throttle = 1.0 | ||
if keys[K_DOWN] or keys[K_s]: | ||
control.brake = 1.0 | ||
if keys[K_SPACE]: | ||
control.hand_brake = True | ||
if keys[K_q]: | ||
is_on_reverse = is_on_reverse | ||
if keys[K_p]: | ||
enable_autopilot = enable_autopilot | ||
control.reverse = is_on_reverse | ||
return control, is_on_reverse, enable_autopilot | ||
|
||
|
||
class MeasurementsDisplayHelper: | ||
def print_player_measurements_map(player_measurements, map_position, lane_orientation, timer): | ||
message = 'Step {step} ({fps:.1f} FPS): ' | ||
message += 'Map Position ({map_x:.1f},{map_y:.1f}) ' | ||
message += 'Lane Orientation ({ori_x:.1f},{ori_y:.1f}) ' | ||
message += '{speed:.2f} km/h, ' | ||
message += '{other_lane:.0f}% other lane, {offroad:.0f}% off-road' | ||
message = message.format( | ||
map_x = map_position[0], | ||
map_y = map_position[1], | ||
ori_x = lane_orientation[0], | ||
ori_y = lane_orientation[1], | ||
step = timer.step, | ||
fps = timer.ticks_per_second(), | ||
speed= player_measurements.forward_speed * 3.6, | ||
other_lane = 100 * player_measurements.intersection_otherlane, | ||
offroad = 100 * player_measurements.intersection_offroad) | ||
print_over_same_line(message) | ||
|
||
def print_player_measurements(player_measurements, timer): | ||
message = 'Step {step} ({fps:.1f} FPS): ' | ||
message += '{speed:.2f} km/h, ' | ||
message += '{other_lane:.0f}% other lane, {offroad:.0f}% off-road' | ||
message = message.format( | ||
step=timer.step, | ||
fps=timer.ticks_per_second(), | ||
speed=player_measurements.forward_speed * 3.6, | ||
other_lane=100 * player_measurements.intersection_otherlane, | ||
offroad=100 * player_measurements.intersection_offroad) | ||
print_over_same_line(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.