Karsten1987 / confbot_robot

workspace comprising demo packages for our roscon2018 talk
Apache License 2.0
10 stars 8 forks source link

Gazebo support (draft) #19

Closed mikaelarguedas closed 5 years ago

mikaelarguedas commented 5 years ago

DO NOT MERGE It was initially marked as draft but apparently something went wrong on page refresh

mikaelarguedas commented 5 years ago

How I'm testing this:

ros2.repos + additionnal_repos.repos in an underlay this repo in an overlay built with:

colcon build --merge-install --cmake-args -DSECURITY=ON -DPOLICY_FILE=<PATH_TO_WORKSPACE>/src/roscon2018/confbot_security/safe_zone_publisher_policies.xml

Running: In all shells start with: source <PATH_TO_WORKSPACE>/install/setup.bash

Shell 1:

export GAZEBO_MODEL_PATH=<PATH_TO_WORKSPACE>/install/share/
source /usr/share/gazebo/setup.sh
ros2 launch confbot_simulation empty_world.launch.py

Shell 2

ros2 run confbot_simulation urdf_spawner.py `ros2 pkg prefix confbot_description --share`/urdf/confbot.urdf
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{angular: {z: 1}}" -1

Shell 3:

ros2 run rviz2 rviz2 -d `ros2 pkg prefix confbot_bringup --share`/config/confbot.rviz
mikaelarguedas commented 5 years ago

CI currently blocked by https://github.com/mikaelarguedas/ros2ci/pull/11

Worked around it upstream, CI is green

mikaelarguedas commented 5 years ago

Things that don't work as originally expected:

GPU ray: https://github.com/Karsten1987/roscon2018/pull/19#discussion_r271888237

Simulation time: - we use the gazebo_ros_factory library to be able to spawn models in gazebo. But that libary doesnt publish the simulated time resulting in using system time everywhere anyway. gazebo_ros_init seems to publish the sim time, but doesnt allow to spawn model via services. Is there a way to get both the spawning interfaces and the simulation time published ? Launching gazebo with both plugins is doable and should solve this

Published transforms

@Karsten1987 as you said you had a different gazebo demo available, any clue as of what should be changed here? (maybe @chapulina has some insights as well?)

chapulina commented 5 years ago

RViz can't display more that a laser scan every second or so due to missing transform

Maybe it's due to https://github.com/ros2/rviz/issues/332 ? I've seen something similar with wheel transforms on the diff drive demo, see https://github.com/ros-simulation/gazebo_ros_pkgs/pull/806#issuecomment-417496670

chapulina commented 5 years ago

a different gazebo demo available

Maybe it was https://github.com/chapulina/dolly/ ? I've visualized the laser scans on RViz, but since the laser update rate itself is low on purpose, I probably never noticed that problem. Turn the bug into a feature :wink:

mikaelarguedas commented 5 years ago

Maybe it's due to ros2/rviz#332 ? I've seen something similar with wheel transforms on the diff drive demo, see ros-simulation/gazebo_ros_pkgs#806 (comment)

Thanks! It looks like the same issue, I tried the referenced PR enabling message_filters but ended up with RViz segfaulting. Using use_sim_time true on Rviz prevent the segfault. LaserScan are not displayed because rviz drops the messages with [signalFailure] Drop message: frame 'base_link' at time 268.967 for reason(0)

@Karsten1987 I'll be away from a computer for the next couple weeks, would you mind giving this a try when you get a chance ?

Karsten1987 commented 5 years ago

I've rebased this branch on top of the latest master to be able to compile to latest ros2 master.

Karsten1987 commented 5 years ago

So I gave this a shot and had only very poor results. I can't get around the TF error independent on where to set use_sim_time. The robot model spawns in gazebo (without the base mesh though) and moves correctly when publishing a velocity. Things go very south when trying to visualize all of this in RViz. The laser scans are not shown at all and the TF error let's my mac run on 100% CPU power. So I am not sure what to do here next. I've tried setting the the simulation time on every node, but that also doesn't yield any success.

I'll try to catch @chapulina in the next few days to sort this out offline.

Karsten1987 commented 5 years ago

For setting the use_sim_time correctly the LaunchConfigurations have to be conditioned. See https://github.com/ros2/launch_ros/issues/30 for a full issue description

Karsten1987 commented 5 years ago

we could boil it down far enough to make it work flawless when setting the fixed frame in RViz to the laser_frame. We've seen a constant time delay of approx 100ms which makes the TF transform fail (with sim_time enabled). So I am not sure if it's the laser or the TF message filters which are not working.

While working with the laser, we've found that the orientation in the urdf must be wrong. Then by visualizing the laser scan in Gazebo, we've noticed that the laser is wrongly rotated around 90 degrees.

mikaelarguedas commented 5 years ago

I'll merge this as an initial version and ticket pending issues / open follow-up PRs