Content-Length: 394333 | pFad | http://github.com/mithi/hexapod-robot-simulator/pull/91/files

C2 Minor refactor for readability by mithi · Pull Request #91 · mithi/hexapod-robot-simulator · GitHub
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

Minor refactor for readability #91

Merged
merged 2 commits into from
Apr 28, 2020
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
14 changes: 7 additions & 7 deletions pages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
NAMES_LEG,
)

new_poses = deepcopy(BASE_POSE)
poses_mgs_header = f"""
NEW_POSES = deepcopy(BASE_POSE)
POSES_MSG_HEADER = f"""
+----------------+------------+------------+------------+
| leg name | coxia | femur | tibia |
+----------------+------------+------------+------------+"""
poses_msg_last_row = "\n+----------------+------------+------------+------------+"
POSES_MSG_LAST_ROW = "\n+----------------+------------+------------+------------+"


def make_pose(alpha, beta, gamma, poses=new_poses):
def make_pose(alpha, beta, gamma, poses=NEW_POSES):

for k, _ in poses.items():
poses[k] = {
Expand All @@ -27,7 +27,7 @@ def make_pose(alpha, beta, gamma, poses=new_poses):
"femur": beta,
"tibia": gamma,
}
return new_poses
return poses


def change_camera_view(figure, relayout_data):
Expand Down Expand Up @@ -63,7 +63,7 @@ def make_monospace(text):


def make_poses_message(poses):
message = poses_mgs_header
message = POSES_MSG_HEADER

for pose in poses.values():
name = pose["name"]
Expand All @@ -73,7 +73,7 @@ def make_poses_message(poses):
row = f"\n| {name:14} | {coxia:<+10.2f} | {femur:<+10.2f} | {tibia:<+10.2f} |"
message += row

return make_monospace(message + poses_msg_last_row)
return make_monospace(message + POSES_MSG_LAST_ROW)


def make_alert_message(alert):
Expand Down
31 changes: 14 additions & 17 deletions pages/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dash_html_components as html
from app import app
from settings import (
UI_CONTROLS_WIDTH,
UI_SIDEBAR_WIDTH,
UI_GRAPH_WIDTH,
UI_GRAPH_HEIGHT,
)
Expand Down Expand Up @@ -43,18 +43,15 @@ def update_hexapod_dimensions_shared(front, side, middle, coxia, femur, tibia):
# ......................


def make_standard_page_layout(graph_name, section_controls):
layout = html.Div(
[
html.Div(section_controls, style={"width": UI_CONTROLS_WIDTH}),
dcc.Graph(
id=graph_name,
figure=BASE_FIGURE,
style={"width": UI_GRAPH_WIDTH, "height": UI_GRAPH_HEIGHT},
),
],
style={"display": "flex"},
def make_standard_page_layout(graph_id, sidebar_sections):
sidebar = html.Div(sidebar_sections, style={"width": UI_SIDEBAR_WIDTH})
graph = dcc.Graph(
id=graph_id,
figure=BASE_FIGURE,
style={"width": UI_GRAPH_WIDTH, "height": UI_GRAPH_HEIGHT},
)

layout = html.Div([sidebar, graph], style={"display": "flex"})
return layout


Expand All @@ -64,19 +61,19 @@ def make_standard_page_layout(graph_name, section_controls):


def make_standard_page_sidebar(
message_section_id, parameters_hidden_section_id, parameter_widgets_section
message_section_id, params_hidden_section_id, params_widgets_section
):
parameters_hidden_section = html.Div(
id=parameters_hidden_section_id, style={"display": "none"}
params_hidden_section = html.Div(
id=params_hidden_section_id, style={"display": "none"}
)
message_section = html.Div(id=message_section_id)

return [
DIMENSIONS_WIDGETS_SECTION,
parameter_widgets_section,
params_widgets_section,
message_section,
DIMENSIONS_HIDDEN_SECTION,
parameters_hidden_section,
params_hidden_section,
]


Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@

UI_GRAPH_HEIGHT = "600px"
UI_GRAPH_WIDTH = "63%"
UI_CONTROLS_WIDTH = "37%"
UI_SIDEBAR_WIDTH = "37%"
5 changes: 3 additions & 2 deletions texts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
APP_TITLE = "Mithi's Hexapod Robot Simulator"

URL_KOFI = "https://ko-fi.com/minimithi"
URL_REPO = "https://github.com/mithi/hexapod-robot-simulator"

KINEMATICS_PAGE_PATH = "/kinematics"
IK_PAGE_PATH = "/inverse-kinematics"
PATTERNS_PAGE_PATH = "/leg-patterns"
ROOT_PATH = "/"

APP_TITLE = "Mithi's Hexapod Robot Simulator"

DIMENSIONS_WIDGETS_HEADER = "robot dimensions".upper()
PATTERNS_WIDGETS_HEADER = "leg patterns".upper()
IK_WIDGETS_HEADER = "inverse kinematics".upper()
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/mithi/hexapod-robot-simulator/pull/91/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy