#include <ros/ros.h>
#include <cmath>
#include <string>
#include <std_msgs/Float32.h>
#include <std_msgs/Bool.h>
#include <std_msgs/String.h>
#include <Grijper/command.h>
Go to the source code of this file.
Functions | |
bool | close_gripper (float distance) |
Small evaluation method to see if the gripper should be closed. More... | |
void | gripperCommand (const std_msgs::String::ConstPtr &msg) |
Method for evaluating and executing commands received from the console. More... | |
void | gripperPhidget (const std_msgs::Float32::ConstPtr &msg) |
Method that evaluates the phidget sensor values and takes appropriate action. More... | |
int | main (int argc, char **argv) |
Main method of the controller node. All incoming messages are analysed and commands are sent from this node. More... | |
bool | open_gripper (float distance) |
Small evaluation method to see if the gripper should be opened. More... | |
void | setForce (const std_msgs::Float32::ConstPtr &msg) |
Method for setting the force on message receiving. More... | |
void | shutdown (const std_msgs::Bool::ConstPtr &b) |
Controll method to shutdown this ROS node when the command is given. More... | |
Variables | |
ros::Publisher | control |
float | force = 0.35 |
bool | force_open = false |
bool | gripper_open = true |
float | last_distance = 0 |
bool close_gripper | ( | float | distance | ) |
Small evaluation method to see if the gripper should be closed.
Compares the distance value to a threshold value to see if the gripper should be closed.
distance | The distance to be evaluated. |
Definition at line 149 of file gripper_controller.cpp.
void gripperCommand | ( | const std_msgs::String::ConstPtr & | msg | ) |
Method for evaluating and executing commands received from the console.
This method is called for every console command that is received. The message parameter contains a string describing the command. When a command is received a Grijper::command is created to give the controller command to the actuator. This command contains a 'cmd' string describing the command and (if applicable) a 'force' float containing the target force.
msg | The message containing the command string |
Definition at line 113 of file gripper_controller.cpp.
void gripperPhidget | ( | const std_msgs::Float32::ConstPtr & | msg | ) |
Method that evaluates the phidget sensor values and takes appropriate action.
This method is called every time the phidget passes on a value, extracting the distance (by using sensorToDistance(int)). Once the distance has been calculated the value is compared to thresholds and a command is given to the actuator.
If the gripper was forced open, and the gripper should close due to proximity of an object, the force_open value is reset to false.
msg | The message containing the Phidget sensor value. |
Definition at line 57 of file gripper_controller.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main method of the controller node. All incoming messages are analysed and commands are sent from this node.
This node listens to commands given from the console, but also evaluates the values passed on from the phidget reader. It evaluates the console commands and if needed passes them on to the actuator node. Otherwise is extracts the distance from the sensor value and compares it to the threshold values to open (using open()) and close (using close()) the gripper. If the command is received to alter the target force, that is set and used in future commands to the actuator.
This node also listens to the shutdown command from the console, and executes shutdown()
Definition at line 33 of file gripper_controller.cpp.
bool open_gripper | ( | float | distance | ) |
Small evaluation method to see if the gripper should be opened.
Compares the distance value to a threshold value to see if the gripper should be opened.
distance | The distance to be evaluated. |
Definition at line 161 of file gripper_controller.cpp.
void setForce | ( | const std_msgs::Float32::ConstPtr & | msg | ) |
Method for setting the force on message receiving.
This method is called when the message for setting the force is received. This new value is then set in force and will be used in future commands.
msg | The message containing the new target force value. |
Definition at line 98 of file gripper_controller.cpp.
void shutdown | ( | const std_msgs::Bool::ConstPtr & | b | ) |
Controll method to shutdown this ROS node when the command is given.
This method will shutdown this node when the command is given by the console.
b | The message containing the command. Nothing is done with the command since we know what it will be when this message is received. |
ros::Publisher control |
Controller message publisher.
Definition at line 15 of file gripper_controller.cpp.
float force = 0.35 |
Force variable, is set by default to 0.35 and listens to the console.
Definition at line 21 of file gripper_controller.cpp.
bool force_open = false |
Force open state variable.
Definition at line 19 of file gripper_controller.cpp.
bool gripper_open = true |
Gripper state variable.
Definition at line 18 of file gripper_controller.cpp.
float last_distance = 0 |
Last sensor value, used for filtering and smoothing.
Definition at line 20 of file gripper_controller.cpp.