ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

angshumanG's profile - activity

2020-05-03 01:19:02 -0500 received badge  Student (source)
2018-12-18 03:17:19 -0500 received badge  Famous Question (source)
2017-11-14 15:44:02 -0500 received badge  Famous Question (source)
2017-06-30 17:13:18 -0500 received badge  Famous Question (source)
2017-06-16 12:45:20 -0500 commented question ROS installation and usage of nmea_navsat_driver for GPS receiver?

Inside the driver go to this folder : roscd nmea_navsat_driver/scripts/ and then make all the files executable by c

2017-06-03 06:09:46 -0500 received badge  Notable Question (source)
2017-04-15 09:54:20 -0500 received badge  Famous Question (source)
2017-02-27 13:00:55 -0500 commented answer Issue with arduino and ROS after creating a new message

I got it . I was not putting the period after the command

 rosrun rosserial_arduino make_libraries.py .
2017-02-27 12:44:41 -0500 commented answer Issue with arduino and ROS after creating a new message

I am getting the error on running rosrun rosserial_arduino make_libraries.py

make_libraries.py generates the Arduino rosserial library files.  It 
requires the location of your Arduino sketchbook/libraries folder.

rosrun rosserial_arduino make_libraries.py <output_path>
2017-02-27 12:34:38 -0500 received badge  Notable Question (source)
2017-02-26 20:29:36 -0500 received badge  Popular Question (source)
2017-02-25 22:27:47 -0500 asked a question Issue with arduino and ROS after creating a new message

I am getting creation of publisher failed: Checksum does not match I am getting creation of subscriber failed: Checksum does not match

This error comes when we make a new arduino message and then do catkin_make and try to publish without flashing the arduino and changing the MD5.

I was struck at this problem since 1 day as I was trying to edit the MD5 in the header to match the checksum.

Solution:

1)copy the MD5 from the error you get to the header file 2)catkin_make 3)flash the arduino

I am a new user and this is a workaround which i found. if anyone has better solution please suggest

I have put this up in case someone gets struck in the same problem can find the solution

2017-02-15 20:55:09 -0500 answered a question how to install bullet on Indigo in Ubuntu

sudo apt-get install libbullet-dev

2017-02-15 20:15:29 -0500 commented question ROS installation and usage of nmea_navsat_driver for GPS receiver?
2017-02-15 20:14:16 -0500 answered a question Trouble installing nmea_navsat_driver package?
2017-02-03 10:54:52 -0500 received badge  Popular Question (source)
2017-02-03 10:54:52 -0500 received badge  Notable Question (source)
2016-12-02 11:14:57 -0500 received badge  Popular Question (source)
2016-12-01 15:39:05 -0500 asked a question I am getting Time is not intialised error

Error message:

   File "/home/angshuman/catkin_ws/src/barc/src/state_estimation_KinBkMdl_sim.py", line 81, in <module>
    state_estimation()
  File "/home/angshuman/catkin_ws/src/barc/src/state_estimation_KinBkMdl_sim.py", line 56, in state_estimation
    rate        = rospy.Rate(loop_rate)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 59, in __init__
    self.last_time = rospy.rostime.get_rostime()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/rostime.py", line 209, in get_rostime
    raise rospy.exceptions.ROSInitException("time is not initialized. Have you called init_node()?")
rospy.exceptions.ROSInitException: time is not initialized. Have you called init_node()?

My code:

#!/usr/bin/env python

# ---------------------------------------------------------------------------
# Licensing Information: You are free to use or extend these projects for
# education or reserach purposes provided that (1) you retain this notice
# and (2) you provide clear attribution to UC Berkeley, including a link
# to http://barc-project.com
#
# Attibution Information: The barc project ROS code-base was developed
# at UC Berkeley in the Model Predictive Control (MPC) lab by Jon Gonzales
# (jon.gonzales@berkeley.edu). The cloud services integation with ROS was developed
# by Kiet Lam  (kiet.lam@berkeley.edu). The web-server app Dator was
# based on an open source project by Bruce Wootton
#
# The original code is being modified by Angshuman Goswami(agoswam@clemson.edu)
# from Clemson University working in Efficient Mobility via Connectivity
# and Control (EMC2) lab
# ---------------------------------------------------------------------------

import rospy
import time
import os
from sensor_msgs.msg import Imu
from barc.msg import ECU, Encoder, Z_KinBkMdl
from numpy import pi, cos, sin, eye, array, zeros, unwrap
from observers import kinematicLuembergerObserver, ekf
from system_models import f_KinBkMdl, h_KinBkMdl
from tf import transformations
from numpy import unwrap

