Cannot convert ros::Subscriber to float
Hello,
I have the Problem: error: cannot convert ros::Subscriber to float in assignment
I used 2 Subscirber to listen to my velocities and i want to get this as an float but it doesn't work.
#include "ros/ros.h"
#include "std_msgs/Float64.h"
#include <can_msgs/Frame.h>
#include <socketcan_bridge/topic_to_socketcan.h>
#include <socketcan_interface/socketcan.h>
class VehicleDynamics
{
public:
VehicleDynamics()
{
sub_vel_left= n.subscribe<std_msgs::Float64>("left_velocity_controller/command",1, &VehicleDynamics::velCallback, this);
sub_vel_right= n.subscribe<std_msgs::Float64>("right_velocity_controller/command",1, &VehicleDynamics::velCallback, this);
pub_ = n.advertise<can_msgs::Frame>("sent_messages", 10);
}
float calculate()
{
static const float calcReduc = m_reduc * 16.6666666f;
static const float calcDiameter = (m_diameter * M_PI) / 1000.0f;
velocity_rpm = ((left_wheel+right_wheel)/ 2);
return (velocity_rpm* calcDiameter/calcReduc);
}
void velCallback(const std_msgs::Float64::ConstPtr& float_msgs)
{
n.getParam("MobileResearchPlattform/motor/nominal_speed",m_max_velocity);
n.getParam("MobileResearchPlattform/geometry/wheel_diameter",m_diameter);
n.getParam("/MobileResearchPlattform/motor/reduction",m_reduc);
left_wheel=sub_vel_left;
right_wheel=sub_vel_right;
velocity_kmh = calculate();
can_msgs::Frame msg;
msg.is_extended = false;
msg.is_rtr = false;
msg.is_error = false;
msg.id = 0x220;
msg.dlc = 8;
msg.data[1] = velocity_kmh;
msg.header.frame_id = "0"; // "0" for no frame.
msg.header.stamp = ros::Time::now();
// send the can_frame::Frame message to the sent_messages topic.
pub_.publish(msg);
}
private:
ros::NodeHandle n;
ros::Publisher pub_;
ros::Subscriber sub_vel_left;
ros::Subscriber sub_vel_right;
float velocity_rpm;
float velocity_kmh;
float left_wheel;
float right_wheel;
float m_max_velocity;
float m_diameter;
int m_reduc;
};
int main(int argc, char **argv)
{
ros::init(argc,argv,"VehilceDyn");
VehicleDynamics SAPObject;
ros::Rate loop_rate(10000);
ros::spin();
return 0;
}