Skip to content

Commit d6de7a8

Browse files
committed
Prettify
1 parent 57e0f35 commit d6de7a8

File tree

7 files changed

+41
-56
lines changed

7 files changed

+41
-56
lines changed

src/factory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class UrdfWidgetFactory extends ABCWidgetFactory<
1313
UrdfWidget,
1414
DocumentModel
1515
> {
16-
1716
constructor(options: DocumentRegistry.IWidgetFactoryOptions) {
1817
super(options);
1918
}
@@ -27,4 +26,4 @@ export class UrdfWidgetFactory extends ABCWidgetFactory<
2726
content: new UrdfPanel(context)
2827
});
2928
}
30-
}
29+
}

src/icons.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
import { LabIcon } from '@jupyterlab/ui-components';
32

43
import urdf_logo from '/style/icons/urdf_logo.svg';
54

65
export const urdf_icon = new LabIcon({
76
name: 'urdf:icon/logo',
87
svgstr: urdf_logo
9-
});
8+
});

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const extension: JupyterFrontEndPlugin<void> = {
5353
restorer: ILayoutRestorer,
5454
browserFactory: IFileBrowserFactory,
5555
menu: IMainMenu,
56-
launcher: ILauncher,
56+
launcher: ILauncher
5757
) => {
5858
console.log('JupyterLab extension URDF is activated!');
5959
const { commands } = app;
@@ -101,7 +101,7 @@ const extension: JupyterFrontEndPlugin<void> = {
101101
iconClass: 'jp-URDFIcon',
102102
fileFormat: 'text',
103103
contentType: 'file',
104-
icon: urdf_icon,
104+
icon: urdf_icon
105105
});
106106

107107
// Add command for creating new urdf (file)

src/layout.ts

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import dat from 'dat.gui';
1010
// Modify URLs for the RobotModel:
1111
//https://github.com/RoboStack/amphion/blob/879045327e879d0bb6fe2c8eac54664de46ef675/src/core/urdf.ts#L22
1212
DefaultLoadingManager.setURLModifier(url => {
13-
console.debug("THREE MANAGER:", url);
13+
console.debug('THREE MANAGER:', url);
1414
return '/ros/pkgs' + url;
1515
});
1616

@@ -69,13 +69,12 @@ export class URDFLayout extends PanelLayout {
6969
}
7070

7171
setURDF(data: string): void {
72-
7372
// Load robot model
7473
if (this._robotModel !== null) {
7574
// Remove old robot model from visualization
7675
// Viewer -> Scene -> Group -> Robot Model
77-
this._robotModel.object.parent.remove( this._robotModel.object );
78-
};
76+
this._robotModel.object.parent.remove(this._robotModel.object);
77+
}
7978

8079
// https://github.com/RoboStack/amphion/blob/879045327e879d0bb6fe2c8eac54664de46ef675/src/core/urdf.ts#L46
8180
const ros = new ROSLIB.Ros();
@@ -84,16 +83,16 @@ export class URDFLayout extends PanelLayout {
8483
this._viewer.addVisualization(this._robotModel);
8584

8685
// Create controller panel
87-
this.setGUI();
86+
this.setGUI();
8887
}
8988

