whoenig / crazyflie_cpp

C++ Library to communicate with Bitcraze Crazyflie
MIT License
21 stars 38 forks source link

Use the sendExternalPositionUpdate Api with crazyflie-link-cpp #21

Closed duguguang closed 2 months ago

duguguang commented 2 months ago

What should i do if i want use the following api?

#if 0
void Crazyflie::sendExternalPositionUpdate(
  float x,
  float y,
  float z)
{
  crtpExternalPositionUpdate position(x, y, z);
  sendPacket(position);
}

void Crazyflie::sendExternalPoseUpdate(
  float x, float y, float z,
  float qx, float qy, float qz, float qw)
{
  crtpExternalPoseUpdate pose(x, y, z, qx, qy, qz, qw);
  sendPacket(pose);
}
#endif

Maybe i can use the sendExternalPositions interface refer to the CrazyflieBroadcaster, but the function need to write the id param and i can't find the id member in the class , so did i need to store the id for the use?

void Crazyflie::sendExternalPositionUpdate(
  float x,
  float y,
  float z)
{
  crtpExternalPositionPacked req;
  req.add(id, x * 1000, y * 1000, z * 1000);
  m_connection.send(req);
}
whoenig commented 2 months ago

The id refers to the last byte of the address part of the URI. For example, if your address is 0xE7E7E7E70A, then the id is 10 (0x0A=10 decimal). You use these functions ideally with broadcasting for low latency and on the host side one would need to know which drone has which URI.

duguguang commented 2 months ago

Thank you for your answer.