# input variables [default values]
d_f      = 0         # steering angle [deg]
acc      = 0         # acceleration [m/s]


# ecu command update
def ecu_callback(data):
    global acc, d_f
    acc         = data.motor        # input acceleration
    d_f         = data.servo        # input steering angle

# state estimation node
def state_estimation_sim():

    # initialize node
    rospy.init_node('state_estimation_sim', anonymous=True)
    # topic subscriptions / publications
    rospy.Subscriber('ecu', ECU, ecu_callback)
    state_pub   = rospy.Publisher('state_estimate_sim', Z_KinBkMdl, queue_size = 10)

    # get vehicle dimension parameters
    L_a = 0.125       # distance from CoG to front axel
    L_b = 0.125       # distance from CoG to rear axel
    vhMdl   = (L_a, L_b)

    # set node rate
    loop_rate   = 50
    dt          = 1.0 / loop_rate
    rate        = rospy.Rate(loop_rate)
    t0          = time.time()


    while not rospy.is_shutdown():

        # publish state estimate
        (x, y, psi, v) = z

        # publish information
        state_pub.publish( Z_KinBkMdl(x, y, psi, v) )

        # collect measurements, inputs, system properties
        # collect inputs
        u   = array([ d_f, acc ])
        args = (u,vhMdl,dt)

        # apply EKF and get each state estimate
        z= f_KinBkMdl

        # wait
        rate.sleep()

if __name__ == '__main__':
    try:
       state_estimation_sim()
    except rospy.ROSInterruptException:
        pass
2016-11-22 00:57:46 -0500 received badge  Notable Question (source)
2016-10-06 10:54:49 -0500 received badge  Famous Question (source)
2016-09-29 16:47:55 -0500 received badge  Enthusiast
2016-09-25 20:04:49 -0500 received badge  Popular Question (source)
2016-09-23 21:11:10 -0500 asked a question subcribing and publishing frequency issue for servo motor control with arduino

I am trying to run MPC on Julia and its results (acceleration and steering) I am publishing to a topic. A low level controller then converts it to pwm values for the arduino. Now my problem is the initial few outputs of the MPC has fluctuating frequency due to which I think the servo motor is not working. The servo motor works when it uses constant frequency pwm signals.

rostopic hz /ecu_pwm 
subscribed to [/ecu_pwm]
average rate: 15.874
    min: 0.063s max: 0.063s std dev: 0.00000s window: 2
no new messages
no new messages
average rate: 1.118
    min: 0.063s max: 2.901s std dev: 1.17307s window: 5
average rate: 2.268
    min: 0.045s max: 2.901s std dev: 0.83080s window: 11
average rate: 2.772
    min: 0.045s max: 2.901s std dev: 0.68780s window: 16
average rate: 3.090

How to the stop the topic from publishing or publishing a constant output till the frequency of the MPC stabilizes.

Its just the first 3 -4 runs for ~1 sec which has fluctuating frequency and later on it becomes static.

My code:

#!/usr/bin/env python

# ---------------------------------------------------------------------------
# Licensing Information: You are free to use or extend these projects for
# education or reserach purposes provided that (1) you retain this notice
# and (2) you provide clear attribution to UC Berkeley, including a link
# to http://barc-project.com
#
# Attibution Information: The barc project ROS code-base was developed at UC
# Berkeley in the Model Predictive Control (MPC) lab by Jon Gonzales
# (jon.gonzales@berkeley.edu) and Greg Marcil (grmarcil@berkeley.edu). The cloud
# services integation with ROS was developed by Kiet Lam
# (kiet.lam@berkeley.edu). The web-server app Dator was based on an open source
# project by Bruce Wootton
# The original code is being modified by Angshuman Goswami from Clemson University
# working in Efficient Mobility via Connectivity and Control (EMC2) lab
# ---------------------------------------------------------------------------

# README: This node serves as an outgoing messaging bus from odroid to arduino
# Subscribes: steering and motor commands on 'ecu'
# Publishes: combined ecu commands as 'ecu_pwm'

from rospy import init_node, Subscriber, Publisher, get_param
from rospy import Rate, is_shutdown, ROSInterruptException, spin, on_shutdown
from barc.msg import ECU_raw, ECU
from numpy import pi
import rospy

motor_pwm = 90
servo_pwm = 90
str_ang_max = 35
str_ang_min = -35


