62 #ifndef _LASER_ROTATE3D_H_
63 #define _LASER_ROTATE3D_H_
65 #define deg2rad 0.017453293 //change this to a standard ros function
66 #define pulse2rad 0.003067962 // convert encoder pulses to radian
67 #define deg2pulse 5.689 //2048/360
69 using namespace serialcom;
102 char command2send[8];
119 bool SetPosition(
int desiredposition);
120 bool SetSpeed(
int desiredrpm);
122 void SetJointState(
const sensor_msgs::JointState::ConstPtr& set_joint_state);
124 void ReadLinesSerialPort(boost::function<
void(std::string*)> f);
125 void RotateLaserCallback(std::string* readdata);
156 std::cout<<
"Param port: "<<
port_name_<<std::endl;
165 ROS_INFO(
"sent to home");
179 #if ROS_VERSION_MINIMUM(1, 8, 0)
190 printf(
"remap=%s\n", (ros::names::remap(
"state")).c_str());
223 if (set_joint_state->velocity.size()==0)
225 ROS_WARN(
"LASER3D VELOCITY REQUEST 0");
226 int position_request = (int)set_joint_state->position[0];
227 int speed_request = (
int)set_joint_state->velocity[0];
231 ROS_INFO(
"Setting a new position");
237 int position_request = (int)set_joint_state->position[0];
238 int speed_request = (
int)set_joint_state->velocity[0];
240 ROS_INFO(
"Setting a new speed");
255 if ((desiredposition>359) | (desiredposition<0))
257 ROS_WARN(
"Demanded position is in integer degrees range {0,...,359}.");
261 if(desiredposition==0)
275 desiredposition = round(desiredposition*
deg2pulse);
295 if ((desiredrpm>19) & (desiredrpm<100))
308 ROS_WARN(
"Demanded speed is in integer rpm range {20,...,99}.");
323 ROS_WARN (
"Error writing the command!");
338 startReadLineStream(f);
359 #if ROS_VERSION_MINIMUM(1, 8, 0)
376 ROS_INFO(
"no data available to publish %s\n",
"");
390 thesize = readdata->size();
410 aux=sscanf(readdata->c_str(),
"%*c %s %*c %s\n",Pos,Vel);
bool SetPosition(int desiredposition)
SetPosition set the external angular position of the laser.
boost::mutex want2publish_mutex
bool SendCommand()
SendCommand send a command to the PIC controlling the stepper motor.
void RotateLaserCallback(std::string *readdata)
void ReadLinesSerialPort(boost::function< void(std::string *)> f)
ReadLinesSerialPort thread to read from the serial port, inherited from SerialCom.
bool SetSpeed(int desiredrpm)
SetSpeed set the external angular velocity of the laser.
int previous_speed_request
tf::Transform Transform2Laser
int previous_position_request
ros::Subscriber RotateLaser_sub
void SetJointState(const sensor_msgs::JointState::ConstPtr &set_joint_state)
SetJointState selects setting the angular position or rate for the external LM200 joint calls SetSpee...
sensor_msgs::JointState joint_state
boost::function< void(std::string *)> BoostRotateLaserCallback
ros::Publisher RotateLaser_pub
ros::NodeHandle RotateLaser_nh
tf::TransformBroadcaster TransfBroadcaster
class implements a gateway to communicate with the PIC to rotate the LMS200
void Publish()
Publish mutex protected publish.