22 #include <osrf_gear/Goal.h> 23 #include <osrf_gear/LogicalCameraImage.h> 24 #include <osrf_gear/Proximity.h> 25 #include <sensor_msgs/JointState.h> 26 #include <sensor_msgs/LaserScan.h> 27 #include <std_msgs/Float32.h> 28 #include <std_msgs/String.h> 29 #include <std_srvs/Trigger.h> 30 #include <trajectory_msgs/JointTrajectory.h> 38 node.
serviceClient<std_srvs::Trigger>(
"/ariac/start_competition");
41 if (!start_client.
exists()) {
42 ROS_INFO(
"Waiting for the competition to be ready...");
44 ROS_INFO(
"Competition is now ready.");
46 ROS_INFO(
"Requesting competition start...");
47 std_srvs::Trigger srv;
48 start_client.
call(srv);
49 if (!srv.response.success) {
50 ROS_ERROR_STREAM(
"Failed to start the competition: " << srv.response.message);
66 "/ariac/arm/command", 10);
97 const sensor_msgs::JointState::ConstPtr & joint_state_msg)
100 "Joint States (throttled to 0.1 Hz):\n" << *joint_state_msg);
105 ROS_INFO(
"Sending arm to zero joint positions...");
115 trajectory_msgs::JointTrajectory
msg;
119 msg.points.resize(1);
132 const osrf_gear::LogicalCameraImage::ConstPtr & image_msg)
135 "Logical camera: '" << image_msg->models.size() <<
"' objects.");
140 if (msg->object_detected) {
155 if (msg->object_detected) {
156 ROS_INFO(
"Proximity sensor triggered.");
161 size_t number_of_valid_ranges = std::count_if(
162 msg->ranges.begin(), msg->ranges.end(), std::isfinite<float>);
163 if (number_of_valid_ranges > 0) {
169 int main(
int argc,
char ** argv) {
171 ros::init(argc, argv,
"gear_example_node");
180 "/ariac/current_score", 10,
185 "/ariac/competition_state", 10,
197 "/ariac/joint_states", 10,
208 "/ariac/break_beam_1_changed", 10,
213 "/ariac/logical_camera_1", 10,
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void start_competition(ros::NodeHandle &node)
Start the competition by waiting for and then calling the start ROS Service.
void proximity_sensor_callback(const osrf_gear::Proximity::ConstPtr &msg)
void publish(const boost::shared_ptr< M > &message) const
void current_score_callback(const std_msgs::Float32::ConstPtr &msg)
Called when a new message is received.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void laser_profiler_callback(const sensor_msgs::LaserScan::ConstPtr &msg)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
void break_beam_callback(const osrf_gear::Proximity::ConstPtr &msg)
Called when a new Proximity message is received.
Example class that can hold state and provide methods that handle incoming data.
std::vector< osrf_gear::Goal > received_goals_
sensor_msgs::JointState current_joint_states_
void logical_camera_callback(const osrf_gear::LogicalCameraImage::ConstPtr &image_msg)
Called when a new LogicalCameraImage message is received.
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
void send_arm_to_zero_state()
Create a JointTrajectory with all positions set to zero, and command the arm.
ros::Publisher joint_trajectory_publisher_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
MyCompetitionClass(ros::NodeHandle &node)
#define ROS_INFO_STREAM(args)
void goal_callback(const osrf_gear::Goal::ConstPtr &goal_msg)
Called when a new Goal message is received.
std::string competition_state_
#define ROS_INFO_THROTTLE(rate,...)
void joint_state_callback(const sensor_msgs::JointState::ConstPtr &joint_state_msg)
Called when a new JointState message is received.
#define ROS_ERROR_STREAM(args)
#define ROS_INFO_STREAM_THROTTLE(rate, args)
void competition_state_callback(const std_msgs::String::ConstPtr &msg)
Called when a new message is received.
int main(int argc, char **argv)