uos_diffdrive_teleop_cyborgevo.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <geometry_msgs/Twist.h>
3 #include <std_msgs/String.h>
4 #include <sensor_msgs/Joy.h>
5 
9 std_msgs::String request;
10 
12 
13 void cyborgevoCallback(const sensor_msgs::Joy::ConstPtr& joy)
14 {
15  geometry_msgs::Twist vel;
16  vel.linear.x = max_vel_x * (joy->axes[2] + 1) / 2 * joy->axes[1];
17  vel.angular.z = max_rotational_vel * (joy->axes[2] + 1) / 2 * joy->axes[0];
18  vel_pub.publish(vel);
19 
20  if (joy->buttons[0] != 0) {
21  if(!requesting) req_pub.publish(request);
22  requesting = true;
23  }
24  else requesting = false;
25 }
26 
27 int main(int argc, char** argv)
28 {
29  ros::init(argc, argv, "uos_diffdrive_teleop_cyborgevo");
30 
31  ros::NodeHandle nh;
32  ros::NodeHandle nh_ns("~");
33 
34  nh_ns.param("max_vel_x", max_vel_x, 1.5);
35  nh_ns.param("max_rotational_vel", max_rotational_vel, 3.0);
36 
37  request.data = "scanRequest";
38  requesting = false;
39 
40  vel_pub = nh.advertise<geometry_msgs::Twist>("cmd_vel", 1);
41  req_pub = nh.advertise<std_msgs::String>("request", 1);
42  ros::Subscriber cyborgevo_sub = nh.subscribe("joy", 10, cyborgevoCallback);
43 
44  ros::spin();
45 }
46 
double max_rotational_vel
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())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Publisher req_pub
ros::Publisher vel_pub
bool param(const std::string &param_name, T &param_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void spin()
std_msgs::String request
void cyborgevoCallback(const sensor_msgs::Joy::ConstPtr &joy)


uos_diffdrive_teleop
Author(s): Jochen Sprickerhof, Sebastian Pütz
autogenerated on Mon Jun 10 2019 15:49:27