def get_msg(intarray):
    msg = IntArray()
    msg.data = intarray
    return msg
def get_msg(intarray):
    msg = IntArray()
    msg.data = intarray
    return msg
Beispiel #3
0
else:
    im = Image.open(image_str+'.png')

cam_sim = logitech_cam_simulation(size,im,scale_factor)
#
Y0,Y1,cmd = cam_sim.simulate_Y_pair(size,[0,0,50])
print('simulated')
def show(Y0,Y1):
    Image.fromarray(Y0).show()
    Image.fromarray(Y1).show()
#pdb.set_trace()
for i in range(duration):
    print(i)
    command = command_list[np.random.randint(0,len(command_list))]
    Y0,Y1,cmd = cam_sim.simulate_Y_pair(size,command)
#    Image.fromarray(Y0).save('test'+str(i)+'y0cmd'+str(cmd)+'.png')
#    Image.fromarray(Y1).save('test'+str(i)+'y1cmd'+str(cmd)+'.png')
#    pdb.set_trace()
    if Y0.__class__ == int:
        print('Ignoring message')
    else:
        Y0ros = ParseMessages.numpy_to_imgmsg(Y0)
        Y1ros = ParseMessages.numpy_to_imgmsg(Y1)
        out_bag.write('Y0',Y0ros,rospy.Time(i+1))
        out_bag.write('Y1',Y1ros,rospy.Time(i+1))
        cmd_msg = IntArray()
        cmd_msg.data = cmd
        out_bag.write('U0',cmd_msg,rospy.Time(i+1))

out_bag.close()