Publish velocities in a Topic [closed]

asked 2015-04-29 04:18:50 -0600

Alvaro Salcedo gravatar image

Hello everyone. I am trying to publish velocities in a topic which name is "pd3x/cmd_vel". I have build this .cpp but it doesn work:

#include <termios.h>
#include <signal.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>


class lanzando_vel
{
private:
ros::NodeHandle n_;
ros::Publisher vel_pub_;
public:
    vel_pub_ = n_advertise<geometry_msgs::Twist>("p3dx/cmd_vel", 1);
};

int
main(int argc, char **argv)
{
 ros::init(argc, argv, "lanzar_velocidades_node");
 ros::NodeHandle n_
}

while (ros::ok())
{
geometry_msgs::Twist p3dx/cmd_vel; 
cmd.linear.x = 0.25;
cmd.linear.y = 0;
cmd.linear.z = 0;

cmd.angular.x = 0;
cmd.angular.y = 0;
cmd.angular.z = 0;

vel_pub_.publish(p3dx/cmd_vel);
}

When I write catkin_make, the errors are:

49:5: error: ‘vel_pub_’ does not name a type vel_pub_ = n_advertise<geometry_msgs::twist>("p3dx/cmd_vel", 1);

/home/alcor/catkin_ws/src/lanzar_velocidades/src/teleop_pr2_keyboard.cpp: In function ‘int main(int, char**)’:

/home/alcor/catkin_ws/src/lanzar_velocidades/src/teleop_pr2_keyboard.cpp:57:1: error: expected initializer before ‘}’ token }

/home/alcor/catkin_ws/src/lanzar_velocidades/src/teleop_pr2_keyboard.cpp: At global scope:

/home/alcor/catkin_ws/src/lanzar_velocidades/src/teleop_pr2_keyboard.cpp:59:1: error: expected unqualified-id before ‘while’ while (ros::ok())

I just try publish this linear and angular velocity in the topic pd3x/cmd_vel, but I can not..

Can you help me?

Thank you so much.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by Alvaro Salcedo
close date 2015-04-29 04:35:50.028743

Comments

I have just done. Thank you! If someone want the code please tell me and i publish :)

Thanks.

Alvaro Salcedo gravatar image Alvaro Salcedo  ( 2015-04-29 04:35:30 -0600 )edit