Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rocolib
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
roco
rocolib
Commits
d54f962f
Commit
d54f962f
authored
4 years ago
by
mehtank
Browse files
Options
Downloads
Patches
Plain Diff
Command line interface for creating / testing components in rocolib using python -m rocolib
parent
b3248b45
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rocolib/__init__.py
+1
-1
1 addition, 1 deletion
rocolib/__init__.py
rocolib/__main__.py
+48
-0
48 additions, 0 deletions
rocolib/__main__.py
with
49 additions
and
1 deletion
rocolib/__init__.py
+
1
−
1
View file @
d54f962f
...
...
@@ -9,7 +9,7 @@ from os.path import realpath
from
os.path
import
relpath
__version__
=
"
0.2.
0
"
__version__
=
"
0.2.
1
"
__author__
=
'
UCLA LEMUR
'
__credits__
=
'
The Laboratory for Embedded Machines and Ubiquitous Robots
'
...
...
This diff is collapsed.
Click to expand it.
rocolib/__main__.py
0 → 100644
+
48
−
0
View file @
d54f962f
#!/bin/env python
import
logging
import
argparse
from
rocolib.library
import
getComponent
from
rocolib.api.composables.graph.Joint
import
FingerJoint
def
test
(
component
,
params
,
thickness
,
display
=
False
,
display3D
=
False
):
f
=
getComponent
(
component
)
if
params
is
not
None
:
for
p
in
params
:
f
.
setParameter
(
p
[
0
],
eval
(
p
[
1
]))
if
thickness
is
None
:
t
=
0
j
=
None
else
:
t
=
thickness
j
=
FingerJoint
(
thickness
=
t
)
f
.
makeOutput
(
"
output/
"
+
component
,
display
=
display
,
display3D
=
display3D
,
thickness
=
t
,
joint
=
j
)
if
__name__
==
'
__main__
'
:
LOG_LEVELS
=
[
"
DEBUG
"
,
"
INFO
"
,
"
WARNING
"
,
"
ERROR
"
,
"
CRITICAL
"
]
DEFAULT_LOG_LEVEL
=
"
WARNING
"
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
component
"
,
help
=
"
Name of the component you
'
d like to test
"
)
parser
.
add_argument
(
"
--verbose
"
,
"
-v
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=-
1
)
parser
.
add_argument
(
"
--quiet
"
,
"
-q
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=
1
)
parser
.
add_argument
(
"
-t
"
,
type
=
float
,
help
=
"
Thickness if you are making with wood
"
)
parser
.
add_argument
(
"
-d
"
,
action
=
'
store_true
'
,
help
=
"
Display 2D drawing
"
)
parser
.
add_argument
(
"
-D
"
,
action
=
'
store_true
'
,
help
=
"
Display 3D drawing
"
)
parser
.
add_argument
(
"
-P
"
,
nargs
=
2
,
action
=
'
append
'
,
metavar
=
(
"
NAME
"
,
"
VALUE
"
),
help
=
"
Set component parameter NAME to value VALUE
"
)
args
=
parser
.
parse_args
()
log_level
=
LOG_LEVELS
.
index
(
DEFAULT_LOG_LEVEL
)
# For each "-q" and "-v" flag, adjust the logging verbosity accordingly
# making sure to clamp off the value from 0 to 4, inclusive of both
for
adjustment
in
args
.
log_level
or
():
log_level
=
min
(
len
(
LOG_LEVELS
)
-
1
,
max
(
log_level
+
adjustment
,
0
))
log_level_name
=
LOG_LEVELS
[
log_level
]
logging
.
basicConfig
(
level
=
getattr
(
logging
,
log_level_name
))
test
(
args
.
component
,
args
.
P
,
thickness
=
args
.
t
,
display
=
args
.
d
,
display3D
=
args
.
D
)
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment