Skip to content
Snippets Groups Projects
Commit c29b115b authored by oceanpdoshi@g.ucla.edu's avatar oceanpdoshi@g.ucla.edu
Browse files

some comments, changed < to <=

avoids cropping off time at the end of sim
parent 66cc2c21
Branches
No related merge requests found
......@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
import IPython
# TODO - add collision checking for circle/random data
class DataGenerator():
def __init__(self, landmarks, duration, robot_labels, starting_states, start_time, delta_t,
velocity_noise = 0, angular_velocity_noise = 0, measurement_range_noise = 0, bearing_noise = 0, communication_noise = 0,
......@@ -87,7 +87,7 @@ class DataGenerator():
# Generates simulated of robots moving in a circle
def generate_circular_data(self, test, velocity=0.1, velocity_spread=0):
radian_step = 2*pi/self.duration
radian_step = 2*pi/self.duration # can be hardcoded to be a certain amount of degrees (radians)
# if it's a "perfect" circle, then velocity spread will be 0
distance_step = (velocity + np.random.normal(0, velocity_spread))*self.delta_t
......@@ -111,7 +111,7 @@ class DataGenerator():
self.groundtruth_data[i].append({'time' : self.time_arr['groundtruth'][i][time_idx], 'x_pos': next_x, 'y_pos': next_y, 'orientation': next_orientation})
self.generate_odometry_data()
self.generate_measurement_data()
......
......@@ -23,7 +23,6 @@ def find_nearest_time_idx(l, value):
# TODO
# communication
# scheduling
class SimulatedDataSetManager:
def __init__(self, dataset_name, landmarks, duration, robot_labels,
......@@ -42,7 +41,7 @@ class SimulatedDataSetManager:
self.curr_request = 'odometry'
self.curr_robot_idx = 0
# time step of the simulation (secs) TODO - user specified
# time step of the simulation (secs)
self.delta_t = delta_t
# landmarks = {landmark ID: [x,y]} (m)
......@@ -52,7 +51,7 @@ class SimulatedDataSetManager:
raise Exception("Invalid landmark ID: landmark IDs must be bigger than 5.")
# starting_states = {robot label: [time, x_pos, y_pos, orientation], ... }
# TODO - create a generate starting states function (potentially randomized to fit boundary)
# TODO - create a generate starting states function
self.starting_states = {label : [self.start_time, i, 0, 0.0] for i,label in enumerate(self.robot_labels)}
# groundtruth & odometry are of fixed length=duration
......@@ -127,8 +126,6 @@ class SimulatedDataSetManager:
req.set_message(message)
req.set_type(req_type)
# TODO - perhaps this is the sourceo f the issue?
if (req_type == 'measurement' and self.reset_robot_ctr()):
current_time += self.delta_t
......@@ -159,7 +156,7 @@ class SimulatedDataSetManager:
message['robot_index'] = robot_idx
# Past the total time of simulation or no further measurements
valid_dataline = current_time < self.end_time or (abs(current_time - self.end_time) < 0.001) # <= w/floats
valid_dataline = current_time <= self.end_time or (abs(current_time - self.end_time) < 0.001) # <= w/floats
# Select message data
if valid_dataline:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment