Esempio n. 1
0
def sc_(params, shell=False):
    """ Run command or command list with arguments.  Wait for commands to complete
        If args.verbose is true, prints command
        If any errors stop list execution and returns error
        if shell=True go shell mode (only for --cron-jobs)

    :param params: command or command list
    :return: error return
    """
    # if not a list convert to a one element list
    if not isinstance(params, list):
        params = [params]

    # traverse list executing commands
    for _cmd in params:
        # si shell = True no hacemos el split
        cmd = _cmd if shell else _cmd.split()
        if args.verbose:
            Environment().msgrun(' ')
            if shell:
                Environment().msgrun(cmd)
            else:
                Environment().msgrun(' '.join(cmd))
            Environment().msgrun(' ')
        ret = subprocess.call(cmd, shell=shell)
        if ret:
            return ret

    return 0
# Convert string labels into numbers.
le = LabelEncoder()
Y = le.fit_transform(df['action'])

knn = KNeighborsClassifier(n_neighbors=25)
knn.fit(X, Y)  # Train the model using the training sets

# if __name__ == '__main__':

for episode in range(100):
    all_data = []
    time = 0
    pred_actions = []
    ego = car(car_id='ego')
    env = Environment(render=True if episode % 10 == 0 else True,
                      ego_id=ego.carid)
    env.start('Highway.sumocfg')
    # prevent ego vehicle from doing any lane change by itself
    traci.vehicle.setLaneChangeMode(ego.carid, 0x00)

    last_distance = 0
    rows_list = []
    risk_detected = False
    risk_start = -1
    risk_distance = 0
    collided = False
    for step in range(1400):
        traci.simulationStep()
        if env.collision_happened():
            collided = True
        if step > 210:  #ego vehicle should be now on the road
Esempio n. 3
0
def main(): 
    seed(1)
    env = Environment() 
    path = '/Plasticity/Experiment_Pop_Online_Test'
    run_instance(path, env)
Esempio n. 4
0
        'error and continues with next repo.'
        'The tag was previously setted with -T option. '
        'To undo this situation issue a --undo-checkout-tag')

    parser.add_argument(
        '--undo-checkout-tag',
        action='store_true',
        help=
        'checkouts the normal branch (i.e. odoo version) for all the repos belonging '
        'to the client. Needs -c option. '
        'This revers the the repos modifyed for a --checkout-tag to its normal state. '
        'Warning: if there is any local change in a repo, the checkout will fail.'
    )

    args = parser.parse_args()
    environment = Environment(args, _clients)

    if args.install_cli:
        install_client(environment)
    if args.stop_env:
        stop_environment(environment)
    if args.run_env:
        run_environment(environment)
    if args.stop_cli:
        stop_client(environment)
    if args.run_cli:
        run_client(environment)
    if args.pull_all:
        pull_all(environment)
    if args.list:
        list_data(environment)