Skip to content

Allow keyboard events to move sliders and click button controls. - #129

Merged
RussTedrake merged 1 commit into
meshcat-dev:masterfrom
RussTedrake:keyboard_controls
Sep 18, 2022
Merged

RussTedrake merged 1 commit into
meshcat-dev:masterfrom
RussTedrake:keyboard_controls

Conversation

@RussTedrake

Copy link
Copy Markdown
Collaborator

My goal is to enable keyboard teleoperation through meshcat, even when I'm running it the Deepnote cloud service (which doesn't fully support ipywidgets). This seemed like a particularly clean way to accomplish that; I've already been using sliders and buttons for teleop successfully in my course notebooks. This will make it much more ergonomic!

Actually the immediate motivation for coding it this weekend actually came from trying to convince a FIRST robotics team to use simulation. ;-)

@RussTedrake
RussTedrake requested a review from rdeits September 17, 2022 17:49
RussTedrake added a commit to RussTedrake/drake that referenced this pull request Sep 17, 2022
Depends on meshcat-dev/meshcat#129.

This will enable, for instance, keyboard teleop through Meshcat. It
will make the Deepnote teleop demos much more ergonomic.

@rdeits rdeits left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, and good luck with the FIRST demo!

Comment thread src/index.js Outdated
// The default layout for dat.GUI buttons is broken, with the button name artificially truncated at the same width that slider names are truncated. We fix that here.
this.gui_controllers[name].domElement.parentElement.querySelector('.property-name').style.width="100%";
if (keycode1 != undefined) {
let keydown_callback = {name: name, callback: eval(callback)};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're now evaling the callback twice on this code path and once above. Can you centralize that to remove the duplicate call (and in case we someday want to do something other that naively eval)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/index.js
} else {
this.keydown_callbacks[keycode2] = [keydown_callback];
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two blocks here are identical except for the sign of the step. Make this a function instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

My goal is to enable keyboard teleoperation through meshcat, even when
I'm running it the Deepnote cloud service (which doesn't fully support
ipywidgets).  This seemed like a particularly clean way to accomplish
that; I've already been using sliders and buttons for teleop
successfully in my course notebooks. This will make it much more
ergonomic!

Actually the immediate motivation for coding it this weekend actually
came from trying to convince a FIRST robotics team to use simulation.
;-)

@rdeits rdeits left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants