Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning when serializing data in a callback #314

Closed
CruxDevStuff opened this issue May 2, 2023 · 0 comments
Closed

warning when serializing data in a callback #314

CruxDevStuff opened this issue May 2, 2023 · 0 comments

Comments

@CruxDevStuff
Copy link

I'm polling a sensor every 50ms which triggers a callback that publishes the sensor packet.

    accel = frame.accelerometer
    gyro = frame.gyroscope
    imu_msg.accel = [float(accel.x), float(accel.y), float(accel.z)]
    imu_msg.gyro = [float(gyro.x), float(gyro.y), float(gyro.z)]
    packet = imu_msg.to_bytes() <----- Here
    imu_publisher.put(packet)

Even though the code executes just fine(no memory leaks), I'm getting this warning:

UserWarning: This message has already been written once. Be very careful that you're not setting Text/Struct/List fields more than once, since that will cause memory leaks (both in memory and in the serialized data). You can disable this warning by calling the clear_write_flag method of this object after every write.
packet = imu_msg.to_bytes()

Is this unintended behaviour(just ignore the warning ?) or is there another way to do this properly ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant