// Auto-generated. Do not edit!

// (in-package detect_targets.msg)


"use strict";

const _serializer = _ros_msg_utils.Serialize;
const _arraySerializer = _serializer.Array;
const _deserializer = _ros_msg_utils.Deserialize;
const _arrayDeserializer = _deserializer.Array;
const _finder = _ros_msg_utils.Find;
const _getByteLength = _ros_msg_utils.getByteLength;

//-----------------------------------------------------------

class control {
  constructor(initObj={}) {
    if (initObj === null) {
      // initObj === null is a special case for deserialization where we don't initialize fields
      this.target = null;
      this.error = null;
      this.derror = null;
      this.cmd_vel = null;
    }
    else {
      if (initObj.hasOwnProperty('target')) {
        this.target = initObj.target
      }
      else {
        this.target = 0.0;
      }
      if (initObj.hasOwnProperty('error')) {
        this.error = initObj.error
      }
      else {
        this.error = 0.0;
      }
      if (initObj.hasOwnProperty('derror')) {
        this.derror = initObj.derror
      }
      else {
        this.derror = 0.0;
      }
      if (initObj.hasOwnProperty('cmd_vel')) {
        this.cmd_vel = initObj.cmd_vel
      }
      else {
        this.cmd_vel = 0.0;
      }
    }
  }

  static serialize(obj, buffer, bufferOffset) {
    // Serializes a message object of type control
    // Serialize message field [target]
    bufferOffset = _serializer.float64(obj.target, buffer, bufferOffset);
    // Serialize message field [error]
    bufferOffset = _serializer.float64(obj.error, buffer, bufferOffset);
    // Serialize message field [derror]
    bufferOffset = _serializer.float64(obj.derror, buffer, bufferOffset);
    // Serialize message field [cmd_vel]
    bufferOffset = _serializer.float64(obj.cmd_vel, buffer, bufferOffset);
    return bufferOffset;
  }

  static deserialize(buffer, bufferOffset=[0]) {
    //deserializes a message object of type control
    let len;
    let data = new control(null);
    // Deserialize message field [target]
    data.target = _deserializer.float64(buffer, bufferOffset);
    // Deserialize message field [error]
    data.error = _deserializer.float64(buffer, bufferOffset);
    // Deserialize message field [derror]
    data.derror = _deserializer.float64(buffer, bufferOffset);
    // Deserialize message field [cmd_vel]
    data.cmd_vel = _deserializer.float64(buffer, bufferOffset);
    return data;
  }

  static getMessageSize(object) {
    return 32;
  }

  static datatype() {
    // Returns string type for a message object
    return 'detect_targets/control';
  }

  static md5sum() {
    //Returns md5sum for a message object
    return '6f80b008c55c6a68dec8d378f0b74e50';
  }

  static messageDefinition() {
    // Returns full string definition for message
    return `
    float64 target
    float64 error
    float64 derror
    float64 cmd_vel
    `;
  }

  static Resolve(msg) {
    // deep-construct a valid message object instance of whatever was passed in
    if (typeof msg !== 'object' || msg === null) {
      msg = {};
    }
    const resolved = new control(null);
    if (msg.target !== undefined) {
      resolved.target = msg.target;
    }
    else {
      resolved.target = 0.0
    }

    if (msg.error !== undefined) {
      resolved.error = msg.error;
    }
    else {
      resolved.error = 0.0
    }

    if (msg.derror !== undefined) {
      resolved.derror = msg.derror;
    }
    else {
      resolved.derror = 0.0
    }

    if (msg.cmd_vel !== undefined) {
      resolved.cmd_vel = msg.cmd_vel;
    }
    else {
      resolved.cmd_vel = 0.0
    }

    return resolved;
    }
};

module.exports = control;
