ROSJOY help
Hi, I'm running hydro on ubuntu 12.04
I have been trying to go through the tutorial on writing a node to use a ps3 controller with ros here. After many try's I think it failed because hydro doesn’t have turtlesim/Velocity.h
. I'm a beginner with cs and am not sure how to build this controller node from scratch. in particular, what would I do to this code to get it to work on hydro?
Here's the code
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Joy.h>
class TeleopTurtle
{
public:
TeleopTurtle();
private:
void joyCallback(const sensor_msgs::Joy::ConstPtr& joy);
ros::NodeHandle nh_;
int linear_, angular_;
double l_scale_, a_scale_;
ros::Publisher vel_pub_;
ros::Subscriber joy_sub_;
};
TeleopTurtle::TeleopTurtle():
linear_(1),
angular_(2)
{
nh_.param("axis_linear", linear_, linear_);
nh_.param("axis_angular", angular_, angular_);
nh_.param("scale_angular", a_scale_, a_scale_);
nh_.param("scale_linear", l_scale_, l_scale_);
vel_pub_ = nh_.advertise<turtlesim::Velocity>("turtle1/turtle1/cmd_vel", 1);
joy_sub_ = nh_.subscribe<sensor_msgs::Joy>("joy", 10, leopTurtle::joyCallback, this);
}
void TeleopTurtle::joyCallback(const sensor_msgs::Joy::ConstPtr& joy)
{
turtlesim::Velocity vel;
vel.angular = a_scale_*joy->axes[angular_];
vel.linear = l_scale_*joy->axes[linear_];
vel_pub_.publish(vel);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "teleop_turtle");
TeleopTurtle teleop_turtle;
ros::spin();command_velocity
}
After making two changes, 1) Changing turtlesim_velocity to geometry_msg/Twist 2) Changing Command_Velocity to cmd_vel I get the following errors when running rosmake on the package.
/home/donni/catkin_ws/src/beginner_tutorials/learning_ps3joy/src/turtle_teleop_ps3joy.cpp:44:3: error: ‘turtlesim’ has not been declared
/home/donni/catkin_ws/src/beginner_tutorials/learning_ps3joy/src/turtle_teleop_ps3joy.cpp:44:23: error: expected ‘;’ before ‘vel’
/home/donni/catkin_ws/src/beginner_tutorials/learning_ps3joy/src/turtle_teleop_ps3joy.cpp:45:3: error: ‘vel’ was not declared in this scope
Can someone interpret them for me?