Exemple #1
0
def callback(data):
    msg = target_positions_msg()
    msg2 = strategy_output_msg()
    msg.x[0] = 2
    msg2.x[0] = 3

    msg2.control_options[0] = control_options.position

    pub.publish(msg)
    pub2.publish(msg2)
Exemple #2
0
def callback(data):
    msg = target_positions_msg()

    #Creating attractive potential
    attract_ball = pf.AttractivePotentialField(
                        np.array([data.ball_x, data.ball_y]),
                        BALL_ATTRACTIVE, min_magnitude=0.3)

    for robot in range(number_of_robots):
        resultant_vector = attract_ball.calculate_force(np.array([data.x[robot], data.y[robot]]))
        msg.x[robot] = resultant_vector[0]
        msg.y[robot] = resultant_vector[1]

    pub.publish(msg)
Exemple #3
0
def measurement_callback(data):
    msg = target_positions_msg()

    ball = [data.ball_x, data.ball_y]
    allies = [[], [], []]
    for robot in range(3):
        allies[robot] = [data.x[robot], data.y[robot]]

    player.setPositions(allies=allies, ball=ball, field_side=field_side)

    for i in range(3):
        msg.x[i], msg.y[i] = player.getTarget()

    pub.publish(msg)
Exemple #4
0
def callback(data):
    msg = target_positions_msg()
    msg2 = strategy_output_msg()
    ball = [data.ball_x, data.ball_y]

    for robot in range(number_of_robots):
        msg.x[robot] = data.ball_x
        msg.y[robot] = data.ball_y
        msg2.x[robot] = data.ball_x
        msg2.y[robot] = data.ball_y
        msg2.control_options[robot] = control_options.position

    pub.publish(msg)
    pub2.publish(msg2)
def convertTargetPositions(global_target):
    msg = target_positions_msg()

    for robot in range(number_of_robots):
        relative_target = [
            global_target.x[robot] - allies_x[robot],
            global_target.y[robot] - allies_y[robot]
        ]
        relative_target = convert_axis_to_robot(relative_target,
                                                allies_th[robot])

        msg.x[robot] = relative_target[0]
        msg.y[robot] = relative_target[1]

    pub.publish(msg)
Exemple #6
0
def callback(data):
    msg = target_positions_msg()

    #PCreating an tangential field
    tangencial_ball = pf.TangencialPotentialField(
        np.array([data.ball_x, data.ball_y]), TANGENCIAL_BALL_MAGNITUDE)

    for robot in range(number_of_robots):

        resultant_vector = tangencial_ball.calculate_force(
            np.array([data.x[robot], data.y[robot]]))
        msg.x[robot] = resultant_vector[0]
        msg.y[robot] = resultant_vector[1]

    pub.publish(msg)
Exemple #7
0
def callback(data):
    msg = target_positions_msg()

    ball = [data.ball_x, data.ball_y]
    for i in range(3):
        allies[i] = [data.x[i], data.y[i], data.th[i]]

    for robot in range(number_of_robots):
        player.setPositions(ball=ball, allies=allies, my_index=robot)
        target = player.getTarget()

        msg.x[robot] = target[0]
        msg.y[robot] = target[1]

    pub.publish(msg)
Exemple #8
0
def callback(data):
    msg = target_positions_msg()

    #Potential Fields
    attract_ball = pf.AttractivePotentialField(np.array(
        [data.ball_x, data.ball_y]),
                                               BALL_ATTRACTIVE,
                                               min_magnitude=0.3)
    kick_attract_ball = pf.AttractivePotentialField(
        np.array([data.ball_x, data.ball_y]), BALL_ATTRACTIVE * 2)
    tangencial_ball = pf.TangencialPotentialField(
        np.array([data.ball_x, data.ball_y]), TANGENCIAL_BALL_MAGNITUDE)
    repulsive_enemy_fields = generate_repulsive_field(data,
                                                      ENEMY_REPULSIVE_RANGE,
                                                      ENEMY_REPULSIVE_WEIGHT,
                                                      ally=False)
    repulsive_ally_fields = generate_repulsive_field(data,
                                                     ALLY_REPULSIVE_RANGE,
                                                     ALLY_REPULSIVE_WEIGHT)

    for robot in range(number_of_robots):
        resultant_vector = np.array([0.0, 0.0])

        #Calculate repulsive force from each enemy
        for field in repulsive_enemy_fields:
            resultant_vector += field.calculate_force(
                np.array([data.x[robot], data.y[robot]]))

        #Calculate repulsive force from each ally
        for i in range(len(repulsive_ally_fields)):
            #Ignore his own field
            if i != robot:
                resultant_vector += repulsive_ally_fields[i].calculate_force(
                    np.array([data.x[robot], data.y[robot]]))

        #resultant_vector += tangencial_ball.calculate_force(np.array([data.x[robot], data.y[robot]]))
        resultant_vector += attract_ball.calculate_force(
            np.array([data.x[robot], data.y[robot]]))
        msg.x[robot] = resultant_vector[0]
        msg.y[robot] = resultant_vector[1]

    pub.publish(msg)
Exemple #9
0
def callback(data):
    msg = target_positions_msg()

    if (side_opponent == 'Right'):
        opponent_goal = np.array([0.8, 0])
    else:
        opponent_goal = np.array([-0.8, 0])
    direction = np.array([data.ball_x, data.ball_y]) - opponent_goal

    #Creating attractive potential
    selective_field = pf.SelectivePotentialField(
        np.array([data.ball_x, data.ball_y]), SELECTIVE_WIDTH, SELECTIVE_RANGE,
        direction, opponent_goal, 4, 0.3)

    for robot in range(number_of_robots):
        resultant_vector = selective_field.calculate_force(
            np.array([data.x[robot], data.y[robot]]))
        msg.x[robot] = resultant_vector[0]
        msg.y[robot] = resultant_vector[1]

    pub.publish(msg)
Exemple #10
0
def callback(data):
    msg = target_positions_msg()
    obt_circle(msg)
    pub.publish(msg)
Exemple #11
0
def callback(data):
    global k
    msg = target_positions_msg()
    set_3_pnts(msg)
    pub.publish(msg)