Comments (12)
Hello, it seems a problem in your gzserver launch file. Is the "gzserver" launch file working fine in your system? Just try:
ros2 launch gazebo_ros gzserver.launch.py
If not, try to reinstall gazebo11 and gazebo_ros_pkgs for ROS2.
from gazebo_ros2_control.
Hi @Schulze18
I am already passing it as an argument so that does sadly not solve the problem.
from gazebo_ros2_control.
Okay, it was my bad. The robot I wanted to control had already ros2_control tags. I added xacro conditionals to determine real HW, fake HW or Gazebo. Problem solved.
from gazebo_ros2_control.
As an update, I have tried to recreate my launch file to better represent that in the examples, however I am running into issues launching it, as I get the following error:
ImportError: cannot import name 'GazeboRosPaths' from 'scripts' (/home/ray/Workspaces/udemy_ros2_ws/install/udemy_ros2_pkg/lib/python3.8/site-packages/scripts/__init__.py)
The launch file is as follows:
# Copyright 2020 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
import xacro
def generate_launch_description():
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(
get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']),
)
# gazebo_ros2_control_demos_path = os.path.join(
# get_package_share_directory('gazebo_ros2_control_demos'))
#
# xacro_file = os.path.join(gazebo_ros2_control_demos_path,
# 'urdf',
# 'test_cart_position.xacro.urdf')
#
# doc = xacro.parse(open(xacro_file))
# xacro.process_doc(doc)
urdf_file_name = 'urdf/camera_bot.xacro'
urdf = os.path.join(
get_package_share_directory('ros2_sim_pkg'),
urdf_file_name)
params = {'robot_description': urdf}
node_robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='screen',
parameters=[params]
)
spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
arguments=['-topic', 'robot_description',
'-entity', 'cartpole'],
output='screen')
load_joint_state_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_start_controller', 'joint_state_controller'],
output='screen'
)
load_joint_trajectory_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_start_controller', 'joint_trajectory_controller'],
output='screen'
)
return LaunchDescription([
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=spawn_entity,
on_exit=[load_joint_state_controller],
)
),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=load_joint_state_controller,
on_exit=[load_joint_trajectory_controller],
)
),
gazebo,
node_robot_state_publisher,
spawn_entity,
])
and the terminal output:
ay@ubuntu:~/Workspaces/udemy_ros2_ws$ ros2 launch ros2_sim_pkg gazebo_ros2_control_test.launch.py
[INFO] [launch]: All log files can be found below /home/ray/.ros/log/2021-03-31-01-20-49-067692-ubuntu-26382
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:271> exception=ImportError("cannot import name 'GazeboRosPaths' from 'scripts' (/home/ray/Workspaces/udemy_ros2_ws/install/udemy_ros2_pkg/lib/python3.8/site-packages/scripts/__init__.py)")>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 273, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 293, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
[Previous line repeated 3 more times]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 125, in execute
launch_description = self.__launch_description_source.get_launch_description(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
self._get_launch_description(self.__expanded_location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/python_launch_description_source.py", line 51, in _get_launch_description
return get_launch_description_from_python_launch_file(location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/python_launch_file_utilities.py", line 62, in get_launch_description_from_python_launch_file
launch_file_module = load_python_launch_file_as_module(python_launch_file_path)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/python_launch_file_utilities.py", line 37, in load_python_launch_file_as_module
loader.exec_module(mod)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/ros/foxy/share/gazebo_ros/launch/gzserver.launch.py", line 28, in <module>
from scripts import GazeboRosPaths
ImportError: cannot import name 'GazeboRosPaths' from 'scripts' (/home/ray/Workspaces/udemy_ros2_ws/install/udemy_ros2_pkg/lib/python3.8/site-packages/scripts/__init__.py)
from gazebo_ros2_control.
Hi I have the same error (at least the initial one) where loading the controller manager crashes gazebo. There are also no error messages for me except the final one that the gzserver has died. Running ros2 launch gazebo_ros gzserver.launch.py
works without any problems.
from gazebo_ros2_control.
Hi @Thieso, I am not sure, but I think the initial problem was that the URDF has been passed as an argument to robot_state_publisher:
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{'use_sim_time': use_sim_time}],
arguments=[urdf]),
but it should be given as a parameter (what @808brick already did in the second post):
params = {'robot_description': urdf}
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[params]
from gazebo_ros2_control.
@808brick It seems that your ros2 launch file is looking only for your workspace scripts folder, did you source the ros2 distro?
source /opt/ros/foxy/setup.bash
from gazebo_ros2_control.
So further information on this,
I ran gazebo with gazebo --verbose -s libgazebo_ros_init.so -s libgazebo_ros_factory.so
which gives me the error [Err] [Model.cc:1137] Exception occured in the Load function of plugin with name[gazebo_ros2_control] and filename[libgazebo_ros2_control.so]. This plugin will not run.
Sadly this is also not helpful for me but maybe you can see some problem there. Any hints are appreciated
My launch file is
#!/usr/bin/env python3
import os
import sys
from ament_index_python.packages import get_package_share_directory
import launch
from launch import LaunchDescription, LaunchService
from launch.actions import IncludeLaunchDescription, RegisterEventHandler, ExecuteProcess
from launch_ros.actions import Node
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
import xacro
def generate_launch_description():
# Load the URDF into a parameter
bringup_dir = get_package_share_directory('scanbot_description')
urdf_path = os.path.join(bringup_dir, 'scanbot_system.urdf.xacro')
urdf = xacro.process_file(urdf_path).toxml()
rviz_config_file = os.path.join(
get_package_share_directory('scanbot_description'),
'scanbot.rviz'
)
gazebo_node = launch.actions.ExecuteProcess(
cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so'],
output='screen'
)
# gazebo_node = IncludeLaunchDescription(
# PythonLaunchDescriptionSource([os.path.join(
# get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']),
# )
spawn_entity_node = Node(package='gazebo_ros', executable='spawn_entity.py',
arguments=['-entity', 'scanbot', '-topic', 'robot_description'],
output='screen')
joint_state_publisher_node = Node(
name='joint_state_publisher',
package='joint_state_publisher',
executable='joint_state_publisher',
output='screen'
)
robot_state_publisher_node = Node(
name='robot_state_publisher',
package='robot_state_publisher',
executable='robot_state_publisher',
parameters=[{'robot_description': urdf}],
output='screen'
)
rviz_node = Node(
package='rviz2',
name='rviz2',
executable='rviz2',
output='screen',
arguments=['-d', rviz_config_file],
)
return LaunchDescription([
joint_state_publisher_node,
rviz_node,
gazebo_node,
robot_state_publisher_node,
spawn_entity_node,
])
def main(argv=sys.argv[1:]):
"""Run lifecycle nodes via launch."""
ld = generate_launch_description()
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return ls.run()
if __name__ == '__main__':
main()
from gazebo_ros2_control.
I apologize for being inactive on this thread, was a busy week.
@Schulze18 my terminals are automatically sourced to ROS Foxy via .bashrc (so the line source /opt/ros/foxy/setup.bash
is at the end of the .bashrc file, which is how my ROS commands are able to run) then I go into the workspace, source it and try to launch.
I am not on the system in question right now, but I will try to do more experimenting this weekend with the comments you have given and report back. Thanks for all the feedback and help.
from gazebo_ros2_control.
hi @Schulze18
is it even possible to launch Gazebo with both plugins as suggested above #67 (comment)
gazebo --verbose -s libgazebo_ros_init.so -s libgazebo_ros_factory.so
from gazebo_ros2_control.
Hi @Schulze18, hi @808brick
Was this issue resolved? I still have the issue on Foxy Branch with Gazebo-11 and would like to know if there's a workaround.
Somehow it seems to function out of the box when looking at eg. https://www.youtube.com/watch?v=xBhYHOSxMOk.
My controller config:
`
controller_manager:
ros__parameters:
update_rate: 100 # Hz
joint_trajectory_controller_spj:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_spj:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_slj:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_slj:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_ej:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_ej:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_w1j:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_w1j:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_w2j:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_w2j:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_w3j:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster_w3j:
type: joint_state_broadcaster/JointStateBroadcaster
joint_trajectory_controller_spj:
ros__parameters:
joints:
- shoulder_pan_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
joint_trajectory_controller_slj:
ros__parameters:
joints:
- shoulder_lift_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
joint_trajectory_controller_ej:
ros__parameters:
joints:
- elbow_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
joint_trajectory_controller_w1j:
ros__parameters:
joints:
- wrist_1_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
joint_trajectory_controller_w2j:
ros__parameters:
joints:
- wrist_2_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
joint_trajectory_controller_w3j:
ros__parameters:
joints:
- wrist_3_joint
interface_name: position
command_interfaces:
- position
state_interfaces:
- position
- velocity
`
And my xacro:
`
<xacro:macro name="gazebo_control" params="
prefix
shoulder_pan_lower_limit
shoulder_pan_upper_limit
shoulder_lift_lower_limit
shoulder_lift_upper_limit
elbow_joint_lower_limit
elbow_joint_upper_limit
wrist_1_lower_limit
wrist_1_upper_limit
wrist_2_lower_limit
wrist_2_upper_limit
wrist_3_lower_limit
wrist_3_upper_limit
">
<!-- ROS 2 Control -->
<ros2_control name="GazeboSystem" type="system">
<hardware>
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
</hardware>
<joint name="${prefix}shoulder_pan_joint">
<command_interface name="position_spj">
<param name="min">${shoulder_pan_lower_limit}</param>
<param name="man">${shoulder_pan_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="${prefix}shoulder_lift_joint">
<command_interface name="position_slj">
<param name="min">${shoulder_lift_lower_limit}</param>
<param name="man">${shoulder_lift_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="${prefix}elbow_joint">
<command_interface name="position_ej">
<param name="min">${elbow_joint_lower_limit}</param>
<param name="man">${elbow_joint_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="${prefix}wrist_1_joint">
<command_interface name="position_w1j">
<param name="min">${wrist_1_lower_limit}</param>
<param name="man">${wrist_1_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="${prefix}wrist_2_joint">
<command_interface name="position_w2j">
<param name="min">${wrist_2_lower_limit}</param>
<param name="man">${wrist_2_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
<joint name="${prefix}wrist_3_joint">
<command_interface name="position_w3j">
<param name="min">${wrist_3_lower_limit}</param>
<param name="man">${wrist_3_upper_limit}</param>
</command_interface>
<state_interface name="position"/>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
</ros2_control>
<gazebo>
<!-- <plugin name="gazebo_ros2_control" filename="/root/ros2_ws/install/gazebo_ros2_control/lib/libgazebo_ros2_control.so" > -->
<plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so" >
<parameters>$(find modprof_bringup)/config/ur_joint_controller_angle.yaml</parameters> -->
<!-- <parameters>$(find modprof_bringup)/config/tst.yaml</parameters> -->
</plugin>
</gazebo>
</xacro:macro>
`
from gazebo_ros2_control.
from gazebo_ros2_control.
Related Issues (20)
- Force Torque data stored in imu vector HOT 2
- Passive joints are broken HOT 4
- Unexpected behavior when using passive joints in closed-loop kinematic chains HOT 2
- FT sensors possible bug HOT 1
- Kinematic chains with passive joints don't work with position interface HOT 1
- Could use remote gazebo possible? HOT 2
- Humble 4.4 update broke joints HOT 9
- Add noise and latency to the joints feedback HOT 1
- ERROR: "struct hardware_interface::HardwareInfo’} has no member named ‘hardware_plugin_name" HOT 5
- Robot still saggs if interfaces are not claimed
- Issue running example script in Harmonic
- Loading controller failed,Exception thrown during init stage with message: expected [string] got [string_array] HOT 7
- Errors after launching demos: controller manager issue? HOT 7
- How can solve this problem? HOT 3
- How to set the Effort while using JointGroupVelocityController in Gazebo HOT 3
- No rule to make target needed by 'libgazebo_ros2_control.so' HOT 2
- How do I handle this issue? HOT 2
- Parser Error Couldn't parse parameter override rule - loading tricycle_controller from ros2_control HOT 20
- Do mimic joints on gazebo_ros2_control work for grippers with one part interacting with the rest? (1 to 5 Gripper)
- Error in destruction of rcl subscription handle: Failed to delete datareader HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gazebo_ros2_control.