Page 1 of 1

[SOLVED]ROS

Posted: Fri Jun 23, 2017 9:44 pm
by aashisht97
The following is a piece of code from crazyflie_ros package (crazyflie_add.cpp):

Code: Select all

 std::vector<std::string> genericLogTopics;
  n.param("genericLogTopics", genericLogTopics, std::vector<std::string>());
  std::vector<int> genericLogTopicFrequencies;
  n.param("genericLogTopicFrequencies", genericLogTopicFrequencies, std::vector<int>());

  if (genericLogTopics.size() == genericLogTopicFrequencies.size())
  {
    size_t i = 0;
    for (auto& topic : genericLogTopics)
    {
      crazyflie_driver::LogBlock logBlock;
      logBlock.topic_name = topic;
      logBlock.frequency = genericLogTopicFrequencies[i];
      n.getParam("genericLogTopic_" + topic + "_Variables", logBlock.variables);
      addCrazyflie.request.log_blocks.push_back(logBlock);
      ++i;
    }
  }
  else
  {
    ROS_ERROR("Cardinality of genericLogTopics and genericLogTopicFrequencies does not match!");
  }
Can someone please explain what is happening. I am new to ROS and unable to decipher what's happening here. Especially the condition

Code: Select all

genericLogTopics.size() == genericLogTopicFrequencies.size()
What is the need for this?
Thank you in advance.

Re: ROS

Posted: Sat Jun 24, 2017 2:28 am
by szx0112
Looks like it defines some log in parameter server for customization.

Re: ROS

Posted: Mon Jun 26, 2017 12:37 pm
by arnaud
Hi, this piece of code implements the generic log functionality. The functionality is used by almost all the ros lauch examples for lps: https://github.com/bitcraze/lps-ros/blo ... ch#L22-L26

In particular, the line you copy-pasted checks that the list of log-block topic names has the same length as the list of logging frequency.

What is your need for understanding this code? What is your end-goal?

Re: ROS

Posted: Thu Jun 29, 2017 9:55 am
by aashisht97
@arnaud
My end goal is to fly the crazyflie autonomously over a desired track (trajectory tracking). I am trying to understand the logic behind the PID controller algorithm being used (for eg, how is the error being reduced, how is feedback being obtained etc.)
What is the need to check that the list of log-block topic names has the same length as the list of logging frequency?

Thanking you in advance.

Re: ROS

Posted: Fri Jun 30, 2017 8:05 am
by arnaud
This code has nothing to do with the PID and the control of the quadcopter, it is just a tool to fetch data from the quadcopter. If you look at the laucnch-file link I sent, there is a list of log block name and log block frequency. This test is essentially syntax check for the configuration: there should be one frequency per log bock.

There is a position PID loop implemented in the Crazyflie itself, this is most likely what you want to use. Are you using the stock Crazyflie firmware or the crazyswarm?

Re: ROS

Posted: Fri Jun 30, 2017 8:55 am
by aashisht97
Thanks a tonne for the information. I am actually trying to use a package "crazyflie_ros" and trying to understand the various files written in it. The code I pasted was one of them and I was curious to know what it actually meant. I would soon try to use crazyswarm as well!