I’m using pros to program my robot, and i am trying to experiment with v5 motor encoders. I am trying to print the motor.get_position() function but it always says that it cant convert the double value into a string value. I am new to use pros and thank you for helping.
#include <string>
std::string str=std::to_string(motor.get_position());
std::cout<<str.c_str()<<std::endl;
1 Like
Wow. That’s a lot of code…
printf("%f\n", motor.get_position());
or:
std::cout << motor.get_position() << std::endl;
1 Like
Thanks. But how do i print this on the controller’s screen? Does this work?
lcd_print(0, “%f\n”, motor.get_position());
Thanks a lot.
I guess what he meant was how to convert double
into const char*
#include <string>
std::string str=std::to_string(motor.get_position());
lcd_print(0,“%s \ n”,str.c_str());
1 Like
That’s more code than is necessary
pros::lcd::print(0, "%f", motor.get_position());
2 Likes
I haven’t heard of any issues with LLEMU. Open an issue on GitHub with an example and we’ll take a look.
1 Like
My student said that the main problem was the length of printing.
Mingming remote control screen still has space. If it’s longer, it’s useless.
joy1->print(0, 0, "joy robot ball");
while(1)
if (_timerDisPlay.getDtFromMark() >= 100)
{
joy->print(1, 0, "%d%% %.0f%% %u", joy->get_battery_capacity(), pros::battery::get_capacity(), getBallNums());
_timerDisPlay.placeMark();
}
joy1->print(0, 0, "joy robot ball");//Adding more space
And :
joy->get_battery_capacity()
It seems inaccurate. Is there something wrong with my usage?
No, I think you are just running into the limit we have on string length able to be sent to the controller.
1 Like