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

Sood's profile - activity

2016-06-28 08:10:30 -0500 received badge  Famous Question (source)
2016-06-15 07:10:56 -0500 received badge  Famous Question (source)
2016-05-22 13:54:26 -0500 commented answer Multiple subscribers and single publisher in one python script?

Great! Did I answer your question successfully? Does it work now?

2016-04-20 10:38:27 -0500 commented question catkin tools command not found

try doing source /opt/ros/indigo/setup.bash

2016-04-20 10:37:43 -0500 answered a question catkin tools command not found

try doing

source /opt/ros/indigo/setup.bash

2016-04-20 09:51:28 -0500 answered a question Multiple subscribers and single publisher in one python script?

As suggested why don't you use a class and some flags


#!/usr/bin/env python

import rospy
from geometry_msgs.msg import Twist
from geometry_msgs.msg import Vector3Stamped
from geometry_msgs.msg import Vector3

from math import radians
from sensor_msgs.msg import NavSatFix
import time
import numpy

global lat1
global long1

Class Foo: 

def call_head(um6):
    z = um6.vector.z
    y = um6.vector.y

    self.angles = Vector3()

    self.heading = numpy.rad2deg(numpy.arctan2(z, y)) + 90

    self.angles.x = self.heading
    self.angles.z = self.bearing

    self.send_bear_ = True
    return "done heading"


def call_nav(navsat):


    self.angles = Vector3()

    self.lat1 = navsat.latitude
    self.long1 = navsat.longitude

    dLon = self.long2 - self.long1
    y = numpy.sin(dLon) * numpy.cos(self.lat2)
    x = numpy.cos(lat1)*numpy.sin(self.lat2) - numpy.sin(self.lat1)*numpy.cos(self.lat2)*numpy.cos(dLon)

    self.bearing = (numpy.rad2deg(numpy.arctan2(y, x)) + 360) % 360

    self.angles.z = self.bearing

    self.send_nav_ = True

    return "done bearing"

def call_move(data):

    move_cmd = Twist()
    turn_cmd = Twist()



    move_cmd.linear.x = 2
    turn_cmd.angular.z = radians(45)

    self.heading = data.z
    self.bearing = data.x


    turn_angle = self.heading - self.bearing

    rospy.loginfo("bearing: %s", self.bearing)
    rospy.loginfo("heading: %s", self.heading)


    if (turn_angle > 180):
        turn_angle -= 360
    elif (turn_angle < -180):
        turn_angle += 360
    else:
        turn_angle = turn_angle

    if (abs(self.lat1-self.lat2)<.0005 and abs(self.long1-self.long2)<.0005):
        self.pub_msg = Twist()
    else:
        if (abs(turn_angle) < 8):
            self.pub_msg = move_cmd
        else:
            self.pub_msg = turn_cmd
    self.send_msg_ = True
    return "done move"      



def __init__(self):

    self.pub_msg = Twist()
    self.heading = #someinit val
    self.bearing = #someinit val
    self.send_msg_ = False
    self.send_bear_ = False
    self.send_ = False
    self.angles = Vector3()
    self.lat1 = #someinit val
    self.lat2 = #someinit val
    ###########################################################
    self.lat2 = 30.210406
    #                                   Destination
    self.long2 = -92.022914
    ############################################################

    rospy.Subscriber("/imu_um6/mag", Vector3Stamped, self.call_head)
    rospy.Subscriber("/gps/fix", NavSatFix, self.call_nav)
    rospy.Subscriber("navStuff", Vector3, self.call_move)
    pub = rospy.Publisher('/husky_velocity_controller/cmd_vel', Twist, queue_size=10)
    call_bear_pub = rospy.Publisher("navStuff", Vector3, queue_size=10)
    call_nav_pub = rospy.Publisher("navStuff", Vector3, queue_size=10)
    while not rospy.is_shutdown():
        if self.send_msg_:
            pub.publish(self.pub_msg)
            self.send_msg_ = False
        if self.send_bear_:
            call_bear_pub.publish(self.angles)
            self.send_bear_ = False
        if self.send_nav_:
            call_nav_pub.publish(self.angles)
            self.send_nav_ = False

if __name__ == '__main__': rospy.init_node('navigate_that_husky') try: foo = Foo() except rospy.ROSInterruptException: pass

Basically once you are receive the message the flag gets set and you can send it on the publisher. If you want them all together simply make sure that all must be true at the same time.

This should take care of timing issues. It did for me.