def pwm_converter_callback(msg):
    global motor_pwm, servo_pwm, b0
    global str_ang_max, str_ang_min

    # translate from SI units in vehicle model
    # to pwm angle units (i.e. to send command signal to actuators)

    # convert desired steering angle to degrees, saturate based on input limits
    str_ang     = max( min( 180.0/pi*msg.servo, str_ang_max), str_ang_min)
    servo_pwm   = 92.0558 + 1.8194*str_ang  - 0.0104*str_ang**2

    # compute motor command
    FxR         =  float(msg.motor) 
    if FxR == 0:
        motor_pwm = 90.0
    elif FxR > 0:
        motor_pwm   =  FxR/b0 + 95.0
    else:
        motor_pwm = 90.0
    update_arduino()

def neutralize():
    global motor_pwm
    motor_pwm = 90
    servo_pwm = 90
    update_arduino()

def update_arduino():
    global motor_pwm, servo_pwm, ecu_pub
    ecu_cmd = ECU(motor_pwm, servo_pwm)
    ecu_pub.publish(ecu_cmd)

def arduino_interface():
    global ecu_pub, b0

    # launch node, subscribe to motorPWM and servoPWM, publish ecu ...
(more)
2016-07-29 13:51:58 -0500 commented question Publish servo messages on the serial for control of rc car with a arduino

In the code, https://github.com/BARCproject/barc/b... (motorCMD, _) = test_mode(opt, rateHz, t_i)

when I change this to motorCMD = 96, the car doesn't run.

2016-07-29 13:50:49 -0500 commented question Publish servo messages on the serial for control of rc car with a arduino

ok. I am new to to ros and programming in general. https://github.com/BARCproject/barc -this is the link to the project.

2016-07-23 14:36:36 -0500 received badge  Notable Question (source)
2016-07-23 01:36:20 -0500 received badge  Popular Question (source)
2016-07-22 15:38:25 -0500 asked a question Publish servo messages on the serial for control of rc car with a arduino

I am trying to subscribe to messages which is being published on a topic (/ecu ) which has the steering and the servo input. I am getting an error [WARN] [WallTime: 1469219387.121113] Serial Port read returned short (expected 8 bytes, received 4 instead). [WARN] [WallTime: 1469219387.121657] Serial Port read failure: my code for publishing to the topic /ecu is :

import rospy
from barc.msg import ECU

def main_auto():
    # initialize ROS node
    rospy.init_node('auto_mode', anonymous=True)
    nh = rospy.Publisher('ecu', ECU, queue_size = 10)
    # set node rate
    rateHz  = 50
    dt      = 1.0 / rateHz
    rate    = rospy.Rate(rateHz)
    t_i     = 0


    # main loop
    while not rospy.is_shutdown():
        # get steering wheel command
        servoCMD = 96.0
        motorCMD = 92.0

    # send command signal
        ecu_cmd = ECU(motorCMD, servoCMD)
        nh.publish(ecu_cmd)

        # wait
        t_i += 1
        rate.sleep()

#############################################################
if __name__ == '__main__':
    try:

        main_auto()
    except rospy.ROSInterruptException:
        pass

the arduino code i have used it from the open source BARC-project

/* ---------------------------------------------------------------------------
# Licensing Information: You are free to use or extend these projects for
# education or reserach purposes provided that (1) you retain this notice
# and (2) you provide clear attribution to UC Berkeley, including a link
# to http://barc-project.com
#
# Attibution Information: The barc project ROS code-base was developed
# at UC Berkeley in the Model Predictive Control (MPC) lab by Jon Gonzales
# (jon.gonzales@berkeley.edu)  Development of the web-server app Dator was
# based on an open source project by Bruce Wootton, with contributions from
# Kiet Lam (kiet.lam@berkeley.edu). The RC Input code was based on sample code
# from http://rcarduino.blogspot.com/2012/04/how-to-read-multiple-rc-channels-draft.html
# --------------------------------------------------------------------------- */


/* ---------------------------------------------------------------------------
WARNING:
* Be sure to have all ultrasound sensors plugged in, otherwise the pins may get stuck in
  some float voltage
# --------------------------------------------------------------------------- */

// include libraries
#include <ros.h>
#include <barc/Ultrasound.h>
#include <barc/Encoder.h>
#include <barc/ECU.h>
#include <Servo.h>
#include "Maxbotix.h"
#include <EnableInterrupt.h>

/**************************************************************************
CAR CLASS DEFINITION (would like to refactor into car.cpp and car.h but can't figure out arduino build process so far)
**************************************************************************/
class Car {
  public:
    void initEncoders();
    void initRCInput();
    void initActuators();
    void armActuators();
    void writeToActuators(const barc::ECU& ecu);
    // Used for copying variables shared with interrupts to avoid read/write
    // conflicts later
    void readAndCopyInputs();
    // Getters
    uint8_t getRCThrottle();
    uint8_t getRCSteering();
    int getEncoderFL();
    int getEncoderFR();
    int getEncoderBL();
    int getEncoderBR();
    // Interrupt service routines
    void incFR();
    void incFL();
    void incBR();
    void incBL();
    void calcThrottle();
    void calcSteering();
  private:
    // Pin assignments
    const int ENC_FL_PIN = 2;
    const int ENC_FR_PIN = 3;
    const int ENC_BL_PIN = 5;
    const int ENC_BR_PIN = 6;
    const int THROTTLE_PIN = 7;
    const int STEERING_PIN = 8;
    const int MOTOR_PIN = 10;
    const int SERVO_PIN= 11;

