Skip to content

Commit

Permalink
feat(models): add additional NAO elbow joint
Browse files Browse the repository at this point in the history
and its corresponding migration
  • Loading branch information
texhnolyze committed Jan 23, 2025
1 parent 269e41a commit 2ba9ce2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Add NAO elbow joint
Revision ID: 14ae0e795470
Revises: 3f1574e89695
Create Date: 2025-01-23 17:01:45.686722
"""

from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "14ae0e795470"
down_revision: Union[str, None] = "3f1574e89695"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("JointCommands") as batch_op:
batch_op.add_column(sa.Column("RElbowYaw", sa.Float(), nullable=False))
batch_op.create_check_constraint(
op.f("ck_JointCommands_RElbowYaw_value"), "RElbowYaw >= 0 AND RElbowYaw < 2 * pi()"
)

batch_op.add_column(sa.Column("LElbowYaw", sa.Float(), nullable=False))
batch_op.create_check_constraint(
op.f("ck_JointCommands_LElbowYaw_value"), "LElbowYaw >= 0 AND LElbowYaw < 2 * pi()"
)

with op.batch_alter_table("JointStates") as batch_op:
batch_op.add_column(sa.Column("RElbowYaw", sa.Float(), nullable=False))
batch_op.create_check_constraint(
op.f("ck_JointStates_LElbowYaw_value"), "LElbowYaw >= 0 AND LElbowYaw < 2 * pi()"
)

batch_op.add_column(sa.Column("LElbowYaw", sa.Float(), nullable=False))
batch_op.create_check_constraint(
op.f("ck_JointStates_RElbowYaw_value"), "RElbowYaw >= 0 AND RElbowYaw < 2 * pi()"
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("JointCommands") as batch_op:
batch_op.drop_constraint("ck_JointCommands_RElbowYaw_value")
batch_op.drop_column("RElbowYaw")

batch_op.drop_constraint("ck_JointCommands_LElbowYaw_value")
batch_op.drop_column("LElbowYaw")

with op.batch_alter_table("JointStates") as batch_op:
batch_op.drop_constraint("ck_JointStates_RElbowYaw_value")
batch_op.drop_column("RElbowYaw")

batch_op.drop_constraint("ck_JointStates_LElbowYaw_value")
batch_op.drop_column("LElbowYaw")
# ### end Alembic commands ###
8 changes: 8 additions & 0 deletions ddlitlab2024/dataset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class JointStates(Base):
r_shoulder_roll: Mapped[float] = mapped_column(Float, name="RShoulderRoll")
l_shoulder_roll: Mapped[float] = mapped_column(Float, name="LShoulderRoll")
r_elbow: Mapped[float] = mapped_column(Float, name="RElbow")
r_elbow_yaw: Mapped[float] = mapped_column(Float, name="RElbowYaw", default=0.0)
l_elbow: Mapped[float] = mapped_column(Float, name="LElbow")
l_elbow_yaw: Mapped[float] = mapped_column(Float, name="LElbowYaw", default=0.0)
r_hip_yaw: Mapped[float] = mapped_column(Float, name="RHipYaw")
l_hip_yaw: Mapped[float] = mapped_column(Float, name="LHipYaw")
r_hip_roll: Mapped[float] = mapped_column(Float, name="RHipRoll")
Expand All @@ -189,7 +191,9 @@ class JointStates(Base):
CheckConstraint("RShoulderRoll >= 0 AND RShoulderRoll < 2 * pi()", name="RShoulderRoll_value"),
CheckConstraint("LShoulderRoll >= 0 AND LShoulderRoll < 2 * pi()", name="LShoulderRoll_value"),
CheckConstraint("RElbow >= 0 AND RElbow < 2 * pi()", name="RElbow_value"),
CheckConstraint("RElbowYaw >= 0 AND RElbowYaw < 2 * pi()", name="RElbowYaw_value"),
CheckConstraint("LElbow >= 0 AND LElbow < 2 * pi()", name="LElbow_value"),
CheckConstraint("LElbowYaw >= 0 AND LElbowYaw < 2 * pi()", name="LElbowYaw_value"),
CheckConstraint("RHipYaw >= 0 AND RHipYaw < 2 * pi()", name="RHipYaw_value"),
CheckConstraint("LHipYaw >= 0 AND LHipYaw < 2 * pi()", name="LHipYaw_value"),
CheckConstraint("RHipRoll >= 0 AND RHipRoll < 2 * pi()", name="RHipRoll_value"),
Expand Down Expand Up @@ -220,7 +224,9 @@ class JointCommands(Base):
r_shoulder_roll: Mapped[float] = mapped_column(Float, name="RShoulderRoll")
l_shoulder_roll: Mapped[float] = mapped_column(Float, name="LShoulderRoll")
r_elbow: Mapped[float] = mapped_column(Float, name="RElbow")
r_elbow_yaw: Mapped[float] = mapped_column(Float, name="RElbowYaw", default=0.0)
l_elbow: Mapped[float] = mapped_column(Float, name="LElbow")
l_elbow_yaw: Mapped[float] = mapped_column(Float, name="LElbowYaw", default=0.0)
r_hip_yaw: Mapped[float] = mapped_column(Float, name="RHipYaw")
l_hip_yaw: Mapped[float] = mapped_column(Float, name="LHipYaw")
r_hip_roll: Mapped[float] = mapped_column(Float, name="RHipRoll")
Expand All @@ -245,7 +251,9 @@ class JointCommands(Base):
CheckConstraint("RShoulderRoll >= 0 AND RShoulderRoll < 2 * pi()", name="RShoulderRoll_value"),
CheckConstraint("LShoulderRoll >= 0 AND LShoulderRoll < 2 * pi()", name="LShoulderRoll_value"),
CheckConstraint("RElbow >= 0 AND RElbow < 2 * pi()", name="RElbow_value"),
CheckConstraint("RElbowYaw >= 0 AND RElbowYaw < 2 * pi()", name="RElbowYaw_value"),
CheckConstraint("LElbow >= 0 AND LElbow < 2 * pi()", name="LElbow_value"),
CheckConstraint("LElbowYaw >= 0 AND LElbowYaw < 2 * pi()", name="LElbowYaw_value"),
CheckConstraint("RHipYaw >= 0 AND RHipYaw < 2 * pi()", name="RHipYaw_value"),
CheckConstraint("LHipYaw >= 0 AND LHipYaw < 2 * pi()", name="LHipYaw_value"),
CheckConstraint("RHipRoll >= 0 AND RHipRoll < 2 * pi()", name="RHipRoll_value"),
Expand Down

0 comments on commit 2ba9ce2

Please sign in to comment.