ethz-asl / asctec_mav_framework

Framework for data aquisition and position control to be used with the highlevel processor of Ascending Technologies helicopters
http://www.ros.org/wiki/asctec_mav_framework
36 stars 40 forks source link

Why is there a negative in front of roll and pitch #74

Closed andre-nguyen closed 7 years ago

andre-nguyen commented 7 years ago

Here https://github.com/ethz-asl/asctec_mav_framework/blob/master/asctec_hl_interface/src/hl_interface.cpp#L522

void HLInterface::controlCmdCallbackMavComm(const mav_msgs::RollPitchYawrateThrustConstPtr & msg)
{
  asctec_hl_comm::mav_ctrl msg_old;

  msg_old.type = asctec_hl_comm::mav_ctrl::acceleration;
  msg_old.x = - msg->pitch;
  msg_old.y = - msg->roll;
  double thrust = msg->thrust.z; //thrust in [N]
  //mapping from thrust to asctec command [0 1] (for Firefly)
  //TODO make polynomial coefficients as parameters
  //msg_old.z = -0.000667*thrust*thrust + 0.0319*thrust + 0.233;
  double throttle = 0.0;
  if(mav_type_ == "hummingbird"){
    throttle = thrust/16.0 + 0.1;
  }else if(mav_type_ == "firefly"){
    throttle = thrust/36.0 + 0.1;
  }else{
    ROS_ERROR("Unkown vehicle type...");
    return;
  }

  if(throttle > 0.95)
    throttle = 0.95;

  if(throttle < 0)
    throttle = 0;

  msg_old.z = throttle;
  msg_old.yaw = msg->yaw_rate;

  sendControlCmd(msg_old);
}

Why is there a negative in front of the roll and pitch, is this some kind of coordinate transformation?

fmina commented 7 years ago

Yes, the MAV body frame has z axis aligned with the gravity vector. While in the controller the body frame has z axis pointing upward. See here http://wiki.asctec.de/display/AR/SDK+Manual Therefore we need to transform the coordinates.