Пример #1
0
    def __init__(self, filename):
        self.messages = load_messages(filename)

        # messages with gitsha1 are transmitted before the simulation loop
        for i, msg in enumerate(self.messages):
            if msg.HasField('gitsha1'):
                start_index = i + 1
            else:
                break

        self.records = get_records_from_messages(self.messages)[start_index:]
        self.t = get_time_vector(self.records)
        self.states = self.records.state[:, 1:] # skip yaw angle
        self.colors = np.roll(sns.color_palette('Paired', 12), 2, axis=0)

        steer_encoder_counts_per_rev = 152000
        encoder_count = self.records.sensors.steer_encoder_count
        encoder_angle = encoder_count / steer_encoder_counts_per_rev * 2*np.pi
        encoder_angle[np.where(encoder_angle > np.pi)[0]] -= 2*np.pi
        self.measured_steer_angle = encoder_angle

        self.kollmorgen_command_torque = convert_kollmorgen_command_dac(
                self.records.actuators.kollmorgen_command_torque)
        self.kollmorgen_applied_torque = convert_kollmorgen_applied_adc(
                self.records.sensors.kollmorgen_actual_torque)
        self.kistler_sensor_torque = convert_kistler_torque_adc(
                self.records.sensors.kistler_measured_torque)
Пример #2
0
    def __init__(self, filename):
        self.messages = load_messages(filename)

        # messages with gitsha1 are transmitted before the simulation loop
        for i, msg in enumerate(self.messages):
            if msg.HasField('gitsha1'):
                start_index = i + 1
            else:
                break

        self.records = get_records_from_messages(self.messages)[start_index:]
        self.t = get_time_vector(self.records)
        self.states = self.records.state[:, 1:]  # skip yaw angle
        self.colors = np.roll(sns.color_palette('Paired', 12), 2, axis=0)

        steer_encoder_counts_per_rev = 152000
        encoder_count = self.records.sensors.steer_encoder_count
        encoder_angle = encoder_count / steer_encoder_counts_per_rev * 2 * np.pi
        encoder_angle[np.where(encoder_angle > np.pi)[0]] -= 2 * np.pi
        self.measured_steer_angle = encoder_angle

        self.kollmorgen_command_torque = convert_kollmorgen_command_dac(
            self.records.actuators.kollmorgen_command_torque)
        self.kollmorgen_applied_torque = convert_kollmorgen_applied_adc(
            self.records.sensors.kollmorgen_actual_torque)
        self.kistler_sensor_torque = convert_kistler_torque_adc(
            self.records.sensors.kistler_measured_torque)
Пример #3
0
    return x


if __name__ == '__main__':
    import sys
    import matplotlib.pyplot as plt
    from plot_sim import plot_states

    sim_time = 3  # time for our Whipple simulation or upper limit [s]
    start_index = 50  # number of records to skip to allow some time for state
    # estimate to converge

    if len(sys.argv) > 1:
        from load_sim import (load_messages, get_records_from_messages,
                              get_time_vector)
        messages = load_messages(sys.argv[1])
        records = get_records_from_messages(messages)
        t = get_time_vector(records[start_index:])
        t -= t[0]  # redefine zero time for simulator data

        m = messages[0]
        v = m.model.v
        dt = m.model.dt
        if t[-1] < sim_time:
            sim_time = t[-1]
        n = int(sim_time / dt)

        states = records[start_index:].state[:, 1:]
        fig2, ax2 = plot_states(t[:n], states[:n, :], to_degrees=True)
        fig2.suptitle('Phobos simulator')
        x0 = np.array(messages[start_index].state.x[1:]).reshape((4, 1))
Пример #4
0
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib2tikz import save as tikz_save
import seaborn as sns
sns.set_style('whitegrid')
sns.set_context('paper')

file_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.abspath(os.path.join(file_dir, os.pardir)))
from plot_sim import plot_states
from load_sim import load_messages, get_records_from_messages, get_time_vector
from simulate_whipple_benchmark import simulate

if __name__ == '__main__':
    messages = load_messages(os.path.join(file_dir, 'whipple.pb'))
    start_index = 50  # ignore some samples to give Kalman state estimate
    # time to converge
    sim_time = 3
    stride = 10  # don't plot all the points

    records = get_records_from_messages(messages)[start_index::stride]
    t = get_time_vector(records)
    t -= t[0]  # redefine zero time for simulator data

    # plot in degrees because understanding radians is harder
    states = records.state[:, 1:]
    fig1, ax1 = plot_states(t, states, second_yaxis=True, to_degrees=True)

    m = messages[0]
    v = m.model.v
Пример #5
0
import numpy as np
import matplotlib.pyplot as plt
#from matplotlib2tikz import save as tikz_save
import seaborn as sns
sns.set_style('whitegrid')
sns.set_context('paper')

file_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.abspath(os.path.join(file_dir, os.pardir)))
from plot_sim import plot_states
from load_sim import load_messages, get_records_from_messages, get_time_vector
from simulate_whipple_benchmark import simulate, calculate_weave_frequency

if __name__ == '__main__':
    if len(sys.argv) > 1:
        messages = load_messages(sys.argv[1])
    else:
        messages = load_messages(os.path.join(file_dir, 'whipple.pb'))

    # ignore first sample as it is transmitted before the simulation loop
    records = get_records_from_messages(messages[1:])

    if len(sys.argv) >= 5:
        start = float(sys.argv[2])
        stop = float(sys.argv[3])
        stride = int(sys.argv[4])

        t = get_time_vector(records)
        t -= t[0]
        start_index = np.squeeze(np.argwhere(t >= start))[0]
        sim_time = stop - start
    return x


if __name__ == '__main__':
    import sys
    import matplotlib.pyplot as plt
    from plot_sim import plot_states

    sim_time = 3 # time for our Whipple simulation or upper limit [s]
    start_index = 50 # number of records to skip to allow some time for state
                     # estimate to converge

    if len(sys.argv) > 1:
        from load_sim import (load_messages, get_records_from_messages,
                              get_time_vector)
        messages = load_messages(sys.argv[1])
        records = get_records_from_messages(messages)
        t = get_time_vector(records[start_index:])
        t -= t[0] # redefine zero time for simulator data

        m = messages[0]
        v = m.model.v
        dt = m.model.dt
        if t[-1] < sim_time:
            sim_time = t[-1]
        n = int(sim_time/dt)

        states = records[start_index:].state[:, 1:]
        fig2, ax2 = plot_states(t[:n], states[:n, :], to_degrees=True)
        fig2.suptitle('Phobos simulator')
        x0 = np.array(messages[start_index].state.x[1:]).reshape((4, 1))
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import seaborn as sns
sns.set_style('whitegrid', {'legend.frameon': True})
sns.set_context('talk')

file_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.abspath(os.path.join(file_dir, os.pardir)))
from load_sim import load_messages, get_records_from_messages, get_time_vector
from simulate_whipple_benchmark import simulate, calculate_weave_frequency

if __name__ == '__main__':
    filename = sys.argv[1]
    messages = load_messages(filename)

    # ignore first sample as it is transmitted before the simulation loop
    records = get_records_from_messages(messages[1:])
    t = get_time_vector(records)
    t -= t[0]

    state = records.state[:, 1:]  # skip yaw angle

    colors = np.roll(sns.color_palette('Paired', 10), 2, axis=0)
    labels = [
        r'$\phi$, roll angle',
        r'$\delta$, steer angle',
        r'$\dot{\phi}$, roll rate',
        r'$\dot{\delta}$, steer rate',
    ]