micro_ros_arduino: Int64MultiArray subscriber not working

Issue template

using OpenCR to control dynamixels. The subscriber(Int64MultiArray) is not working. When I change the message type to Int32 it is working. I read the documentation and initialized the array(mentioned below). kindly inform me how to implement it.

int64_t array_tic[2]= {left_tick,right_tick};
int64_t value[10] = {0,0,0,0,0,0,0,0,0,0};

goal_vel = std_msgs__msg__Int64MultiArray__create();
      goal_vel->data.capacity = 10;
      goal_vel->data.data = (int64_t*)malloc(goal_vel->data.capacity * sizeof(int64_t));
      goal_vel->data.size = sizeof(value)/sizeof(int64_t);memcpy(goal_vel->data.data, value,sizeof(value));
//            
      ticks = std_msgs__msg__Int64MultiArray__create();  
      ticks->data.capacity = 2;
      ticks->data.data = (int64_t*)malloc(sizeof(array_tic));   
      ticks->data.size = sizeof(array_tic)/sizeof(int64_t);memcpy(ticks->data.data,array_tic,sizeof(array_tic));

//////Callback function:

void subscription_callback(const void * msgin)
{  
    const std_msgs__msg__Int64MultiArray * goal_vel = (const std_msgs__msg__Int64MultiArray *)msgin;
    int64_t left_front; 
    
//    value[0] = int64_t(goal_vel->data.data[0]);    
    //left_front = int32_t(msg->data);
    dxl.setGoalVelocity(DXL_ID,value[0]);
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

HI,

Thanks a lot for the example. It is working fine.

Sorry for the late reply.