Exemplo n.º 1
0
def update_table_state(table):
    table_width = 1.12
    
    # Cue ball
    cue = BallState()
    cue.id = 0
    cue.point.point.x = 0.5
    cue.point.point.y = table_width / 2
    table.balls.append(cue)

    # 1 ball
    ball_1 = BallState()
    ball_1.id = 1
    ball_1.point.point.x = 1.0
    ball_1.point.point.y = table_width / 2
    table.balls.append(ball_1)

    # 2 ball
    ball_2 = BallState()
    ball_2.id = 1
    ball_2.point.point.x = 1.0
    ball_2.point.point.y = table_width / 2 + 0.3
    table.balls.append(ball_2)
Exemplo n.º 2
0
from fastfiz_msgs.srv import SimulateShot, SimulateShotRequest, SimulateShotResponse
from billiards_msgs.msg import TableState, BallState 

if __name__ == "__main__":
    rospy.init_node("shot_test")
    
    ss = rospy.ServiceProxy("simulate_shot", SimulateShot, persistent=True)
    
    pub = rospy.Publisher("simulated_shot", TableState, latch=True)
    
    vel = 0.5
    phi = 0.0
    while (True):
        req = SimulateShotRequest()
        ball = BallState()
        ball.id = 0
        ball.point.point.x = 0.5
        ball.point.point.y = 0.5
    
        req.state.balls.append(ball)
        
        ball2 = BallState()
        ball2.id = 1
        ball2.point.point.x = 1.0
        ball2.point.point.y = 0.5
        req.state.balls.append(ball2)
    
        req.shot.v = vel
        req.shot.theta = 1.5
        req.shot.phi = phi