Skip to content

Commit

Permalink
less overzealous removal of options || {}
Browse files Browse the repository at this point in the history
  • Loading branch information
EzraBrooks committed Nov 17, 2023
1 parent 84e3c16 commit f74d843
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/actionlib/ActionClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ActionClient extends EventEmitter2 {
constructor(options) {
super();
var that = this;
options = options || {};
this.ros = options.ros;
this.serverName = options.serverName;
this.actionName = options.actionName;
Expand Down
1 change: 0 additions & 1 deletion src/actionlib/ActionListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ActionListener extends EventEmitter2 {
constructor(options) {
super();
var that = this;
options = options || {};
this.ros = options.ros;
this.serverName = options.serverName;
this.actionName = options.actionName;
Expand Down
1 change: 0 additions & 1 deletion src/actionlib/SimpleActionServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class SimpleActionServer extends EventEmitter2 {
constructor(options) {
super();
var that = this;
options = options || {};
this.ros = options.ros;
this.serverName = options.serverName;
this.actionName = options.actionName;
Expand Down
13 changes: 6 additions & 7 deletions src/core/Param.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Param {
* @param {string} options.name - The param name, like max_vel_x.
*/
constructor(options) {
options = options || {};
this.ros = options.ros;
this.name = options.name;
}
Expand All @@ -33,8 +32,8 @@ class Param {
get(callback) {
var paramClient = new Service({
ros: this.ros,
name: '/rosapi/get_param',
serviceType: 'rosapi/GetParam',
name: "/rosapi/get_param",
serviceType: "rosapi/GetParam",
});

var request = new ServiceRequest({
Expand Down Expand Up @@ -63,8 +62,8 @@ class Param {
set(value, callback) {
var paramClient = new Service({
ros: this.ros,
name: '/rosapi/set_param',
serviceType: 'rosapi/SetParam',
name: "/rosapi/set_param",
serviceType: "rosapi/SetParam",
});

var request = new ServiceRequest({
Expand All @@ -82,8 +81,8 @@ class Param {
delete(callback) {
var paramClient = new Service({
ros: this.ros,
name: '/rosapi/delete_param',
serviceType: 'rosapi/DeleteParam',
name: "/rosapi/delete_param",
serviceType: "rosapi/DeleteParam",
});

var request = new ServiceRequest({
Expand Down
1 change: 0 additions & 1 deletion src/core/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Service extends EventEmitter2 {
*/
constructor(options) {
super();
options = options || {};
this.ros = options.ros;
this.name = options.name;
this.serviceType = options.serviceType;
Expand Down
1 change: 0 additions & 1 deletion src/core/Topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Topic extends EventEmitter2 {
*/
constructor(options) {
super();
options = options || {};
this.waitForReconnect = false;
/** @type {import('eventemitter2').ListenerFn|undefined} */
this.reconnectFunc = undefined;
Expand Down
3 changes: 1 addition & 2 deletions src/math/Transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class Transform {
* @param {Object} options
* @param {Vector3} options.translation - The ROSLIB.Vector3 describing the translation.
* @param {Quaternion} options.rotation - The ROSLIB.Quaternion describing the rotation.
*/
*/
constructor(options) {
options = options || {};
// Copy the values into this object if they exist
this.translation = new Vector3(options.translation);
this.rotation = new Quaternion(options.rotation);
Expand Down
1 change: 0 additions & 1 deletion src/tf/TFClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class TFClient extends EventEmitter2 {
*/
constructor(options) {
super();
options = options || {};
/** @type {Goal|undefined} */
this.currentGoal = undefined;
/** @type {Topic|undefined} */
Expand Down
15 changes: 7 additions & 8 deletions src/urdf/UrdfModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class UrdfModel {
* @param {string} options.string - The XML element to parse as a string.
*/
constructor(options) {
options = options || {};
var xmlDoc = options.xml;
var string = options.string;
this.materials = {};
Expand All @@ -33,22 +32,22 @@ class UrdfModel {
if (string) {
// Parse the string
var parser = new DOMParser();
xmlDoc = parser.parseFromString(string, 'text/xml').documentElement;
xmlDoc = parser.parseFromString(string, "text/xml").documentElement;
}

// Initialize the model with the given XML node.
// Get the robot tag
var robotXml = xmlDoc;

// Get the robot name
this.name = robotXml.getAttribute('name');
this.name = robotXml.getAttribute("name");

// Parse all the visual elements we need
for (var nodes = robotXml.childNodes, i = 0; i < nodes.length; i++) {
/** @type {Element} */
// @ts-expect-error -- unknown why this doesn't work properly.
var node = nodes[i];
if (node.tagName === 'material') {
if (node.tagName === "material") {
var material = new UrdfMaterial({
xml: node,
});
Expand All @@ -57,18 +56,18 @@ class UrdfModel {
if (this.materials[material.name].isLink()) {
this.materials[material.name].assign(material);
} else {
console.warn('Material ' + material.name + 'is not unique.');
console.warn("Material " + material.name + "is not unique.");
}
} else {
this.materials[material.name] = material;
}
} else if (node.tagName === 'link') {
} else if (node.tagName === "link") {
var link = new UrdfLink({
xml: node,
});
// Make sure this is unique
if (this.links[link.name] !== void 0) {
console.warn('Link ' + link.name + ' is not unique.');
console.warn("Link " + link.name + " is not unique.");
} else {
// Check for a material
for (var j = 0; j < link.visuals.length; j++) {
Expand All @@ -85,7 +84,7 @@ class UrdfModel {
// Add the link
this.links[link.name] = link;
}
} else if (node.tagName === 'joint') {
} else if (node.tagName === "joint") {
var joint = new UrdfJoint({
xml: node,
});
Expand Down

0 comments on commit f74d843

Please sign in to comment.