9089
/**
9190
* Create a GUI to set the joint angles / positions
9291
*/
9392
setGUI(): void {
94-
this._gui = new dat.GUI({
93+
this._gui = new dat.GUI({
9594
width: 310,
96-
autoPlace: false,
95+
autoPlace: false
9796
});
9897

9998
// Adjust position so that it's attached to viewer
@@ -108,16 +107,14 @@ export class URDFLayout extends PanelLayout {
108107

109108
// Create new folder for the joints
110109
this._gui.addFolder('Robot Joints').open();
111-
Object.keys(this._robotModel.urdfObject.joints).forEach(
112-
(jointName) => {
113-
this.createJointSlider(jointName);
114-
}
115-
);
110+
Object.keys(this._robotModel.urdfObject.joints).forEach(jointName => {
111+
this.createJointSlider(jointName);
112+
});
116113
}
117114

118-
/**
115+
/**
119116
* Set angle for revolute joints
120-
*
117+
*
121118
* @param jointName - The name of the joint to be set
122119
*/
123120
setJointAngle(jointName: string, newAngle: number): void {
@@ -126,52 +123,46 @@ export class URDFLayout extends PanelLayout {
126123

127124
/**
128125
* Creates a slider for each movable joint
129-
*
126+
*
130127
* @param jointName - Name of joint as string
131128
*/
132129
createJointSlider(jointName: string): void {
133130
// Retrieve joint
134-
const joint = this._robotModel.urdfObject.joints[ jointName ];
131+
const joint = this._robotModel.urdfObject.joints[jointName];
135132

136133
// Skip joints which should not be moved
137134
if (joint._jointType == 'fixed') {
138-
return
139-
};
135+
return;
136+
}
140137

141138
// Obtain joint limits
142139
let limitMin = joint.limit.lower;
143140
let limitMax = joint.limit.upper;
144141

145142
// If the limits are not defined, set defaults to +/- 180 degrees
146-
if (( limitMin == 0 ) && ( limitMax == 0 )) {
147-
limitMin = - Math.PI;
148-
limitMax = + Math.PI;
149-
};
143+
if (limitMin == 0 && limitMax == 0) {
144+
limitMin = -Math.PI;
145+
limitMax = +Math.PI;
146+
}
150147

151148
// Step increments for slider
152-
const stepSize = ( limitMax - limitMin ) / 20;
149+
const stepSize = (limitMax - limitMin) / 20;
153150

154151
// Initialize to the position given in URDF file
155152
const initValue = joint.jointValue;
156153

157154
// Object to be manipulated
158155
let jointObject = { [jointName]: initValue };
159-
156+
160157
// Add slider to GUI
161-
this._gui.__folders['Robot Joints'].add(
162-
jointObject,
163-
jointName,
164-
limitMin,
165-
limitMax,
166-
stepSize,
167-
).onChange(
168-
(newAngle: any) => this.setJointAngle(jointName, newAngle)
169-
);
158+
this._gui.__folders['Robot Joints']
159+
.add(jointObject, jointName, limitMin, limitMax, stepSize)
160+
.onChange((newAngle: any) => this.setJointAngle(jointName, newAngle));
170161
}
171162

172163
/**
173164
* Change the background color of the scene
174-
*
165+
*
175166
* @param bgColor - The new background color as RGB array
176167
*/
177168
setBGColor(bgColor: any): void {
@@ -184,18 +175,15 @@ export class URDFLayout extends PanelLayout {
184175
* Create color controller
185176
*/
186177
createColorControl(): void {
187-
const defaultColor = [ 240, 240, 240 ];
178+
const defaultColor = [240, 240, 240];
188179

189180
// Object to be manipulated
190181
let colorObject = { Background: defaultColor };
191182

192183
// Add controller to GUI
193-
this._gui.__folders['Scene'].addColor(
194-
colorObject,
195-
'Background',
196-
).onChange(
197-
(newColor: any) => this.setBGColor(newColor)
198-
);
184+
this._gui.__folders['Scene']
185+
.addColor(colorObject, 'Background')
186+
.onChange((newColor: any) => this.setBGColor(newColor));
199187
}
200188

201189
/**

src/svg.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
// The svg will be imported as a raw string
99

1010
declare module '*.svg' {
11-
const value: string;
12-
export default value;
13-
}
11+
const value: string;
12+
export default value;
13+
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare module 'amphion';
2-
declare module 'roslib';
2+
declare module 'roslib';

src/widget.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ export class UrdfPanel extends Panel {
4040
*/
4141
constructor(context: DocumentRegistry.IContext<DocumentModel>) {
4242
super({ layout: new URDFLayout() });
43-
43+
4444
this.addClass('jp-urdf-canvas'); // for css styling
4545
this._context = context;
4646

4747
this._context.ready.then(value => {
4848
(this.layout as URDFLayout).setURDF(this._context.model.toString());
49-
this._context.model.contentChanged.connect((sender, args)=>{
50-
console.log("Model changed.", args);
49+
this._context.model.contentChanged.connect((sender, args) => {
50+
console.log('Model changed.', args);
5151
(this.layout as URDFLayout).setURDF(this._context.model.toString());
5252
});
5353
});
@@ -85,6 +85,5 @@ export class UrdfPanel extends Panel {
8585
*
8686
* @param event - Event on the widget
8787
*/
88-
public handleEvent(event: MouseEvent): void {
89-
}
88+
public handleEvent(event: MouseEvent): void {}
9089
}

0 commit comments

Comments
 (0)