# ---

# # Python Tools Usage Examples

from proto.sensor_msg_pb2 import SensorProto
import numpy as np
import matplotlib.pyplot as plt
import os
from python_tools.proto_log import ProtoLog
from python_tools.sensor_proto_log import SensorProtoLog
from proto.tbots_software_msgs_pb2 import PrimitiveSet

# +
# Create a ProtoLog from the chunked Protobuf message files in the directory,
# with contained message type PrimitiveSet
primitive_set_proto_log = ProtoLog("test_data/AI_PrimitiveSet", PrimitiveSet)

# create a list of primitives for robot 0 from the primitive sets
robot_0_primitives = [
    primitive_set.robot_primitives[0]
    for primitive_set in primitive_set_proto_log
]
plt.figure(figsize=(20, 5))

# build a list of move primitive final angles and their corresponding timestamps from the list of robot 0 primitives
final_angles = []
timestamps = []
for idx, prim in enumerate(robot_0_primitives):
    if prim.HasField("move"):
        final_angles.append(prim.move.final_angle.radians)
        timestamps.append(
Ejemplo n.º 2
0
#       format_version: '1.5'
#       jupytext_version: 1.10.1
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
from software.proto.messages_robocup_ssl_wrapper_pb2 import SSL_WrapperPacket
from python_tools.proto_log import ProtoLog
import ipywidgets
from IPython.display import display

wrapper_proto_log = ProtoLog(
    "/home/jordan/log_ssl_wrapper_filtered_world_test/SensorFusion_SSL_WrapperPacket",
    SSL_WrapperPacket,
)

# +
from bokeh.plotting import figure
from bokeh.io import output_notebook, show, push_notebook
from python_tools.plotting.plot_ssl_wrapper import SSLWrapperPlotter

output_notebook()

fig = figure(plot_width=900, plot_height=900, match_aspect=True)

ssl_wrapper_plotter = SSLWrapperPlotter(fig)


def plot_ssl_wrapper_at_idx(idx):
# ---

# # Python Tools Usage Examples

from software.proto.sensor_msg_pb2 import SensorProto
import numpy as np
import matplotlib.pyplot as plt
import os
from python_tools.proto_log import ProtoLog
from python_tools.sensor_proto_log import SensorProtoLog
from shared.proto.tbots_software_msgs_pb2 import PrimitiveSet

# +
# Create a ProtoLog from the chunked Protobuf message files in the directory,
# with contained message type PrimitiveSet
primitive_set_proto_log = ProtoLog(
    "/home/jordan/protologgertest/PrimitiveSet/", PrimitiveSet)

# create a list of primitives for robot 0 from the primitive sets
robot_0_primitives = [
    primitive_set.robot_primitives[0]
    for primitive_set in primitive_set_proto_log
]
plt.figure(figsize=(20, 5))

# build a list of autochip move final angles and their corresponding timestamps from the list of robot 0 primitives
final_angles = []
timestamps = []
for idx, prim in enumerate(robot_0_primitives):
    if prim.HasField("autochip_move"):
        final_angles.append(prim.autochip_move.final_angle.radians)
        timestamps.append(
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
from proto.messages_robocup_ssl_wrapper_pb2 import SSL_WrapperPacket
from python_tools.proto_log import ProtoLog
import ipywidgets
from IPython.display import display
from software.python_bindings import world, passing, keep_away
import numpy as np

wrapper_proto_log = ProtoLog(
    "test_data/SensorFusion_SSL_WrapperPacket",
    SSL_WrapperPacket,
)
# -

world.getDefaultSensorFusionConfig()

# +
from bokeh.models import ColumnDataSource


class PointsPlotter:
    def __init__(self, fig, legend_label, marker_type, color, size=10):
        self.fig = fig
        self.points_source = ColumnDataSource(dict(xs=[], ys=[]))
        self.fig.scatter(
            source=self.points_source,