Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to Hydro with turtlesim twist messages #4

Closed
wants to merge 9 commits into from
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
### Tutorial code for using a Linux Joystick device with ROS

This code demonstrates how to setup a linux joystick device with ROS and interface it with the turtlesim program. The tutorial text is available on the ROS Wiki article [Writing a Teleoperation Node for a Linux-Supported Joystick][1].

[1]:http://wiki.ros.org/joy/Tutorials/WritingTeleopNode
12 changes: 6 additions & 6 deletions turtle_teleop/src/teleop_turtle_joy.cpp
@@ -1,7 +1,7 @@
// %Tag(FULL)%
// %Tag(INCLUDE)%
#include <ros/ros.h>
#include <turtlesim/Velocity.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Joy.h>
// %EndTag(INCLUDE)%
// %Tag(CLASSDEF)%
Expand Down Expand Up @@ -34,7 +34,7 @@ TeleopTurtle::TeleopTurtle():
nh_.param("scale_linear", l_scale_, l_scale_);
// %EndTag(PARAMS)%
// %Tag(PUB)%
vel_pub_ = nh_.advertise<turtlesim::Velocity>("turtle1/command_velocity", 1);
vel_pub_ = nh_.advertise<geometry_msgs::Twist>("turtle1/cmd_vel", 1);
// %EndTag(PUB)%
// %Tag(SUB)%
joy_sub_ = nh_.subscribe<sensor_msgs::Joy>("joy", 10, &TeleopTurtle::joyCallback, this);
Expand All @@ -43,10 +43,10 @@ TeleopTurtle::TeleopTurtle():
// %Tag(CALLBACK)%
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);
geometry_msgs::Twist twist;
twist.linear.x = l_scale_*joy->axes[linear_];
twist.angular.z = a_scale_*joy->axes[angular_];
vel_pub_.publish(twist);
}
// %EndTag(CALLBACK)%
// %Tag(MAIN)%
Expand Down