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

fix(arcor2_arserver): ap parent checks #871

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
4 changes: 2 additions & 2 deletions build-support/install_ur_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

apt-get install -y -q --no-install-recommends \
ros-jazzy-ros-base=0.11.0-1noble.20240922.110418 \
ros-jazzy-ur=2.4.10-1noble.20240922.120253 \
ros-jazzy-moveit-py=2.10.0-1noble.20240922.114626
ros-jazzy-ur=2.4.12-1noble.20241015.122847 \
ros-jazzy-moveit-py=2.10.0-1noble.20241008.001636
2 changes: 1 addition & 1 deletion compose-files/fit-demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
fit-demo-arserver:
image: arcor2/arcor2_arserver:1.3.0
image: arcor2/arcor2_arserver:1.3.1
container_name: fit-demo-arserver
depends_on:
fit-demo-project:
Expand Down
2 changes: 1 addition & 1 deletion compose-files/ur-demo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
memlock: 8428281856
# network_mode: host
ur-demo-arserver:
image: arcor2/arcor2_arserver:1.3.0
image: arcor2/arcor2_arserver:1.3.1
container_name: ur-demo-arserver
depends_on:
ur-demo-project:
Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_arserver/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shell_source(name="start.sh", source="start.sh")

docker_image(
name="arcor2_arserver", repository="arcor2/arcor2_arserver", dependencies=[":start.sh"], image_tags=["1.3.0"]
name="arcor2_arserver", repository="arcor2/arcor2_arserver", dependencies=[":start.sh"], image_tags=["1.3.1"]
)
6 changes: 3 additions & 3 deletions src/docker/arcor2_arserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM python:3.11.10-bookworm as deps
COPY src.python.arcor2_arserver.scripts/arserver.pex /binary.pex
RUN PEX_TOOLS=1 PYTHONOPTIMIZE=1 /usr/local/bin/python /binary.pex venv --scope=deps --compile /bin/app
RUN PEX_TOOLS=1 /usr/local/bin/python /binary.pex venv --scope=deps --compile /bin/app

FROM python:3.11.10-bookworm as srcs
COPY src.python.arcor2_arserver.scripts/arserver.pex /binary.pex
RUN PEX_TOOLS=1 PYTHONOPTIMIZE=1 /usr/local/bin/python /binary.pex venv --scope=srcs --compile /bin/app
RUN PEX_TOOLS=1 /usr/local/bin/python /binary.pex venv --scope=srcs --compile /bin/app

FROM python:3.11.10-bookworm

RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_arserver/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

mkdir -p "${ARCOR2_AREDITOR_LOGS_FOLDER:-/root/logs}"
python3 -m uploadserver --directory "${ARCOR2_AREDITOR_LOGS_FOLDER:-/root/logs}" 6799 &
/bin/app/pex
PYTHONOPTIMIZE=1 /bin/app/pex
2 changes: 1 addition & 1 deletion src/docker/arcor2_build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM python:3.11.10-bookworm

# curl is for healthcheck
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 curl=7.88.1-10+deb12u5 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 curl=7.88.1-10+deb12u5 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_calibration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM python:3.11.10-bookworm
# libgomp1 and libusb-1.0-0 are because of Open3D
# curl is for healthcheck
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_dobot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM python:3.11.10-bookworm

# curl is for healthcheck
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_execution/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN PEX_TOOLS=1 PYTHONOPTIMIZE=1 /usr/local/bin/python /binary.pex venv --scope=
FROM python:3.11.10-bookworm

RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion src/docker/arcor2_scene/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM python:3.11.10-bookworm
# libgomp1 and libusb-1.0-0 are because of Open3D
# curl is for healthcheck
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u2 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get install -y -q --no-install-recommends libgl1-mesa-glx=22.3.6-1+deb12u1 libglib2.0-0=2.74.6-2+deb12u3 libgomp1=12.2.0-14 libusb-1.0-0=2:1.0.26-1 curl=7.88.1-10+deb12u5 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 2 additions & 0 deletions src/python/arcor2/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ def remove_joints(self, joints_id: str) -> cmn.ProjectRobotJoints:
def upsert_action_point(
self, ap_id: str, name: str, position: cmn.Position, parent: None | str = None
) -> cmn.BareActionPoint:
assert parent != ""

