32 #include <sensor_msgs/Joy.h> 33 #include <geometry_msgs/Twist.h> 73 params.
param<
int>(
"yaw_axis",
axes_.yaw.axis, 1);
75 params.
param<
double>(
"yaw_velocity_max",
axes_.yaw.max, 90.0 * M_PI / 180.0);
77 params.
param<
double>(
"x_velocity_max",
axes_.x.max, 2.0);
78 params.
param<
double>(
"y_velocity_max",
axes_.y.max, 2.0);
79 params.
param<
double>(
"z_velocity_max",
axes_.z.max, 2.0);
84 velocity_publisher_ = node_handle_.
advertise<geometry_msgs::Twist>(
"cmd_vel", 10);
96 velocity_publisher_.
publish(velocity_);
111 sensor_msgs::Joy::_axes_type::value_type
getAxis(
const sensor_msgs::JoyConstPtr &joy,
Axis axis)
113 if (axis.
axis == 0) {
116 sensor_msgs::Joy::_axes_type::value_type sign = 1.0;
121 if ((
size_t) axis.
axis > joy->axes.size()) {
124 return sign * joy->axes[axis.
axis - 1] * axis.
max;
127 sensor_msgs::Joy::_buttons_type::value_type
getButton(
const sensor_msgs::JoyConstPtr &joy,
int button)
132 if ((
size_t) button > joy->buttons.size()) {
135 return joy->buttons[button - 1];
141 velocity_ = geometry_msgs::Twist();
142 velocity_publisher_.
publish(velocity_);
147 int main(
int argc,
char **argv)
149 ros::init(argc, argv,
"quadrotor_teleop");
geometry_msgs::Twist velocity_
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Publisher velocity_publisher_
sensor_msgs::Joy::_buttons_type::value_type getButton(const sensor_msgs::JoyConstPtr &joy, int button)
ros::Subscriber joy_subscriber_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
sensor_msgs::Joy::_axes_type::value_type getAxis(const sensor_msgs::JoyConstPtr &joy, Axis axis)
int main(int argc, char **argv)
uint32_t getNumSubscribers() const
ros::NodeHandle node_handle_
ROSCPP_DECL void spinOnce()
void joyTwistCallback(const sensor_msgs::JoyConstPtr &joy)