I am attempting the topics_quiz
right now and I need to compare the output of the ranges
array to some constant (1 in this case) to publish the correct Twist
information to the /cmd_vel
node.
I have this code to compare specific values within range
to the constant:
if (msg->ranges[360] < 1.0) { var.angular.z = 0.5; } else if (msg->ranges[0] < 1.0) { var.angular.z = 0.5; } else if (msg->ranges[719] < 1.0) { var.angular.z = -0.5; } else { var.linear.x = 0.6; var.angular.z = 0; }
Where var
is the Twist
variable that stores the information to be published to the /cmd_vel
node.
I get many error message when building this:
/home/user/catkin_ws/src/topics_quiz/src/topics_quiz.cpp:19:47: error: conversion from 'const value_type' {aka 'const float'} to non-scalar type 'std_msgs::Float32' {aka 'std_msgs::Float32_<std::allocator<void> >'} requested 19 | std_msgs::Float32 right_dist = msg->ranges[0];
Anyone have any idea what I can do to make this control flow statement work?