// generated from rosidl_generator_c/resource/idl__functions.c.em
// with input from virtual_robot_prococol:action/TargetPosition.idl
// generated code does not contain a copyright notice
#include "virtual_robot_prococol/action/detail/target_position__functions.h"

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include "rcutils/allocator.h"


bool
virtual_robot_prococol__action__TargetPosition_Goal__init(virtual_robot_prococol__action__TargetPosition_Goal * msg)
{
  if (!msg) {
    return false;
  }
  // target_x
  // target_y
  // target_speed
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Goal__fini(virtual_robot_prococol__action__TargetPosition_Goal * msg)
{
  if (!msg) {
    return;
  }
  // target_x
  // target_y
  // target_speed
}

bool
virtual_robot_prococol__action__TargetPosition_Goal__are_equal(const virtual_robot_prococol__action__TargetPosition_Goal * lhs, const virtual_robot_prococol__action__TargetPosition_Goal * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // target_x
  if (lhs->target_x != rhs->target_x) {
    return false;
  }
  // target_y
  if (lhs->target_y != rhs->target_y) {
    return false;
  }
  // target_speed
  if (lhs->target_speed != rhs->target_speed) {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Goal__copy(
  const virtual_robot_prococol__action__TargetPosition_Goal * input,
  virtual_robot_prococol__action__TargetPosition_Goal * output)
{
  if (!input || !output) {
    return false;
  }
  // target_x
  output->target_x = input->target_x;
  // target_y
  output->target_y = input->target_y;
  // target_speed
  output->target_speed = input->target_speed;
  return true;
}

virtual_robot_prococol__action__TargetPosition_Goal *
virtual_robot_prococol__action__TargetPosition_Goal__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Goal * msg = (virtual_robot_prococol__action__TargetPosition_Goal *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Goal), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_Goal));
  bool success = virtual_robot_prococol__action__TargetPosition_Goal__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_Goal__destroy(virtual_robot_prococol__action__TargetPosition_Goal * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_Goal__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__init(virtual_robot_prococol__action__TargetPosition_Goal__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Goal * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_Goal *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_Goal), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_Goal__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_Goal__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__fini(virtual_robot_prococol__action__TargetPosition_Goal__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_Goal__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_Goal__Sequence *
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Goal__Sequence * array = (virtual_robot_prococol__action__TargetPosition_Goal__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Goal__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_Goal__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_Goal__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_Goal__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_Goal__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_Goal__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Goal__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Goal__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_Goal__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_Goal__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_Goal);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_Goal * data =
      (virtual_robot_prococol__action__TargetPosition_Goal *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_Goal__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_Goal__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Goal__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `msg`
#include "rosidl_runtime_c/string_functions.h"

bool
virtual_robot_prococol__action__TargetPosition_Result__init(virtual_robot_prococol__action__TargetPosition_Result * msg)
{
  if (!msg) {
    return false;
  }
  // success
  // msg
  if (!rosidl_runtime_c__String__init(&msg->msg)) {
    virtual_robot_prococol__action__TargetPosition_Result__fini(msg);
    return false;
  }
  // status
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Result__fini(virtual_robot_prococol__action__TargetPosition_Result * msg)
{
  if (!msg) {
    return;
  }
  // success
  // msg
  rosidl_runtime_c__String__fini(&msg->msg);
  // status
}

bool
virtual_robot_prococol__action__TargetPosition_Result__are_equal(const virtual_robot_prococol__action__TargetPosition_Result * lhs, const virtual_robot_prococol__action__TargetPosition_Result * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // success
  if (lhs->success != rhs->success) {
    return false;
  }
  // msg
  if (!rosidl_runtime_c__String__are_equal(
      &(lhs->msg), &(rhs->msg)))
  {
    return false;
  }
  // status
  if (lhs->status != rhs->status) {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Result__copy(
  const virtual_robot_prococol__action__TargetPosition_Result * input,
  virtual_robot_prococol__action__TargetPosition_Result * output)
{
  if (!input || !output) {
    return false;
  }
  // success
  output->success = input->success;
  // msg
  if (!rosidl_runtime_c__String__copy(
      &(input->msg), &(output->msg)))
  {
    return false;
  }
  // status
  output->status = input->status;
  return true;
}

virtual_robot_prococol__action__TargetPosition_Result *
virtual_robot_prococol__action__TargetPosition_Result__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Result * msg = (virtual_robot_prococol__action__TargetPosition_Result *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Result), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_Result));
  bool success = virtual_robot_prococol__action__TargetPosition_Result__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_Result__destroy(virtual_robot_prococol__action__TargetPosition_Result * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_Result__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_Result__Sequence__init(virtual_robot_prococol__action__TargetPosition_Result__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Result * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_Result *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_Result), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_Result__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_Result__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Result__Sequence__fini(virtual_robot_prococol__action__TargetPosition_Result__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_Result__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_Result__Sequence *
virtual_robot_prococol__action__TargetPosition_Result__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Result__Sequence * array = (virtual_robot_prococol__action__TargetPosition_Result__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Result__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_Result__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_Result__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_Result__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_Result__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_Result__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_Result__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_Result__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Result__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Result__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_Result__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_Result__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_Result);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_Result * data =
      (virtual_robot_prococol__action__TargetPosition_Result *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_Result__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_Result__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Result__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


bool
virtual_robot_prococol__action__TargetPosition_Feedback__init(virtual_robot_prococol__action__TargetPosition_Feedback * msg)
{
  if (!msg) {
    return false;
  }
  // progress
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Feedback__fini(virtual_robot_prococol__action__TargetPosition_Feedback * msg)
{
  if (!msg) {
    return;
  }
  // progress
}

bool
virtual_robot_prococol__action__TargetPosition_Feedback__are_equal(const virtual_robot_prococol__action__TargetPosition_Feedback * lhs, const virtual_robot_prococol__action__TargetPosition_Feedback * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // progress
  if (lhs->progress != rhs->progress) {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Feedback__copy(
  const virtual_robot_prococol__action__TargetPosition_Feedback * input,
  virtual_robot_prococol__action__TargetPosition_Feedback * output)
{
  if (!input || !output) {
    return false;
  }
  // progress
  output->progress = input->progress;
  return true;
}

virtual_robot_prococol__action__TargetPosition_Feedback *
virtual_robot_prococol__action__TargetPosition_Feedback__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Feedback * msg = (virtual_robot_prococol__action__TargetPosition_Feedback *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Feedback), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_Feedback));
  bool success = virtual_robot_prococol__action__TargetPosition_Feedback__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_Feedback__destroy(virtual_robot_prococol__action__TargetPosition_Feedback * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_Feedback__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__init(virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Feedback * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_Feedback *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_Feedback), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_Feedback__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_Feedback__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__fini(virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_Feedback__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_Feedback__Sequence *
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * array = (virtual_robot_prococol__action__TargetPosition_Feedback__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_Feedback__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Feedback__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_Feedback__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_Feedback__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_Feedback);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_Feedback * data =
      (virtual_robot_prococol__action__TargetPosition_Feedback *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_Feedback__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_Feedback__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_Feedback__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `goal_id`
#include "unique_identifier_msgs/msg/detail/uuid__functions.h"
// Member `goal`
// already included above
// #include "virtual_robot_prococol/action/detail/target_position__functions.h"

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__init(virtual_robot_prococol__action__TargetPosition_SendGoal_Request * msg)
{
  if (!msg) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__init(&msg->goal_id)) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(msg);
    return false;
  }
  // goal
  if (!virtual_robot_prococol__action__TargetPosition_Goal__init(&msg->goal)) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(msg);
    return false;
  }
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(virtual_robot_prococol__action__TargetPosition_SendGoal_Request * msg)
{
  if (!msg) {
    return;
  }
  // goal_id
  unique_identifier_msgs__msg__UUID__fini(&msg->goal_id);
  // goal
  virtual_robot_prococol__action__TargetPosition_Goal__fini(&msg->goal);
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__are_equal(const virtual_robot_prococol__action__TargetPosition_SendGoal_Request * lhs, const virtual_robot_prococol__action__TargetPosition_SendGoal_Request * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__are_equal(
      &(lhs->goal_id), &(rhs->goal_id)))
  {
    return false;
  }
  // goal
  if (!virtual_robot_prococol__action__TargetPosition_Goal__are_equal(
      &(lhs->goal), &(rhs->goal)))
  {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__copy(
  const virtual_robot_prococol__action__TargetPosition_SendGoal_Request * input,
  virtual_robot_prococol__action__TargetPosition_SendGoal_Request * output)
{
  if (!input || !output) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__copy(
      &(input->goal_id), &(output->goal_id)))
  {
    return false;
  }
  // goal
  if (!virtual_robot_prococol__action__TargetPosition_Goal__copy(
      &(input->goal), &(output->goal)))
  {
    return false;
  }
  return true;
}

virtual_robot_prococol__action__TargetPosition_SendGoal_Request *
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Request * msg = (virtual_robot_prococol__action__TargetPosition_SendGoal_Request *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Request), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Request));
  bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Request__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__destroy(virtual_robot_prococol__action__TargetPosition_SendGoal_Request * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__init(virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Request * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_SendGoal_Request *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Request), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Request__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__fini(virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence *
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * array = (virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Request__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_SendGoal_Request__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Request);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_SendGoal_Request * data =
      (virtual_robot_prococol__action__TargetPosition_SendGoal_Request *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Request__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_SendGoal_Request__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Request__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `stamp`
#include "builtin_interfaces/msg/detail/time__functions.h"

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__init(virtual_robot_prococol__action__TargetPosition_SendGoal_Response * msg)
{
  if (!msg) {
    return false;
  }
  // accepted
  // stamp
  if (!builtin_interfaces__msg__Time__init(&msg->stamp)) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(msg);
    return false;
  }
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(virtual_robot_prococol__action__TargetPosition_SendGoal_Response * msg)
{
  if (!msg) {
    return;
  }
  // accepted
  // stamp
  builtin_interfaces__msg__Time__fini(&msg->stamp);
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__are_equal(const virtual_robot_prococol__action__TargetPosition_SendGoal_Response * lhs, const virtual_robot_prococol__action__TargetPosition_SendGoal_Response * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // accepted
  if (lhs->accepted != rhs->accepted) {
    return false;
  }
  // stamp
  if (!builtin_interfaces__msg__Time__are_equal(
      &(lhs->stamp), &(rhs->stamp)))
  {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__copy(
  const virtual_robot_prococol__action__TargetPosition_SendGoal_Response * input,
  virtual_robot_prococol__action__TargetPosition_SendGoal_Response * output)
{
  if (!input || !output) {
    return false;
  }
  // accepted
  output->accepted = input->accepted;
  // stamp
  if (!builtin_interfaces__msg__Time__copy(
      &(input->stamp), &(output->stamp)))
  {
    return false;
  }
  return true;
}

virtual_robot_prococol__action__TargetPosition_SendGoal_Response *
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Response * msg = (virtual_robot_prococol__action__TargetPosition_SendGoal_Response *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Response), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Response));
  bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Response__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__destroy(virtual_robot_prococol__action__TargetPosition_SendGoal_Response * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__init(virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Response * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_SendGoal_Response *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Response), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Response__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__fini(virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence *
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * array = (virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Response__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_SendGoal_Response__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_SendGoal_Response);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_SendGoal_Response * data =
      (virtual_robot_prococol__action__TargetPosition_SendGoal_Response *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Response__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_SendGoal_Response__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_SendGoal_Response__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `goal_id`
// already included above
// #include "unique_identifier_msgs/msg/detail/uuid__functions.h"

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__init(virtual_robot_prococol__action__TargetPosition_GetResult_Request * msg)
{
  if (!msg) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__init(&msg->goal_id)) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(msg);
    return false;
  }
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(virtual_robot_prococol__action__TargetPosition_GetResult_Request * msg)
{
  if (!msg) {
    return;
  }
  // goal_id
  unique_identifier_msgs__msg__UUID__fini(&msg->goal_id);
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__are_equal(const virtual_robot_prococol__action__TargetPosition_GetResult_Request * lhs, const virtual_robot_prococol__action__TargetPosition_GetResult_Request * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__are_equal(
      &(lhs->goal_id), &(rhs->goal_id)))
  {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__copy(
  const virtual_robot_prococol__action__TargetPosition_GetResult_Request * input,
  virtual_robot_prococol__action__TargetPosition_GetResult_Request * output)
{
  if (!input || !output) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__copy(
      &(input->goal_id), &(output->goal_id)))
  {
    return false;
  }
  return true;
}

virtual_robot_prococol__action__TargetPosition_GetResult_Request *
virtual_robot_prococol__action__TargetPosition_GetResult_Request__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Request * msg = (virtual_robot_prococol__action__TargetPosition_GetResult_Request *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Request), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Request));
  bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Request__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Request__destroy(virtual_robot_prococol__action__TargetPosition_GetResult_Request * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__init(virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Request * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_GetResult_Request *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Request), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Request__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__fini(virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence *
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * array = (virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_GetResult_Request__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_GetResult_Request__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Request);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_GetResult_Request * data =
      (virtual_robot_prococol__action__TargetPosition_GetResult_Request *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_GetResult_Request__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_GetResult_Request__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_GetResult_Request__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `result`
// already included above
// #include "virtual_robot_prococol/action/detail/target_position__functions.h"

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__init(virtual_robot_prococol__action__TargetPosition_GetResult_Response * msg)
{
  if (!msg) {
    return false;
  }
  // status
  // result
  if (!virtual_robot_prococol__action__TargetPosition_Result__init(&msg->result)) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(msg);
    return false;
  }
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(virtual_robot_prococol__action__TargetPosition_GetResult_Response * msg)
{
  if (!msg) {
    return;
  }
  // status
  // result
  virtual_robot_prococol__action__TargetPosition_Result__fini(&msg->result);
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__are_equal(const virtual_robot_prococol__action__TargetPosition_GetResult_Response * lhs, const virtual_robot_prococol__action__TargetPosition_GetResult_Response * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // status
  if (lhs->status != rhs->status) {
    return false;
  }
  // result
  if (!virtual_robot_prococol__action__TargetPosition_Result__are_equal(
      &(lhs->result), &(rhs->result)))
  {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__copy(
  const virtual_robot_prococol__action__TargetPosition_GetResult_Response * input,
  virtual_robot_prococol__action__TargetPosition_GetResult_Response * output)
{
  if (!input || !output) {
    return false;
  }
  // status
  output->status = input->status;
  // result
  if (!virtual_robot_prococol__action__TargetPosition_Result__copy(
      &(input->result), &(output->result)))
  {
    return false;
  }
  return true;
}

virtual_robot_prococol__action__TargetPosition_GetResult_Response *
virtual_robot_prococol__action__TargetPosition_GetResult_Response__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Response * msg = (virtual_robot_prococol__action__TargetPosition_GetResult_Response *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Response), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Response));
  bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Response__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Response__destroy(virtual_robot_prococol__action__TargetPosition_GetResult_Response * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__init(virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Response * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_GetResult_Response *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Response), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Response__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__fini(virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence *
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * array = (virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_GetResult_Response__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_GetResult_Response__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_GetResult_Response);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_GetResult_Response * data =
      (virtual_robot_prococol__action__TargetPosition_GetResult_Response *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_GetResult_Response__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_GetResult_Response__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_GetResult_Response__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}


// Include directives for member types
// Member `goal_id`
// already included above
// #include "unique_identifier_msgs/msg/detail/uuid__functions.h"
// Member `feedback`
// already included above
// #include "virtual_robot_prococol/action/detail/target_position__functions.h"

bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__init(virtual_robot_prococol__action__TargetPosition_FeedbackMessage * msg)
{
  if (!msg) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__init(&msg->goal_id)) {
    virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(msg);
    return false;
  }
  // feedback
  if (!virtual_robot_prococol__action__TargetPosition_Feedback__init(&msg->feedback)) {
    virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(msg);
    return false;
  }
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(virtual_robot_prococol__action__TargetPosition_FeedbackMessage * msg)
{
  if (!msg) {
    return;
  }
  // goal_id
  unique_identifier_msgs__msg__UUID__fini(&msg->goal_id);
  // feedback
  virtual_robot_prococol__action__TargetPosition_Feedback__fini(&msg->feedback);
}

bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__are_equal(const virtual_robot_prococol__action__TargetPosition_FeedbackMessage * lhs, const virtual_robot_prococol__action__TargetPosition_FeedbackMessage * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__are_equal(
      &(lhs->goal_id), &(rhs->goal_id)))
  {
    return false;
  }
  // feedback
  if (!virtual_robot_prococol__action__TargetPosition_Feedback__are_equal(
      &(lhs->feedback), &(rhs->feedback)))
  {
    return false;
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__copy(
  const virtual_robot_prococol__action__TargetPosition_FeedbackMessage * input,
  virtual_robot_prococol__action__TargetPosition_FeedbackMessage * output)
{
  if (!input || !output) {
    return false;
  }
  // goal_id
  if (!unique_identifier_msgs__msg__UUID__copy(
      &(input->goal_id), &(output->goal_id)))
  {
    return false;
  }
  // feedback
  if (!virtual_robot_prococol__action__TargetPosition_Feedback__copy(
      &(input->feedback), &(output->feedback)))
  {
    return false;
  }
  return true;
}

virtual_robot_prococol__action__TargetPosition_FeedbackMessage *
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__create()
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_FeedbackMessage * msg = (virtual_robot_prococol__action__TargetPosition_FeedbackMessage *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_FeedbackMessage), allocator.state);
  if (!msg) {
    return NULL;
  }
  memset(msg, 0, sizeof(virtual_robot_prococol__action__TargetPosition_FeedbackMessage));
  bool success = virtual_robot_prococol__action__TargetPosition_FeedbackMessage__init(msg);
  if (!success) {
    allocator.deallocate(msg, allocator.state);
    return NULL;
  }
  return msg;
}

void
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__destroy(virtual_robot_prococol__action__TargetPosition_FeedbackMessage * msg)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (msg) {
    virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(msg);
  }
  allocator.deallocate(msg, allocator.state);
}


bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__init(virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * array, size_t size)
{
  if (!array) {
    return false;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_FeedbackMessage * data = NULL;

  if (size) {
    data = (virtual_robot_prococol__action__TargetPosition_FeedbackMessage *)allocator.zero_allocate(size, sizeof(virtual_robot_prococol__action__TargetPosition_FeedbackMessage), allocator.state);
    if (!data) {
      return false;
    }
    // initialize all array elements
    size_t i;
    for (i = 0; i < size; ++i) {
      bool success = virtual_robot_prococol__action__TargetPosition_FeedbackMessage__init(&data[i]);
      if (!success) {
        break;
      }
    }
    if (i < size) {
      // if initialization failed finalize the already initialized array elements
      for (; i > 0; --i) {
        virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(&data[i - 1]);
      }
      allocator.deallocate(data, allocator.state);
      return false;
    }
  }
  array->data = data;
  array->size = size;
  array->capacity = size;
  return true;
}

void
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__fini(virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * array)
{
  if (!array) {
    return;
  }
  rcutils_allocator_t allocator = rcutils_get_default_allocator();

  if (array->data) {
    // ensure that data and capacity values are consistent
    assert(array->capacity > 0);
    // finalize all array elements
    for (size_t i = 0; i < array->capacity; ++i) {
      virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(&array->data[i]);
    }
    allocator.deallocate(array->data, allocator.state);
    array->data = NULL;
    array->size = 0;
    array->capacity = 0;
  } else {
    // ensure that data, size, and capacity values are consistent
    assert(0 == array->size);
    assert(0 == array->capacity);
  }
}

virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence *
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__create(size_t size)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * array = (virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence *)allocator.allocate(sizeof(virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence), allocator.state);
  if (!array) {
    return NULL;
  }
  bool success = virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__init(array, size);
  if (!success) {
    allocator.deallocate(array, allocator.state);
    return NULL;
  }
  return array;
}

void
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__destroy(virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * array)
{
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  if (array) {
    virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__fini(array);
  }
  allocator.deallocate(array, allocator.state);
}

bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__are_equal(const virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * lhs, const virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * rhs)
{
  if (!lhs || !rhs) {
    return false;
  }
  if (lhs->size != rhs->size) {
    return false;
  }
  for (size_t i = 0; i < lhs->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_FeedbackMessage__are_equal(&(lhs->data[i]), &(rhs->data[i]))) {
      return false;
    }
  }
  return true;
}

bool
virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence__copy(
  const virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * input,
  virtual_robot_prococol__action__TargetPosition_FeedbackMessage__Sequence * output)
{
  if (!input || !output) {
    return false;
  }
  if (output->capacity < input->size) {
    const size_t allocation_size =
      input->size * sizeof(virtual_robot_prococol__action__TargetPosition_FeedbackMessage);
    rcutils_allocator_t allocator = rcutils_get_default_allocator();
    virtual_robot_prococol__action__TargetPosition_FeedbackMessage * data =
      (virtual_robot_prococol__action__TargetPosition_FeedbackMessage *)allocator.reallocate(
      output->data, allocation_size, allocator.state);
    if (!data) {
      return false;
    }
    // If reallocation succeeded, memory may or may not have been moved
    // to fulfill the allocation request, invalidating output->data.
    output->data = data;
    for (size_t i = output->capacity; i < input->size; ++i) {
      if (!virtual_robot_prococol__action__TargetPosition_FeedbackMessage__init(&output->data[i])) {
        // If initialization of any new item fails, roll back
        // all previously initialized items. Existing items
        // in output are to be left unmodified.
        for (; i-- > output->capacity; ) {
          virtual_robot_prococol__action__TargetPosition_FeedbackMessage__fini(&output->data[i]);
        }
        return false;
      }
    }
    output->capacity = input->size;
  }
  output->size = input->size;
  for (size_t i = 0; i < input->size; ++i) {
    if (!virtual_robot_prococol__action__TargetPosition_FeedbackMessage__copy(
        &(input->data[i]), &(output->data[i])))
    {
      return false;
    }
  }
  return true;
}
