import rospy when calling a python script from a c++ executable
I have a Robai Cyton gamma arm that I'm attempting to connect to with ROS by trying to call a Python script from a C++ program.
What I want to do is use C++ and OpenCV to get a video from an Xbox Kinect. From the kinect video I want to be able to click on a point in the image and send the x-y-z position (after converting them to my robot coordinate system) to a Python Script using OpenRave to figure out the inverse kinematics. After the position of my joint angles are known I want to use ROS to send them to the robot.
Currently, I can send the x-y-z locations and find the inverse kinematics no problem and everything works together nicely when I don't have import rospy in my python script(not trying to send the robot my joint angles). I also can move the robot with a different python script I have so I know I can connect with and move it.
Without the ROS commands to try to publish to the robot when I run the c++ exe I get the joint angles for the different links of my robot.
getIndicesFromJointNames [0] ['link1']
[ 1. 0.78545125 0.62655888 0.96602943 1.01751733 1.06180138
-0.7132951 ]
When I add the command
import rospy
and subsequently try to publish them to the robot
> rospy.init_node('shoulder_roll')
> ...
> ...
pub = rospy.Publisher('/theta_2/command', Float64)
pub.publish(Float64(sol.item(1)))
pub = rospy.Publisher('/theta_3/command', Float64)
pub.publish(Float64(sol.item(2)*-1))
pub = rospy.Publisher('/theta_4/command', Float64)
pub.publish(Float64(sol.item(3)))
I get the error
Traceback (most recent call last):
File "/home/nick/fuerte_workspace/Robai/bin/test.py", line 22, in run
import rospy
File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>
from .client import spin, myargv, init_node, \
File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/client.py", line 53, in <module>
import rospy.core
File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/core.py", line 66, in <module>
from rospy.names import *
File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/names.py", line 86, in <module>
_mappings = load_mappings(sys.argv)
AttributeError: 'module' object has no attribute 'argv'
Any help or suggestions would be appreciated
Thanks, Nick
Hi Nick, Did you make any progress on this issue? I'm asking, because I'm receiving the same error while importing rospy in a c++ class. I've already looked into the names.py but the load_mappings object has an 'argv' attribute, so the error-message is kind of misguiding me. Kind regards, Tobi