try:
ap = self.bare_action_point(ap_id)
ap.name = name
Expand Down
6 changes: 6 additions & 0 deletions src/python/arcor2_arserver/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [1.3.1] - 2024-10-23

### Fixed

- Handling of useless changes in `UpdateActionPointParent`.

## [1.3.0] - 2024-09-12

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/python/arcor2_arserver/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1
10 changes: 9 additions & 1 deletion src/python/arcor2_arserver/rpc/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ async def update_action_point_parent_cb(req: srpc.p.UpdateActionPointParent.Requ
ap = proj.bare_action_point(req.args.action_point_id)

# some super basic checks (not involving other objects) are performed before locking anything
if req.args.new_parent_id == ap.parent:
if req.args.new_parent_id == ("" if ap.parent is None else ap.parent):
logger.warn(f"Attempted useless update of parent from {ap.parent} to {req.args.new_parent_id} on AP {ap.name}.")
return None

if req.args.new_parent_id == ap.id:
Expand All @@ -473,10 +474,12 @@ async def update_action_point_parent_cb(req: srpc.p.UpdateActionPointParent.Requ
if not ap.parent and req.args.new_parent_id:
# AP position and all orientations will become relative to the parent
updated_aps = tr.make_global_ap_relative(scene, proj, ap, req.args.new_parent_id)
assert ap.parent == req.args.new_parent_id

elif ap.parent and not req.args.new_parent_id:
# AP position and all orientations will become absolute
updated_aps = tr.make_relative_ap_global(scene, proj, ap)
assert ap.parent is None
else:
assert ap.parent
# AP position and all orientations will become relative to another parent
Expand Down Expand Up @@ -867,6 +870,11 @@ async def add_action_point_cb(req: srpc.p.AddActionPoint.Request, ui: WsClient)
scene = glob.LOCK.scene_or_exception()
proj = glob.LOCK.project_or_exception()

# TODO workaround for issue with parent
# best solution would be probably to make it non-optional everywhere
if req.args.parent == "":
req.args.parent = None

async with ctx_write_lock(glob.LOCK.SpecialValues.PROJECT, glob.USERS.user_name(ui)):
hlp.is_valid_identifier(req.args.name)
unique_name(req.args.name, proj.action_points_names)
Expand Down
42 changes: 42 additions & 0 deletions src/python/arcor2_arserver/tests/test_project_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,48 @@ def test_project_ap_rpcs(start_processes: None, ars: ARServer) -> None:
child_ap_evt = event(ars, events.p.ActionPointChanged)
assert child_ap_evt.data.parent == parent_ap_evt.data.id

assert ars.call_rpc(
rpc.p.UpdateActionPointParent.Request(
get_id(), rpc.p.UpdateActionPointParent.Request.Args(child_ap_evt.data.id, parent_ap_evt.data.id)
),
rpc.p.UpdateActionPointParent.Response,
).result

lock_object(ars, child_ap_evt.data.id)

assert ars.call_rpc(
rpc.p.UpdateActionPointParent.Request(
get_id(), rpc.p.UpdateActionPointParent.Request.Args(child_ap_evt.data.id, "")
),
rpc.p.UpdateActionPointParent.Response,
).result

update_ap_parent_evt = event(ars, events.p.ActionPointChanged)
assert update_ap_parent_evt.data.parent is None

event(ars, events.lk.ObjectsUnlocked)

assert ars.call_rpc(
rpc.p.UpdateActionPointParent.Request(
get_id(), rpc.p.UpdateActionPointParent.Request.Args(child_ap_evt.data.id, "")
),
rpc.p.UpdateActionPointParent.Response,
).result

lock_object(ars, child_ap_evt.data.id)

assert ars.call_rpc(
rpc.p.UpdateActionPointParent.Request(
get_id(), rpc.p.UpdateActionPointParent.Request.Args(child_ap_evt.data.id, parent_ap_evt.data.id)
),
rpc.p.UpdateActionPointParent.Response,
).result

update_ap_parent_evt = event(ars, events.p.ActionPointChanged)
assert update_ap_parent_evt.data.parent == parent_ap_evt.data.id

event(ars, events.lk.ObjectsUnlocked)

lock_object(ars, child_ap_evt.data.id)

assert ars.call_rpc(
Expand Down
Loading