 /*define channel enable output pins*/
 int ENA=5;
 int ENB=11;
+int ABS = 100;
 
-void moveRobot(const std_msgs::UInt8& msg)
+void move_robot(const std_msgs::UInt8& msg)
 { 
   switch(msg.data)
   {
    case 0:
    {
-     digitalWrite(ENA,HIGH);
-     digitalWrite(ENB,HIGH);
+     analogWrite(ENA,ABS);
+     analogWrite(ENB,ABS);
+     digitalWrite(in1,LOW);
+     digitalWrite(in2,HIGH);
+     digitalWrite(in3,HIGH);
+     digitalWrite(in4,LOW);
+     
+     nh.logdebug("Moving forward");
+     break;
+   }
+   case 1:
+   { 
+     analogWrite(ENA,ABS);
+     analogWrite(ENB,ABS);
      digitalWrite(in1,HIGH);
      digitalWrite(in2,LOW);
      digitalWrite(in3,LOW);
      digitalWrite(in4,HIGH);
      
-     nh.logdebug("Moving forward");
-     break;
-   }
-   case 1:
-   {
-     digitalWrite(ENA,HIGH);
-     digitalWrite(ENB,HIGH);
-     digitalWrite(in1,LOW);
-     digitalWrite(in2,HIGH);
-     digitalWrite(in3,HIGH);
-     digitalWrite(in4,LOW);
-  
      nh.logdebug("Moving back");
      break;
    } 
    case 2:
    {
-     digitalWrite(ENA,HIGH);
-     digitalWrite(ENB,HIGH);
+     analogWrite(ENA,ABS);
+     analogWrite(ENB,ABS);
      digitalWrite(in1,HIGH);
      digitalWrite(in2,LOW);
      digitalWrite(in3,HIGH);

#include <ros.h>
#include <std_msgs/UInt8.h>

ros::NodeHandle nh;

/*define logic control output pin*/
int in1=6;
int in2=7;
int in3=8;

  } 
}

int get_distance()   
{
  digitalWrite(Trig, LOW);   
  delayMicroseconds(2);
  digitalWrite(Trig, HIGH);  
  delayMicroseconds(20);
  digitalWrite(Trig, LOW);   
  
  float distance = pulseIn(Echo, HIGH);  
  distance= distance/58; 
  
  return (int)distance;
}  

ros::Subscriber<std_msgs::UInt8> steering_subscriber("robot_car_steering", &move_robot);

std_msgs::Int16 ultrasonic_sensor_message;
ros::Publisher ultrasonic_sensor_publisher("robot_car_ultrasonic_sensor", &ultrasonic_sensor_message);

void setup() 
{