Sorry for the poor formatting I'm in a hurry.

2016-04-20 08:58:44 -0500 answered a question Reuse camera calibration parameters?

Thought I'd answer my own question because I figured a way to do it.

Once you have calibrated your camera and clicked the save and commit button you will find a file

/tmp/calibrationdata.tar.gz

Copy it to some location and then extract it as

tar -xzf calibrationdata.tar.gz

You will get a left.yaml and right.yaml file. If not use this to get the files.

Once that's done you will need a launch file that looks something like this

<group ns="stereo">

  <node pkg="uvc_camera" type="uvc_stereo_node" name="uvc_camera_stereo">

    <param name="width" type="int" value="640" />
    <param name="height" type="int" value="480" />
    <param name="fps" type="int" value="30" />
    <param name="frame" type="string" value="wide_stereo" />

    <param name="auto_focus" type="bool" value="False" />
    <param name="focus_absolute" type="int" value="0" />
    <!-- other supported params: auto_exposure, exposure_absolute, brightness, power_line_frequency -->

    <param name="left/device" type="string" value="/dev/video1" />
    <param name="right/device" type="string" value="/dev/video2" />
    <param name="left/camera_info_url" type="string" value="file://$(find ksas)/cameracalibration/left.yaml" />
    <param name="right/camera_info_url" type="string" value="file://$(find ksas)/cameracalibration/right.yaml" />
  </node>
</group>

Note:

ksas

is the name of the package I have written.

2016-04-20 08:26:12 -0500 received badge  Enthusiast
2016-04-19 14:23:01 -0500 received badge  Notable Question (source)
2016-04-11 11:12:02 -0500 received badge  Popular Question (source)
2016-04-10 22:55:10 -0500 commented question Reuse camera calibration parameters?

The usb_cam driver.

2016-04-10 13:44:40 -0500 asked a question Reuse camera calibration parameters?

I am using a stereo camera set up which I need to recalibrate every time I want to use it. Is there anyway to save the best camera calibraiton parameters I got and just reuse them?

It would probably only work under the assumption that the camera's do not change in orientation with respect to each other, which is fairly trivial to do.

2016-04-10 07:59:06 -0500 commented question Error in verifying & uploading File/Examples/ros_lib/HelloWorld in Arduino IDE

Inside ros_lib folder, the file ArduinoHardware.h has a line

#include "WProgram.h"

replace that with

#include "Arduino.h"

2016-04-10 06:42:33 -0500 commented answer ros/node_handle.h No such file ERROR in Arduino 'hellow world' tutorial

Hasitha could you tell me what permissions you used to get it to run? I am having the same problem.

2016-04-07 21:51:58 -0500 received badge  Notable Question (source)
2016-04-01 04:33:05 -0500 received badge  Popular Question (source)
2016-03-25 12:33:00 -0500 commented answer Running two nodes for two webcams with usb_cam

Thank you so much. I'm new to ROS and I missed things which should be obvious.

2016-03-25 12:32:29 -0500 received badge  Scholar (source)
2016-03-25 11:22:33 -0500 asked a question Running two nodes for two webcams with usb_cam

I'm trying to run two different webcams. What I understood was I need to create two different nodes and set the parameters differently to run them. Both are Logitech C270 cameras.

What I did was copy the usb_cam_node.cpp file to usb_cam_node1.cpp and usb_cam_node2.cpp. I then run them as follows:

rosrun usb_cam usb_cam_node1 _video_device:=/dev/video1 _camera_name:=cam1
rosrun usb_cam usb_cam_node2 _video_device:=/dev/video2 _camera_name:=cam2

I added executables to the CMakeList.txt as follows:

add_executable(${PROJECT_NAME}_node1 nodes/usb_cam_node1.cpp) add_executable(${PROJECT_NAME}_node2 nodes/usb_cam_node2.cpp)

target_link_libraries(${PROJECT_NAME}_node1
${PROJECT_NAME}
${avcodec_LIBRARIES}
${swscale_LIBRARIES}
${catkin_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}_node2
${PROJECT_NAME}
${avcodec_LIBRARIES}
${swscale_LIBRARIES}
${catkin_LIBRARIES}
)

However every time I execute one after the other, I get the following error.

[ WARN] [1458914475.903122037]: Shutdown request received.
[ WARN] [1458914475.903222764]: Reason given for shutdown: [new node registered with same name]

Quite obviously the nodes are different. Not sure what's going wrong.

2016-03-24 09:47:49 -0500 received badge  Supporter (source)