    // Car properties
    // unclear what this is for
    const int noAction = 0;

    // Motor limits
    // TODO are these the real limits?
    const int MOTOR_MAX = 120;
    const int MOTOR_MIN = 40;
    const int MOTOR_NEUTRAL = 90;
    // Optional: smaller values for testing safety
    /* const int MOTOR_MAX = 100; */
    /* const int MOTOR_MIN = 75; */

    // Steering limits
    // TODO seems to me that the permissible steering range is really about [58,
    // 120] judging from the sound of the servo pushing beyond a mechanical limit
    // outside that range. The ...
(more)
2016-07-19 19:43:07 -0500 commented question Logging multiple-ultrasound data on a MySQL server with (arduino-ROS-Python) framework

i am getting error : NameError: global name 'FL' is not defined

2016-07-19 19:41:50 -0500 received badge  Editor (source)
2016-07-19 19:21:16 -0500 asked a question Logging multiple-ultrasound data on a MySQL server with (arduino-ROS-Python) framework

I am trying to log the ultrasonic data from a RC car into a MySQL server. I am able to publish and subscribe to the data via rostopic. But I am having problem with the code for uploading the data which is being subscribed. I have 4 sensors published to 4 topics /ultrasoundFL,/ultrasoundFR,/ultrasoundRL,/ultrasoundRR.

import rospy
#from std_msgs.msg import String
from sensor_msgs.msg import Range
import os
from time import *
import time
import threading
import serial
import datetime
import sys
import MySQLdb as mdb
try:
  con = mdb.connect('130.127.199.212', 'root', 'Fr24clemson', 'autonomous');
  cur = con.cursor()
except:
    print "Error opening serial port."
    sys.exit(1)

    resp = ""
droptable="DROP TABLE autonomous.ultrasonic_sensor_data"
cur.execute(droptable)
createtable="CREATE TABLE autonomous.ultrasonic_sensor_data (n_FL DOUBLE NULL  ,w_FR DOUBLE NULL,n_RL DOUBLE NULL  ,w_RR DOUBLE NULL,t_unixtime DOUBLE NULL,t_time TIMESTAMP)"
cur.execute(createtable)

try:
      def ultrasoundFL_callback(data):
          FL=float(data.range)
      def ultrasoundFR_callback(data):
          FR=float(data.range)
      def ultrasoundRL_callback(data):
          RL=float(data.range)
      def ultrasoundRR_callback(data):
          RR=float(data.range)
          unixtime=datetime.datetime.now().strftime("%s")
          sql = "insert into ultrasonic_sensor_data(n_FL, w_FR, n_RL, w_RR,  t_unixtime) values(%s, %s, %s, %s, %s)" % (FL,FR,RL,RR, unixtime)
          print sql
          cur.execute(sql)
          print "Rows inserted: %s" % cur.rowcount
          con.commit()
          #time.sleep(1)#set to whatever
          resp = ""
except:
        print sys.exc_info()[0]
def listener():
    from sensor_msgs.msg import Range
    rospy.init_node('serial', anonymous=True)
    rospy.Subscriber("ultrasoundFL", Range, ultrasoundFL_callback)
    print ("a")
    rospy.Subscriber("ultrasoundFR", Range, ultrasoundFR_callback)
    print ("b")
    rospy.Subscriber("ultrasoundRL", Range, ultrasoundRL_callback)
    print ("c")
    rospy.Subscriber("ultrasoundRR", Range, ultrasoundRR_callback)
    print ("c")
    rospy.spin()

if __name__=='__main__':
    listener()

I am getting this error: [ERROR] [WallTime: 1468975143.127478] bad callback: <function ultrasoundrr_callback="" at="" 0xb660010c=""> Traceback (most recent call last): File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 720, in _invoke_callback cb(msg) File "arduino_python_ros_sonar.py", line 36, in ultrasoundRR_callback sql = "insert into ultrasonic_sensor_data(n_FL, w_FR, n_RL, w_RR, t_unixtime) values(%s, %s, %s, %s, %s)" % (FL,FR,RL,RR, unixtime) NameError: global name 'FL' is not defined