Is there an already built-in method to change crazyflie parameters using rosrun on terminal?
Have searched through crazyflie_tools and there doesn't seem to be executable that can do it (the closest one is listParams), so I tried to write my own executable for it (I do not know C++ at all, was just playing around and trying it out, am taking online courses right now.), which compiled but doesn't work.
I'm guessing it's the following block of code here that would make it work: https://github.com/whoenig/crazyflie_cp ... #L770-L775
I was hoping to use this command line to control the parameters for the crazyflies because I'm using more than one, it would be so much faster to change all of their parameters by a using a single line of code.
For instance, maybe something like:
rosrun crazyflie_tools setParam --ring.effect -- 2 --uri radio://0/100/2M/E7E7E7E7XX
or
rosrun crazyflie_tools setParam --param ring.effect --value 2 --uri radio://0/100/2M/E7E7E7E7XX
or
rosrun crazyflie_tools setParam --param ring/effect --value 2 --uri radio://0/100/2M/E7E7E7E7XX
I've tried using the python way of connecting at first. It works well, but the issue is that using crazyflie.open_link(uri) takes a considerable amount of time (>2s) and it establishes a blocking connection, whereas using the crazyflie ros tools, multiple crazyfliess can be targeted at once (not sure why that is so, might be because packets are sent instead of a establishing a stable link). I might as well do it via cfclient if I'm using this method.
Here is what I did, if anyone is interested. I'm ashamed because I really don't know what I'm doing, not sure if what I'm passing into the method even makes sense.
This is based of listParams.cpp by whoenig's crazyflie ros
setParam.cpp
Code: Select all
#include <iostream>
#include <boost/program_options.hpp>
#include <crazyflie_cpp/Crazyflie.h>
int main(int argc, char **argv)
{
std::string uri;
std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
std::uint8_t param;
std::string value;
namespace po = boost::program_options;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
("param", po::value<std::uint8_t>(¶m)->required(), "parameter to set")
("value", po::value<std::string>(&value)->required(), "value to set")
;
try
{
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 0;
}
}
catch(po::error& e)
{
std::cerr << e.what() << std::endl << std::endl;
std::cerr << desc << std::endl;
return 1;
}
try
{
Crazyflie cf(uri);
cf.setParam(param, value);
return 0;
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
return 1;
}
}