Ask Your Question
0

how to stop abb rbot when sensor values reaches a particular limit

asked 2016-11-08 11:00:54 -0500

anadgopi1994 gravatar image

updated 2016-11-08 12:13:28 -0500

gvdhoorn gravatar image

i am using abb 2400 model which can do path planning. i wrote a node which can read ultrasonic sensor values and it displays a marker according to the sensor value.The robot is executing a plan continously .I want to stop the robot when sensor value reaches a particular value. By using state_display_time we can do this in rviz explicitly. How to automatically do this , what changes need to be made in the node i have written.

The code is,

#include <ros/ros.h>
   #include <visualization_msgs/Marker.h>
   #include "sensor_msgs/Range.h"
#include "std_msgs/Bool.h"
#include "planning_display.h"
 //#include <arm_navigation_msgs/DisplayTrajectory.h>



 #include <map>

float range=1 ;
float t=1;
//range=1000;
int i=1;
void rangeCallback(const sensor_msgs::Range::ConstPtr& range_data)
{

  range = range_data->range;
 ROS_INFO("I heard: [%f]", range);
ros::NodeHandle n;
     ros::Rate r(1);
    ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 1);


 // Set our initial shape type to be a cube
     uint32_t shape = visualization_msgs::Marker::CUBE;



     while (ros::ok())
     {
     // ros::Subscriber sub = n.subscribe("range_data", 9600,rangeCallback);   
visualization_msgs::Marker marker;
       // Set the frame ID and timestamp.  See the TF tutorials for information on these.
       marker.header.frame_id = "/base_link";
       marker.header.stamp = ros::Time::now();

       // Set the namespace and id for this marker.  This serves to create a unique ID
     // Any marker sent with the same namespace and id will overwrite the old one
       marker.ns = "basic_shapes";
       marker.id = 0;

       // Set the marker type.  Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER
       //marker.type = shape;
   marker.type = visualization_msgs::Marker::CYLINDER;
       // Set the marker action.  Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL)
     marker.action = visualization_msgs::Marker::ADD;
       // Set the pose of the marker.  This is a full 6DOF pose relative to the frame/time specified in the header

       marker.pose.position.x =range; //TO MOVE MARKER
       marker.pose.position.y = 0;
       marker.pose.position.z = 1;  
       marker.pose.orientation.x = 0.0;
       marker.pose.orientation.y = 0.0;
       marker.pose.orientation.z = 0.0;
       marker.pose.orientation.w = 1.0;

       // Set the scale of the marker -- 1x1x1 here means 1m on a side
       marker.scale.x = 2.0;
       marker.scale.y = 2.0;
       marker.scale.z = 2.0;

       // Set the color -- be sure to set alpha to something non-zero!

       marker.color.r = 0.20f;
       marker.color.g = 0.3f;
       marker.color.b = 0.2f;
       marker.color.a = 1;

       marker.lifetime = ros::Duration();

       // Publish the marker
       while (marker_pub.getNumSubscribers() < 1)
       {
         if (!ros::ok())
         {
           return ;
         }
        // ROS_WARN_ONCE("Please create a subscriber to the marker");

sleep(1);
       }
       marker_pub.publish(marker);

       // Cycle between different shapes
       /*switch (4)
       {
       case visualization_msgs::Marker::CUBE:
         shape = visualization_msgs::Marker::SPHERE;
        break;
      case visualization_msgs::Marker::SPHERE:
        shape = visualization_msgs::Marker::ARROW;
        break;
      case visualization_msgs::Marker::ARROW:
        shape = visualization_msgs::Marker::CYLINDER;
        break;
      case visualization_msgs::Marker::CYLINDER:*/
       //shape = visualization_msgs::Marker::CYLINDER;
      // break;
      //}

ros::spin();

   }


}
   int main( int argc, char** argv )
   {
    ros::init(argc, argv, "basic_shapes");
     ros::NodeHandle n;
     ros::Rate r(1);
    //ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 1 ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-11-09 08:54:04 -0500

Sending an empty trajectory should cause the robot to stop.

edit flag offensive delete link more
0

answered 2016-11-09 08:15:43 -0500

rbbg gravatar image

The move_group interface offers a stop function (described here in the API) that can cancel the execution of a path. I suppose this only works whenever the move_group is the one actually executing the path, but I haven't tested it.

edit flag offensive delete link more

Comments

I used stop() function.But it is not stopping a currently executing path in the middle. How can i stop execution in the middle

anadgopi1994 gravatar imageanadgopi1994 ( 2016-11-24 21:57:31 -0500 )edit

Hey, did you manage to stop it? I'm trying to do the same but with Panda from Franka Emika.

hpoleselo gravatar imagehpoleselo ( 2018-11-05 05:53:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-11-08 11:00:54 -0500

Seen: 306 times

Last updated: Nov 09 '16