Skip to content

DNL Mikebauer/multi goal events #13

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions systems/drone/build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ echo "Ensuring the ReSim cli is installed..."
cd $(dirname "$0")
../../scripts/maybe_install_cli.sh

echo "Building the build image..."
./build.sh
#echo "Building the build image..."
#./build.sh

echo "Building the metrics build image..."
./metrics/build.sh
Expand All @@ -63,34 +63,34 @@ echo "Performing ECR Login..."
aws ecr get-login-password --region "${RESIM_SANDBOX_ECR_REGION}" \
| docker login --username AWS --password-stdin "${RESIM_SANDBOX_ECR}"

echo "Pushing build image..."
_FULL_TAG="${RESIM_SANDBOX_ECR}/${RESIM_SANDBOX_ECR_REPO}:${RESIM_SANDBOX_BUILD_TAG_PREFIX}${RESIM_SANDBOX_BUILD_VERSION}"
docker tag "${LOCAL_TAG}" "${_FULL_TAG}"
docker push "${_FULL_TAG}"

echo "Registering build with ReSim..."
resim builds create \
--url "${RESIM_API_URL}" \
--auth-url "${RESIM_AUTH_URL}" \
--branch "${RESIM_SANDBOX_BUILD_BRANCH}" \
--description "A ReSim sandbox build." \
--image "${_FULL_TAG}" \
--project "${RESIM_SANDBOX_PROJECT}" \
--system "${RESIM_SANDBOX_SYSTEM}" \
--version "${RESIM_SANDBOX_BUILD_VERSION}" \
--auto-create-branch
#echo "Pushing build image..."
#_FULL_TAG="${RESIM_SANDBOX_ECR}/${RESIM_SANDBOX_ECR_REPO}:${RESIM_SANDBOX_BUILD_TAG_PREFIX}${RESIM_SANDBOX_BUILD_VERSION}"
#docker tag "${LOCAL_TAG}" "${_FULL_TAG}"
#docker push "${_FULL_TAG}"
#
#echo "Registering build with ReSim..."
#resim builds create \
# --url "${RESIM_API_URL}" \
# --auth-url "${RESIM_AUTH_URL}" \
# --branch "${RESIM_SANDBOX_BUILD_BRANCH}" \
# --description "A ReSim sandbox build." \
# --image "${_FULL_TAG}" \
# --project "${RESIM_SANDBOX_PROJECT}" \
# --system "${RESIM_SANDBOX_SYSTEM}" \
# --version "${RESIM_SANDBOX_BUILD_VERSION}" \
# --auto-create-branch

echo "Pushing metrics image..."
_FULL_METRICS_TAG="${RESIM_SANDBOX_ECR}/${RESIM_SANDBOX_ECR_REPO}:${RESIM_SANDBOX_METRICS_BUILD_TAG_PREFIX}${RESIM_SANDBOX_BUILD_VERSION}"
docker tag "${LOCAL_METRICS_TAG}" "${_FULL_METRICS_TAG}"
docker push "${_FULL_METRICS_TAG}"

