Ask Your Question

jetman's profile - activity

2020-01-20 22:03:27 -0600 received badge  Famous Question (source)
2019-12-04 16:40:35 -0600 received badge  Notable Question (source)
2019-09-10 03:10:27 -0600 received badge  Famous Question (source)
2019-08-26 15:16:39 -0600 received badge  Popular Question (source)
2019-07-25 01:04:01 -0600 asked a question How to Dashing action client cancel goal

How to Dashing action client cancel goal I try minimal_action_client of exsamples package.Using distribution is ROS2 Das

2019-07-25 00:37:01 -0600 received badge  Famous Question (source)
2019-05-06 06:21:23 -0600 received badge  Notable Question (source)
2019-02-12 19:09:26 -0600 received badge  Famous Question (source)
2019-02-12 19:09:26 -0600 received badge  Notable Question (source)
2019-02-12 19:09:26 -0600 received badge  Popular Question (source)
2019-02-01 04:02:52 -0600 received badge  Student (source)
2019-02-01 04:01:24 -0600 received badge  Popular Question (source)
2019-01-31 08:29:19 -0600 asked a question Moveit! UR5 goal pose different

Moveit! UR5 goal pose different I am using Moveit and UR 5 using the Python Interface in the following environment. Ubu

2018-11-25 23:58:55 -0600 asked a question How to measure distance with realsense

How to measure distance with realsense I use realsense ROS wrapper from https://github.com/intel-ros/realsense . I want

2018-11-16 00:27:33 -0600 received badge  Enthusiast
2018-11-09 02:19:53 -0600 received badge  Notable Question (source)
2018-11-08 21:07:13 -0600 marked best answer ros2 run ImportError

Hi! I am working with ROS2 Bouncy, using colcon to build.

ROS2 build is successful. I create new package using Python3.5 I write setup.py, package.xml,setup.cfg and colcon build successful.But I run the package using ros2 run, Importerror: module 'module name' has no attribute 'main'.

Package referred ROS2 examples/rclpy/topic/mimimal_publisher

setup.py is:

from setuptools import setup

package_name = 'test_my_module'

setup(
    name=package_name,
    version='0.0.1',
    packages=[],
    py_modules=[
        'my_module'],
    install_requires=['setuptools'],
    zip_safe=True,
    author='name',
    author_email='mail',
    maintainer='name',
    maintainer_email='mail',
    keywords=['ROS'],
    classifiers=[
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python',
        'Topic :: Software Development',
    ],
    description='test my module.',
    license='Apache License, Version 2.0',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'my_module = my_module:main',
        ],
    },
)

my_module is:

import rclpy
from rclpy.node import Node
from std_msgs.msg import String


class TestPulisher(Node):

    def __init__(self):
        super().__init__('test_pubrisher')
        self.publisher1 = self.create_publisher(String, 'topic1')      
        time_period = 0.5
        self.timer = self.create_timer(timer_period,self.timer_callback)
        self.i = 0

    def timer_callback(self):
        msg1 = String()
        msg1.data = 'Hello World: %d' % self.i
        self.publisher1_.publish(msg1)
        self.get_logger().info('Publisher1: "%s"' % msg1.data)
        self.i += 1

    def main(args=None):
        rclpy.init(args=args)
        test_publisher = TestPulisher()
        rclpy.spin(test_publisher)

if __name__ == '__main__':
    main()

Error message when running my_module:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2351, in resolve
    return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'my_module' has no attribute 'main'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/main/ros2_ws/install/test_my_module/lib/test_my_module/my_module", line 11, in <module>
    load_entry_point('test-my-module', 'console_scripts', 'my_module')()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 484, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2725, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2343, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2353, in resolve
    raise ImportError(str(exc))
ImportError: module 'my_module' has no attribute 'main'
2018-11-08 21:07:13 -0600 received badge  Scholar (source)
2018-11-08 21:07:11 -0600 commented answer ros2 run ImportError

Thank you for answering! A little mistake of python script. def main fixed,it works

2018-11-08 20:37:05 -0600 received badge  Popular Question (source)
2018-11-08 19:32:18 -0600 edited question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p

2018-11-08 19:31:49 -0600 edited question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p

2018-11-08 19:30:41 -0600 commented question ros2 run ImportError

Thank you for the advice! I write if __name__ == '__main__': in my_module. Error message when my_module running and sc

2018-11-08 19:30:23 -0600 edited question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p

2018-11-08 19:27:00 -0600 edited question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p

2018-11-08 19:27:00 -0600 received badge  Editor (source)
2018-11-08 19:26:04 -0600 edited question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p

2018-11-08 03:39:24 -0600 asked a question ros2 run ImportError

ros2 run ImportError Hi! I am working with ROS2 Bouncy, using colcon to build. ROS2 build is successful. I create new p