[SOLVED]ROS

Discussions about all things Bitcraze
Post Reply
aashisht97
Beginner
Posts: 5
Joined: Fri Jun 23, 2017 9:14 pm

[SOLVED]ROS

Post 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.
Last edited by aashisht97 on Fri Jun 30, 2017 10:24 am, edited 1 time in total.
szx0112
Beginner
Posts: 15
Joined: Thu Feb 23, 2017 6:59 pm

Re: ROS

Post by szx0112 »

Looks like it defines some log in parameter server for customization.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: ROS

Post 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?
aashisht97
Beginner
Posts: 5
Joined: Fri Jun 23, 2017 9:14 pm

Re: ROS

Post 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.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: ROS

Post 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?
aashisht97
Beginner
Posts: 5
Joined: Fri Jun 23, 2017 9:14 pm

Re: ROS

Post 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!
Post Reply