@@ -10,7 +10,7 @@ import dat from 'dat.gui';
10
10
// Modify URLs for the RobotModel:
11
11
//https://github.com/RoboStack/amphion/blob/879045327e879d0bb6fe2c8eac54664de46ef675/src/core/urdf.ts#L22
12
12
DefaultLoadingManager . setURLModifier ( url => {
13
- console . debug ( " THREE MANAGER:" , url ) ;
13
+ console . debug ( ' THREE MANAGER:' , url ) ;
14
14
return '/ros/pkgs' + url ;
15
15
} ) ;
16
16
@@ -69,13 +69,12 @@ export class URDFLayout extends PanelLayout {
69
69
}
70
70
71
71
setURDF ( data : string ) : void {
72
-
73
72
// Load robot model
74
73
if ( this . _robotModel !== null ) {
75
74
// Remove old robot model from visualization
76
75
// 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
+ }
79
78
80
79
// https://github.com/RoboStack/amphion/blob/879045327e879d0bb6fe2c8eac54664de46ef675/src/core/urdf.ts#L46
81
80
const ros = new ROSLIB . Ros ( ) ;
@@ -84,16 +83,16 @@ export class URDFLayout extends PanelLayout {
84
83
this . _viewer . addVisualization ( this . _robotModel ) ;
85
84
86
85
// Create controller panel
87
- this . setGUI ( ) ;
86
+ this . setGUI ( ) ;
88
87
}
89
88
90
89
/**
91
90
* Create a GUI to set the joint angles / positions
92
91
*/
93
92
setGUI ( ) : void {
94
- this . _gui = new dat . GUI ( {
93
+ this . _gui = new dat . GUI ( {
95
94
width : 310 ,
96
- autoPlace : false ,
95
+ autoPlace : false
97
96
} ) ;
98
97
99
98
// Adjust position so that it's attached to viewer
@@ -108,16 +107,14 @@ export class URDFLayout extends PanelLayout {
108
107
109
108
// Create new folder for the joints
110
109
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
+ } ) ;
116
113
}
117
114
118
- /**
115
+ /**
119
116
* Set angle for revolute joints
120
- *
117
+ *
121
118
* @param jointName - The name of the joint to be set
122
119
*/
123
120
setJointAngle ( jointName : string , newAngle : number ) : void {
@@ -126,52 +123,46 @@ export class URDFLayout extends PanelLayout {
126
123
127
124
/**
128
125
* Creates a slider for each movable joint
129
- *
126
+ *
130
127
* @param jointName - Name of joint as string
131
128
*/
132
129
createJointSlider ( jointName : string ) : void {
133
130
// Retrieve joint
134
- const joint = this . _robotModel . urdfObject . joints [ jointName ] ;
131
+ const joint = this . _robotModel . urdfObject . joints [ jointName ] ;
135
132
136
133
// Skip joints which should not be moved
137
134
if ( joint . _jointType == 'fixed' ) {
138
- return
139
- } ;
135
+ return ;
136
+ }
140
137
141
138
// Obtain joint limits
142
139
let limitMin = joint . limit . lower ;
143
140
let limitMax = joint . limit . upper ;
144
141
145
142
// 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
+ }
150
147
151
148
// Step increments for slider
152
- const stepSize = ( limitMax - limitMin ) / 20 ;
149
+ const stepSize = ( limitMax - limitMin ) / 20 ;
153
150
154
151
// Initialize to the position given in URDF file
155
152
const initValue = joint . jointValue ;
156
153
157
154
// Object to be manipulated
158
155
let jointObject = { [ jointName ] : initValue } ;
159
-
156
+
160
157
// 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 ) ) ;
170
161
}
171
162
172
163
/**
173
164
* Change the background color of the scene
174
- *
165
+ *
175
166
* @param bgColor - The new background color as RGB array
176
167
*/
177
168
setBGColor ( bgColor : any ) : void {
@@ -184,18 +175,15 @@ export class URDFLayout extends PanelLayout {
184
175
* Create color controller
185
176
*/
186
177
createColorControl ( ) : void {
187
- const defaultColor = [ 240 , 240 , 240 ] ;
178
+ const defaultColor = [ 240 , 240 , 240 ] ;
188
179
189
180
// Object to be manipulated
190
181
let colorObject = { Background : defaultColor } ;
191
182
192
183
// 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 ) ) ;
199
187
}
200
188
201
189
/**
0 commit comments