error in rosmake tf_workshop

asked 2017-05-05 12:48:42 -0600

zakizadeh gravatar image

i try to learning Handling ROS Tutorial course . when i run this command i have error :

rosmake tf_workshop

error :

 /home/zakizadeh/catkin_ws2/src/tf_workshop/src/fdisplay.cpp: In member function ‘void Transforms::DrawFn(int, char*, geometry_msgs::Vector3Stamped, int)’:
  /home/zakizadeh/catkin_ws2/src/tf_workshop/src/fdisplay.cpp:62:9: error: ‘visualization_msgs::Marker’ has no member named ‘set_points_size’
    marker.set_points_size(2);

my obj_tracker file :

    #include <stdio.h>
#include <ros/ros.h>
#include <cstdlib>
#include <visualization_msgs/Marker.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/Quaternion.h>
#include <geometry_msgs/Vector3.h>
#include <math.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
#include <sensor_msgs/PointCloud2.h>


#define pi 3.14159265

class Ktracker{

public:
    Ktracker();
    ros::Subscriber trkmarker_sub, pose_sub;
    ros::Publisher objectpc_pub;

    void trackCallback(const visualization_msgs::Marker&);
    void poseCallback(const geometry_msgs::PoseStamped&);

    tf::TransformListener listener;
    tf::StampedTransform transform;
    tf::TransformBroadcaster br;
    tf::Quaternion qtf;

private:
    sensor_msgs::PointCloud objectpc;


};

Ktracker::Ktracker(){

    ros::NodeHandle n;
    objectpc_pub=n.advertise<sensor_msgs::PointCloud>("objpc",1000);
}


void Ktracker::trackCallback(const visualization_msgs::Marker &msg){


    objectpc.set_points_size(msg.get_points_size());

    int i;
    for (i=0;i<(int) msg.get_points_size();i++){
        objectpc.points[i].x=msg.points[i].x;
        objectpc.points[i].y=msg.points[i].y;
        objectpc.points[i].z=msg.points[i].z;
    }

    ros::Time now = ros::Time::now();
    transform.setOrigin(tf::Vector3(msg.pose.position.x,msg.pose.position.y,msg.pose.position.z));
    tf::quaternionMsgToTF(msg.pose.orientation,qtf);
    transform.setRotation(qtf);
    br.sendTransform(tf::StampedTransform(transform, msg.header.stamp, "/openni_rgb_frame","/object_frame"));
    objectpc.header.frame_id="/object_frame";

    try
    {
// Enter the correct transformation to track the object 


        //now=ros::Time::now();
        listener.waitForTransform("/object_frame", "/end_effector",msg.header.stamp, ros::Duration(0.2));
        listener.lookupTransform("/object_frame", "/end_effector",msg.header.stamp, transform);
        listener.transformPointCloud("/end_effector",objectpc,objectpc);
        objectpc.header.frame_id="/end_effector";
        objectpc_pub.publish(objectpc);

    }
    catch (tf::TransformException ex)
    {
        ROS_WARN("TF Exception: %s", ex.what());
    }
}


void Ktracker::poseCallback(const geometry_msgs::PoseStamped &msg){
    objectpc_pub.publish(objectpc);
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "armtrack");
    Ktracker ktracker;
    ros::Rate loop_rate(20);
    visualization_msgs::Marker bluem;
    ros::NodeHandle n;
    ktracker.trkmarker_sub=n.subscribe("markers_out", 1000, &Ktracker::trackCallback,&ktracker);
    ktracker.pose_sub=n.subscribe("armpose",1000, &Ktracker::poseCallback,&ktracker);

    ros::spin();

}

my fdisplay.cpp :

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_listener.h>
#include <geometry_msgs/WrenchStamped.h>
#include <geometry_msgs/Vector3Stamped.h>
#include <visualization_msgs/Marker.h>

class Transforms{
public:
    Transforms();
    void f1Callback(const geometry_msgs::WrenchStamped&);
    void f2Callback(const geometry_msgs::WrenchStamped&);
    void DrawFn(int,char*,geometry_msgs::Vector3Stamped,int);

    geometry_msgs::Vector3Stamped f1ft,f2ft;
    geometry_msgs::PointStamped f1cl,f2cl;
    geometry_msgs::PointStamped start;

    ros::NodeHandle node;
    tf::TransformListener listener;
    ros::Subscriber f1_sub,f2_sub;
    ros::Publisher marker_pub;
    visualization_msgs::Marker marker;
private:

};

Transforms::Transforms(){
    marker_pub = node.advertise<visualization_msgs::Marker>("fmarker", 10);
    start.point.x=0;
    start.point.y=0;
    start.point.z=0;

}






void Transforms::DrawFn(int id,char* frame, geometry_msgs::Vector3Stamped vector,int color){
    marker.header.frame_id = frame;
    marker.header.stamp = ros::Time();
    marker.ns = "my_namespace";
    marker.id = id;
    marker.type = visualization_msgs::Marker::ARROW;
    marker.action = visualization_msgs::Marker::ADD;
    marker.pose.position.x = 0;
    marker.pose.position.y = 0;
    marker.pose.position.z ...
(more)
edit retag flag offensive close merge delete