-
Notifications
You must be signed in to change notification settings - Fork 10
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
Calzim/only example cleanup #39
Conversation
fixed broken plots and naming conventions for all basic examples. Also fixed teacg repeat from arms examples. All examples should now run and plot data correctly.
mobile_io now has comments
fixed all but mobile control examples, mobile control only breaks after a pause and restart.
mobile device control is completely functional with no lock on rotation of the ee
removed dead code
created mobile_io_control example and fixed bugs in mobile_io
fixed up arm kit examples
fixed naming conventions and corrected impedence control setpoint
also added correct example log file
|
||
# Plot using some handy helper functions | ||
hebi.util.plot_logs(log, 'position', figure_spec=101) | ||
|
||
log = hebi.util.load_log('{}/{}'.format(folder, name)) | ||
hebi.util.plot_logs(log, 'velocity', figure_spec=102) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call plot_logs
with a string object too, so something like:
hebi.util.plot_logs('{}/{}'.format(folder, name), 'velocity', figure_spec=102)
but this is sufficient for now.
@@ -29,7 +29,7 @@ | |||
freq = freq_hz * 2.0 * pi # [rad / sec] | |||
amp = pi * 0.25 # [rad] (45 degrees) | |||
|
|||
duration = 10.0 # [sec] | |||
duration = 4 # [sec] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamtesch @CalZim Does anyone know why this changed to 4 seconds? It appears to be 10 seconds in the matlab example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure -- I think this might have just been a testing change. I'd prefer to keep it matching the MATLAB example for consistency.
@@ -29,7 +29,7 @@ | |||
freq = freq_hz * 2.0 * pi # [rad / sec] | |||
amp = 1.0 # [rad] (45 degrees) | |||
|
|||
duration = 10.0 # [sec] | |||
duration = 4 # [sec] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid spamming this PR with duplicate comments, see previous comment corresponding to 10->4
seconds in the examples... Not a big deal, just wondering why it was done
@@ -47,5 +48,30 @@ | |||
|
|||
# Stop logging. `log_file` contains the contents of the file | |||
log_file = group.stop_log() | |||
hebi.util.plot_logs(log_file, 'position', figure_spec=101) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bug in the Python API, which I believe has since been fixed, related to this (first plot_logs
would work, but second would not, since the log file had been iterated through)... If it's fixed, we can revert the changes on the RHS here back to what it was previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 this would be great to test and revert if possible :)
@@ -109,7 +111,13 @@ def execute_trajectory(group, model, trajectory, feedback): | |||
group.get_next_feedback(reuse_fbk=feedback) | |||
waypoints[:, 0] = feedback.position | |||
waypoints[:, 1] = joint_targets[:, 0] | |||
print("joint targets") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These print statements are extraneous and should be removed for the public facing examples.
current_button_state = [0, 0, 0, 0, 0, 0, 0, 0] | ||
current_slider_state = [0, 0, 0, 0, 0, 0, 0, 0] | ||
|
||
btn_states = ["", "", "", "", "", "", "", ""] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are class fields, not instance fields (i.e., they are static variables). This means that multiple instances of MobileIO
will refer to a single instance of these variables, which I assume is not the intention here.
Move these definitions into __init__
to make them instance variables
return (self.current_button_state, self.current_slider_state) | ||
|
||
# returns the change in button positions (currently breaks if called in same step as getState()) | ||
def getDiff(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, we have snake_case
naming convention for our Python stuff (that is what is generally used in Python)... I'm not really opposed to camelCase
(I prefer camel tbh), but it goes against what we generally use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as much as I dislike snake_case
, I agree we should keep things consistent. I have a feeling this current name was influenced by porting this from C++.
# send a buzz to the mobile device (only works on iphones) | ||
def sendVibrate(self): | ||
self.cmd.effort = 1 | ||
return self.grp.send_command_with_acknowledgement(self.cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamtesch , should we do send_command_with_ack
here, or just send_command
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...I would probably stick with send_command
, unless we are actually doing something with the feedback.
@CalZim , the biggest difference here is that under the covers, send_command_with_ack
sends a message and then waits for a response. This means that this call is blocking, and if the return packet is dropped will block until the timeout is reached.
sendVibrate
is something that is more likely to happen in a control loop as feedback, so the "fire and forget" style of send_command
is probably more appropriate.
For functions such as setSnap
which configure the interface as a "one time" action, these are much more appropriate to be done with a send_command_with_acknowledgement
and have wrapping code in the app to check for success.
sleep(2.0) | ||
|
||
family_name = "HEBI" | ||
module_name = "Cal's iPhone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to change this back to what other examples are using (for consistency)
orient = fbk[0].ar_orientation | ||
|
||
r = R.from_quat(orient) | ||
rot_mat = r.as_matrix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a function (util.math_utils.quat2rot
) to do this, and I'd prefer not to bring in a dependency like scipy
(I forget if it's a different package than numpy
or what...). However... it's not imported here (you need to add a directory to the PATH
for Python to find it), so this warrants a discussion on the best way to resolve this dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CalZim -- I agree we should use our existing library functions where possible.
@rLinks234 -- I assume you mean the import is for the scipy/numpy, or is that for ours?
Ah -- I see your comment elsewhere, @rLinks234 . Yeah, I'm not a huge fan of having to alter the path; it there any better way to handle this?
]) | ||
|
||
plt.clf() | ||
ax = plt.axes(projection="3d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume this is potentially an expensive call which should be done once (outside of the loop), as opposed to each iteration
print("state: " + str(state)) | ||
counter += 1 | ||
if counter % 100 == 0: | ||
print("counter: " + str(counter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamtesch , should we leave all/some of these print statements in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so -- I think the counter
was part of a debugging process? We should clean up the temporary/debug code where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so...
@@ -111,106 +116,117 @@ def get_ik(xyz_target, rot_target, ik_seed): | |||
# Start background logging | |||
if enable_logging: | |||
group.start_log(os.path.join(local_dir, 'logs'), mkdirs=True) | |||
phone_group.start_log(os.path.join(local_dir, 'logs'), mkdirs=True) | |||
#phone_group.start_log(os.path.join(local_dir, 'logs'), mkdirs=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not want to log mobile IO feedback? Just wondering. If we don't (as implied by this line being commented out), then we should delete this commented out line.
|
||
first_run = True | ||
|
||
print("check 2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming these check X
print statements were for debugging purposes... We should remove them before merging this in
# Send to robot | ||
group.send_command(cmd) | ||
#group.send_command(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be uncommented, right?
# Add the root folder of the repository to the search path for modules | ||
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) | ||
sys.path = [root_path] + sys.path | ||
# ------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the hack necessary to add in the util
package for stuff like the quat2rot
functions.
|
||
# Mobile Device Setup | ||
phone_family = 'HEBI' | ||
phone_name = "Cal's iPhone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to change this back
@@ -0,0 +1,320 @@ | |||
import hebi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is up with the ex_mobile_device_control_vX.py
scheme here? It sounds like these were iterations to get the example working... If this is the case, we need to delete all but the one we want to keep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great so far, but there are a few things which we need to change before we get this merged in. Thanks a lot for cleaning up my disastrous mess.
So far, these changes are pertinent to get this merged in:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some name changes to match convention, looks good overall!
family_name = "Test Family" | ||
module_names = ["J3_elbow", "J2_shoulder", "J1_base"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
family_name = "Test Family" | |
module_names = ["J3_elbow", "J2_shoulder", "J1_base"] | |
family_name = "Test Family" |
Is there a reason the actuators in this list are backwards of normal convention? Typically we would order this [base, shoulder, elbow]
|
||
family_name = "Test Family" | ||
family_name = "Test Family" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
|
||
family_name = "Test Family" | ||
family_name = "Test Family" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace
|
||
family_name = "Test Family" | ||
family_name = "Test Family" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace
|
||
lookup = hebi.Lookup() | ||
|
||
# Wait 2 seconds for the module list to populate | ||
sleep(2.0) | ||
|
||
family_name = "Test Family" | ||
family_name = "Test Family" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace
enable_effort_comp = True | ||
|
||
# Mobile Device Setup | ||
phone_family = 'HEBI' | ||
phone_name = 'Mobile IO' | ||
phone_name = "Cal's iPhone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set to default
arm_name = '6-DoF + gripper' | ||
arm_family = 'Arm' | ||
arm_name = '6-DoF' | ||
arm_family = 'Example Arm' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be "Arm"?
|
||
# Mobile device setup | ||
phone_family = 'HEBI' | ||
phone_name = "Cal's iPhone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixme
|
||
# Mobile device setup | ||
phone_family = 'HEBI' | ||
phone_name = "Phone Name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobileIO
print_and_cr("When in playback mode, 'b6' resumes training, and 'b1' quits.") | ||
|
||
|
||
m = mbio.MobileIO("HEBI", "Phone Name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobileIO
Also, do we want to have logfiles included in the examples repo? It doesn't bother me either way, but I'm not sure what they represent since their names are timestamps. Maybe rename them if they are for specific examples? |
t = 0 | ||
|
||
#t = 0 | ||
print("check 1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More debug printout and commented variables here and below...
Unless the logfiles are part of an example in loading logfiles, we shouldn't have these in general |
No description provided.