Ask Your Question
0

error: ‘visualization_msgs::Marker’ has no member named ‘set_points_size’ [closed]

asked 2017-03-05 13:45:49 -0500

zakizadeh gravatar image

i wrote fdisplay.cpp in src folder, when i run rosmake , i have error .

    #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 = 0;
    marker.pose.orientation.x = 0.0;
    marker.pose.orientation.y = 0.0;
    marker.pose.orientation.z = 0.0;
    marker.pose.orientation.w = 1.0;
    marker.scale.x = 0.008;
    marker.scale.y = 0.02;
    marker.scale.z = 0.0;
    marker.color.a = 1.0;
    marker.color.r = 1.0;
    marker.color.g = 0.0;
    marker.color.b = 0.0;
    marker.set_points_size(2);
    marker.points[0].x=(start.point.x)/1000;
    marker.points[0].y=(start.point.y)/1000;
    marker.points[0].z=(start.point.z)/1000;
    marker.points[1].x=start.point.x/1000+vector.vector.x/100;
    marker.points[1].y=start.point.y/1000+vector.vector.y/100;
    marker.points[1].z=start.point.z/1000+vector.vector.z/100;

    marker_pub.publish(marker);

}

void Transforms::f1Callback(const geometry_msgs::WrenchStamped& msg){
    f1ft.vector=msg.wrench.force;
}


void Transforms::f2Callback(const geometry_msgs::WrenchStamped& msg){
    f2ft.vector=msg.wrench.force;
}



int main(int argc, char** argv){
    ros::init(argc, argv, "forcesdisplay");


    Transforms Trans;

    Trans.f1_sub=Trans.node.subscribe("finger1/nano17ft",1000,&Transforms::f1Callback,&Trans);
        Trans.f2_sub=Trans.node.subscribe("finger2/nano17ft",1000,&Transforms::f2Callback,&Trans);

    ros::Rate rate(10.0);
    ros::Time now;
    geometry_msgs::Vector3Stamped wvect,weight,weight1;

    tf::Vector3 weight2;
    tf::Transformer TransClass;
    tf::StampedTransform transform;
    tf::Stamped<tf::Vector3> vaux,w2;


    while (Trans.node.ok()){


        Trans.DrawFn(1,"/BHand/FingerOne/Sensor",Trans.f1ft,1);
        Trans.DrawFn(2,"/BHand/FingerTwo/Sensor",Trans.f2ft,1);




        //DRAW WEIGHT:

        //FINGER 1
        tf::vector3StampedMsgToTF(Trans.f1ft,vaux);

        try{
            now = ros::Time::now();
            vaux.frame_id_="/BHand/FingerOne/Sensor";
            vaux.stamp_=now;

            Trans.listener.waitForTransform("/BHand/FingerOne/Sensor", "/robot_base",   now, ros::Duration(3.0));
            Trans.listener.lookupTransform("/BHand/FingerOne/Sensor", "/robot_base",now/*ros::Time(0)*/, transform);
            Trans.listener.transformVector("/robot_base",vaux,w2);
            tf::vector3TFToMsg(w2,wvect.vector);

            weight=wvect;

    }
    catch (tf::TransformException ex){
            ROS_ERROR("%s",ex.what());
        }
        try{

            //FINGER 2
            tf::vector3StampedMsgToTF(Trans.f2ft,vaux);
            now = ros::Time::now();
            vaux.frame_id_="/BHand/FingerTwo/Sensor";
            vaux.stamp_=now;

            Trans.listener.waitForTransform("/BHand/FingerTwo/Sensor", "/robot_base",now, ros::Duration(3.0));
            Trans.listener.lookupTransform("/BHand/FingerTwo/Sensor", "/robot_base ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ahendrix
close date 2017-03-06 11:38:43.573767

Comments

1

This compiler error is trying to tell you that the set_points_size method doesn't exist on a visualization_msgs::Marker object.

ahendrix gravatar image ahendrix  ( 2017-03-05 14:07:31 -0500 )edit

what can i do ?? i need points_size

zakizadeh gravatar image zakizadeh  ( 2017-03-05 21:28:22 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-03-05 23:26:19 -0500

ahendrix gravatar image

updated 2017-03-06 00:36:08 -0500

gvdhoorn gravatar image

No, you don't need points_size . You need to set the size of the points vector within the marker object. Since points is a std::vector, I would start with the std::vector documentation.

From the std::vector documentation, you should look for a method that sets the size of the vector, and you should find the resize method. Now you know that the proper way to set the size of marker.points is marker.points.resize(2)

edit flag offensive delete link more

Comments

thanks a lot .

zakizadeh gravatar image zakizadeh  ( 2017-03-05 23:54:37 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-05 13:45:49 -0500

Seen: 1,164 times

Last updated: Mar 06 '17