echo "Registering metrics build with ReSim..."
resim metrics-builds create \
--url "${RESIM_API_URL}" \
--auth-url "${RESIM_AUTH_URL}" \
--name "A ReSim sandbox metrics build." \
--image "${_FULL_METRICS_TAG}" \
--systems "${RESIM_SANDBOX_SYSTEM}" \
--project "${RESIM_SANDBOX_PROJECT}" \
--version "${RESIM_SANDBOX_BUILD_VERSION}"
#echo "Registering metrics build with ReSim..."
#resim metrics-builds create \
# --url "${RESIM_API_URL}" \
# --auth-url "${RESIM_AUTH_URL}" \
# --name "A ReSim sandbox metrics build." \
# --image "${_FULL_METRICS_TAG}" \
# --systems "${RESIM_SANDBOX_SYSTEM}" \
# --project "${RESIM_SANDBOX_PROJECT}" \
# --version "${RESIM_SANDBOX_BUILD_VERSION}"
37 changes: 32 additions & 5 deletions systems/drone/experiences/local_experience/experience.sim
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,46 @@ dynamic_behavior {
}
}
ilqr_drone {
velocity_cost: 0.06
velocity_cost: 0.01
initial_position: 0
initial_position: 0
initial_position: 0
goal_position: -617
goal_position: 423
goal_position: 200
goals {
position: -100
position: -100
position: 200
}
goals {
position: 100
position: -100
position: 200
}
goals {
position: 100
position: 100
position: 200
}
goals {
position: -100
position: 100
position: 200
}
goals {
position: 0
position: 0
position: 10
}
goals {
position: 0
position: 0
position: 0
}
}
}
}
completion_criteria {
time_limit {
seconds: 30
seconds: 120
}
}
}
Expand Down
1 change: 1 addition & 0 deletions systems/drone/metrics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM python:3.10-slim

LABEL description="Demo metrics build docker image"

COPY resim_open_core-0.0.0-py3-none-manylinux2014_x86_64.whl /resim_open_core-0.0.0-py3-none-manylinux2014_x86_64.whl
COPY requirements_lock.txt /requirements_lock.txt
RUN pip install --no-cache-dir -r /requirements_lock.txt

Expand Down
61 changes: 59 additions & 2 deletions systems/drone/metrics/batch_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.


import uuid

from collections import defaultdict
Expand All @@ -22,14 +21,18 @@
MetricStatus,
HistogramBucket,
)

from datetime import datetime

import plotly.express as px
import pandas as pd
from resim.metrics.proto.validate_metrics_proto import validate_job_metrics
from resim.metrics.python.metrics_writer import ResimMetricsWriter
from resim.metrics.proto.metrics_pb2 import JobMetrics
from resim_python_client.api.batches import list_jobs
from resim_python_client.api.batches import list_events_for_job
from resim_python_client.api.experiences import get_experience, create_experience, list_experiences
from resim_python_client.api.experience_tags import add_experience_tag_to_experience
from resim_python_client.models import CreateExperienceInput

from resim_python_client.client import AuthenticatedClient
from resim_python_client.api.batches import get_batch
Expand Down Expand Up @@ -309,6 +312,60 @@ async def compute_batch_metrics(
.with_unit("m/s")
)

################################################################################
# SNIPPETING
#

experience_pages = await async_fetch_all_pages(
list_experiences.asyncio,
client=client,
project_id=project_id,
)
experiences = {e.name : e for page in experience_pages for e in page.experiences}


for job in jobs:
event_pages = await async_fetch_all_pages(
list_events_for_job.asyncio,
job_id=job.job_id,
client=client,
project_id=project_id,
batch_id=batch_id,
)
events = [event.timestamp for page in event_pages for event in page.events]
events.sort()

experience = await get_experience.asyncio(
project_id=project_id, client=client, experience_id=job.experience_id
)
basename = experience.name

if "?" in basename:
continue

for ii in range(len(events)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curse ye off by one error

ev = events[ii]

def diff_ts(ts: datetime, diff: int):
ns = int(ts.timestamp() * 1000000000)
print(ns)
return f"{ns // 1000000000 + diff}.{ns % 1000000000}"

newname = experience.name + f"?lb={diff_ts(ev, -5)}&ub={diff_ts(ev, 5)}"

if newname not in experiences:
experiences[newname] = await create_experience.asyncio(
project_id=project_id,
client=client,
body=CreateExperienceInput(
name=newname,
location=experience.location,
description=experience.description,
),
)

print(await add_experience_tag_to_experience.asyncio_detailed(project_id=project_id, experience_tag_id="0ef03700-eab7-4d4c-9ef6-cd8d1274151d", experience_id=experiences[newname].experience_id, client=client))

write_proto(metrics_writer, "/tmp/resim/outputs/metrics.binproto")


Expand Down
Loading