working with cmvision/Blobs
hi, I am trying to work with cmvision/Blobs topic "message" and when I use in my code cmvision/Blobs.x it gives me an error, can anyone please show me how to access the elements of Blobs (x,y in particular)?
EDIT:
Here is the code:
#include "ros/ros.h"
#include <geometry_msgs/Twist.h>
#include "cmvision/Blobs.h"
#include <turtlesim/Pose.h>
using namespace std;
ros::Publisher pub_msg;
geometry_msgs::Twist cmd_msg;
cmvision::Blobs lastobjectpose;
turtlesim::Pose lastFollowerPose;
void fblobCallback(cmvision::Blobs object_pose)
{
lastobjectpose=object_pose;
}
void fposeCallback(turtlesim::Pose follower_pose)
{
lastFollowerPose=follower_pose;
}
int main (int argc, char** argv)
{
//ROS Initialization
ros::init(argc, argv, "follower_leader");
ROS_INFO("Node follower_leader Connected to roscore");
ros::NodeHandle n ("~");
ros::Subscriber pose_sub_object = n.subscribe<cmvision::Blobs>("/blobs",1,fblobCallback);
ros::Subscriber pose_sub_follower = n.subscribe<turtlesim::Pose>("follower_pose",1,fposeCallback);
pub_msg = n.advertise<geometry_msgs::Twist>("follower_velocity",1);
ros::Rate rate(10);
ROS_INFO("SPINNING @ 10Hz");
while (ros::ok()){
ros::spinOnce();
double d = 0;
d = sqrt( pow(lastobjectpose.x-lastFollowerPose.x,2)
+ pow(lastobjectpose.y-lastFollowerPose.y,2) ) ;
double dtheta = 0.0 ;
if( d>0.01 ) {
dtheta = atan2(lastobjectpose.y-lastFollowerPose.y,
lastobjectpose.x-lastFollowerPose.x)
- lastFollowerPose.theta ;
}
if(d>0.01){
cmd_msg.linear.x = 0.2*d;
cmd_msg.angular.z = 4*dtheta;}else{cmd_msg.linear.x = 0;
cmd_msg.angular.z = 0;}
pub_msg.publish(cmd_msg);
rate.sleep();
}
ROS_INFO("ROS-Node Terminated\n");
}
And here is the error i receive when i do "catkin_make":
Base path: /home/ghanim/catkin_ws
Source space: /home/ghanim/catkin_ws/src
Build space: /home/ghanim/catkin_ws/build
Devel space: /home/ghanim/catkin_ws/devel
Install space: /home/ghanim/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/ghanim/catkin_ws/build"
####
####
#### Running command: "make -j2 -l2" in "/home/ghanim/catkin_ws/build"
####
[ 0%] [ 0%] Built target std_msgs_generate_messages_py
Built target std_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_lisp
[ 18%] Built target colorgui
[ 25%] Building CXX object color_follower/CMakeFiles/color_follower_node.dir/src/color_follower_node.cpp.o
[ 31%] Built target follower_leader_node
[ 43%] Built target cmvision_generate_messages_cpp
[ 62%] Built target cmvision_generate_messages_py
[ 75%] Built target cmvision_generate_messages_lisp
[ 75%] Built target cmvision_gencpp
[ 75%] Built target cmvision_generate_messages
[100%] Built target cmvision
/home/ghanim/catkin_ws/src/color_follower/src/color_follower_node.cpp: In function ‘int main(int, char**)’:
/home/ghanim/catkin_ws/src/color_follower/src/color_follower_node.cpp:60:33: error: ‘cmvision::Blobs’ has no member named ‘x’
/home/ghanim/catkin_ws/src/color_follower/src/color_follower_node.cpp:61:39: error: ‘cmvision::Blobs’ has no member named ‘y’
/home/ghanim/catkin_ws/src/color_follower/src/color_follower_node.cpp:64:36: error: ‘cmvision::Blobs’ has no member named ‘y’
/home/ghanim/catkin_ws/src/color_follower/src/color_follower_node.cpp:65:39: error: ‘cmvision::Blobs’ has no member named ‘x’
make[2]: *** [color_follower/CMakeFiles/color_follower_node.dir/src/color_follower_node.cpp.o] Error 1
make[1]: *** [color_follower/CMakeFiles/color_follower_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
Please update your question with the error message you're getting, and the code that produces it.
When adding code, please don't create an answer. I moved the code to your original question, and deleted the answer you created.
okay and thanks