Skip to content

Instantly share code, notes, and snippets.

@lucasw
Last active February 16, 2019 16:27
Show Gist options
  • Save lucasw/76a903f98bce3179da6282baf9021f30 to your computer and use it in GitHub Desktop.
Save lucasw/76a903f98bce3179da6282baf9021f30 to your computer and use it in GitHub Desktop.
ros2 notes

Updating many repositories to use ros2 bouncy: image_manip, usb_cam, v4l2ucp, imgui_ros

The intent is to develop/learn how to convert ros1 packages first along with the entire workflow of building and debugging and deploying and then take advantage of ros2 features.

Colcon

No verbose option? cd into build/package_name then run make VERBOSE=1 right there.

Does running a release build (using a mixin) then forgetting to specify release the next time clobber all the old built files, requiring a complete rebuild?

Likewise with debug builds.

Lack of devel half-way install space is annoying, though forces proper install of necessary files from beginning.

Can edit a yaml then ros launch and immediately see results, have to colcon build it, and possibly re-source the install/setup.bash if a new file was created.

--symlink-install is solution to above- it installs with symlinks to files in source, so scripts and yamls can be run with new changes without reinstall.

Debugging

gdb attach to process is probably the right approach rather than figuring out how to launch/run processes with all the arguments in gdb.

The process node composition plays in there, if only want to debug one node and let the rest run full speed then need to leave that node out, or run all of them in separate processes. or

Python rclpy

One node took up a lot of cpu to do very little. ros1 had that probably but only 10% cpu instead of nearly 100%. Probably there is an easy fix but for now using mostly C++ since performance is the goal anyhow.

Where python will be useful is for initial configuration scripts that launch and end, maybe python will be better at figuring out parameters of other nodes, or what the contents of custom messages are.

Messages and Services

Have made a few custom services and they work fine. async response approach looks ideal for user interfaces, but haven't used it yet.

Need the same ability for at least python to encounter a new message/service and peel it apart.

Parameters

Setting parameters in launch file is very roundabout- writing yaml files to /tmp. Not sure how to get arguments into the launch.py file (just look at sys.argv?)

Not updating parameters live anywhere, mostly using them like in ros1 and only updating at node init time.

Not sure if high frequency parameter updating is okay now in ros2.

Replacing dynamic reconfigure with individual basic type topic subscription mostly. It gets repetitive, probably will end up making convenience functions to help there, maybe even reinvent the dynamic reconfigure wheel with a yaml configured class that is a member of any class that wants to use it.

Or parameters turn out to be easy and convenient for this. Certainly certain controls ought to be topics - floats and ints that can change rapidly, while text boxes for configuration and enables and disables can be slower parameter updates- both of those tended to be commingled because it was convenient in .cfg files in the past.

Process composition

Not sure what currently launch file approach is doing here. Want to be able to package nodes into single processes for efficiency later.

usb_cam

ros-drivers/usb_cam#103

usb_cam - would this be better off with a new name to clearly delineate from uvc_camera, v4l_camera or v4l2_camera would be better (though it doesn't necessarily have to be a camera).

Haven't seen any responses to the issue, raise something on discourse? orphaned packages group? Send messages to maintainers?

It is grabbing images super slow, haven't debugged yet.

v4l2ucp

lucasw/v4l2ucp#4

Probably should rename this to v4l2_control, it doesn't have much to do with old v4l2ucp now.

Need to resolve parameters vs. topics, right now it is all topics. No camera control ought to be changed that frequently, so here dynamic parameters ought to be enough.

Image Manip

Don't necessarily convert all the nodes, just ones needed immediately.

lucasw/image_manip#6 lucasw/image_manip#11

Not useing unique_ptrs yet, revisit this later to increase performance. TBD insert link to page that shows pointers being inserted as text into images to show where they are getting copied in a chain of nodes.

Simulation and Visualization

May update simple_sim_ros next (maybe rename it to bullet_ros also).

Need to look at ros2 rviz - update rviz_textured_quads, rviz_lighting, and rviz_camera_stream.

UI

imgui_ros

lucasw/imgui_ros#19

Need to develop imgui_ros more.

How to introspect nodes for parameters, then create a bunch of imgui widgets to set them (if they can even be set live).

Need to look at docking. Want to use docking to create ini file then disable it (via default parameter) for normal usage. (also disable the multi view port stuff for now).

Need to stretch ui components to fill window, and have changes to that window stretch components inside- probably easy to do.

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

why subscriber - > subscription? (subscribtion vs. subscription...)

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

ros2 launch locks up and has to be killed if there is an exception.

$ ros2 launch image_manip stop_motion_launch.py
[ERROR] [launch.LaunchService]: Caught exception in launch (see debug for traceback): unexpected indent (stop_motion_launch.py, line 121)
^C^C^C^C^C
ps aux | grep launch.py | grep python
kill 5532 # or whatever
Exception ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
    t.join()
  File "/usr/lib/python3.6/threading.py", line 1056, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
  File "/opt/ros/bouncy/lib/python3.6/site-packages/launch/utilities/signal_management.py", line 120, in __on_sigint
    __original_sigint_handler(signum, frame)
KeyboardInterrupt
[ERROR] [asyncio]: Task was destroyed but it is pending!
task: <Task pending coro=<LaunchContext.emit_event() running at /opt/ros/bouncy/lib/python3.6/site-packages/launch/launch_context.py:172>>
/usr/lib/python3.6/asyncio/base_events.py:493: RuntimeWarning: coroutine 'LaunchContext.emit_event' was never awaited
  self._ready.clear()

Just issuing the kill doesn't work unless ctrl-c has already been issued on the launch, and a second ctrl-c is required to get back to a prompt (kill -9 probably works).

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

Colcon - Exceeded maximum number of notifications

$ colcon build --mixin release --packages-select image_manip
Starting >>> image_manip
Finished <<< image_manip [0.46s]                      

Summary: 1 package finished [0.62s]
[0.799s] ERROR:colcon.colcon_notification.desktop_notification:Exception in desktop notification extension 'notify2': org.freedesktop.Notifications.MaxNotificationsExceeded: Exceeded maximum number of notifications
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_notification/desktop_notification/__init__.py", line 107, in notify
    title=title, message=message, icon_path=icon_path)
  File "/usr/lib/python3/dist-packages/colcon_notification/desktop_notification/notify2.py", line 50, in notify
    self._last_notification.show()
  File "/usr/lib/python3/dist-packages/notify2.py", line 188, in show
    self.timeout,  # expire_timeout
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.Notifications.MaxNotificationsExceeded: Exceeded maximum number of notifications

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

[ERROR] [launch.LaunchService]: Caught exception in launch (see debug for traceback): 'module' object is not callable

Where is the debug?

There isn't a file, rerun the launch:

ros2 launch image_manip -d stop_motion_launch.py

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

How to change the node name in the launch file? node_name=

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

get_parameter_or():

terminate called after throwing an instance of 'rclcpp::ParameterTypeException'
  what():  expected [integer] got [double]

An integer instead of a double also terminates.

@lucasw
Copy link
Author

lucasw commented Nov 8, 2018

really need to have working ros2 node info, and ros2 topic info that shows node names.

@lucasw
Copy link
Author

lucasw commented Nov 10, 2018

Mismatched subscriber templates doesn't produce a build or run time error?

rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr capture_single_sub_;
...
capture_single_sub_ = create_subscription<std_msgs::msg::Float32>(...

@lucasw
Copy link
Author

lucasw commented Nov 11, 2018

ros2 daemon

If nodes aren't dying after killing a launch script, need to kil the ros2 daemon.

Is it this:

 /usr/bin/python3 /opt/ros/bouncy/bin/_ros2_daemon --rmw-implementation rmw_fastrtps_cpp --ros-domain-id 0

Instead kill everything running out of workspace:

kill -9 $(pgrep -f colcon_ws)

This kills a failed launch (also kills vi which has any launch.py open, so refine this):

kill -9 $(pgrep -f "/opt/ros/bouncy/bin/ros2 launch")
kill -9 $(pgrep -f "/opt/ros/bouncy/bin/ros2 launch"); kill -9 $(pgrep -f colcon_ws); kill -9 $(pgrep -f ros2_daemon)

@lucasw
Copy link
Author

lucasw commented Nov 12, 2018

If only have a wireless connection, then that connection is lost, can't run ros2 nodes properly-
they can't communicate with each other?

If had launched the terminal after losing the connection, would it know to just use loopback?

@lucasw
Copy link
Author

lucasw commented Nov 13, 2018

Moved a colcon build directory to a new location, deleted build install and log, still get this:

[0.324s] WARNING:colcon.colcon_core.shell:The path '/home/lucasw/ros/ros2_ws/install' in the environment variable COLCON_PREFIX_PATH doesn't exist

Was there a hidden directory to delete, and then mixins would have to be re-added and updated?

@lucasw
Copy link
Author

lucasw commented Nov 23, 2018

Get this after launch seems successful, but then launch has to be killed -9.

[ERROR] [launch.LaunchService]: Caught exception in launch (see debug for traceback): 'utf-8' codec can't decode byte 0xb0 in position 31: invalid start byte

Actually this seems to be related to setting a double parameter with an integer.

Also associated with usage of StaticTransformBroadcaster and regular TransformBroadcaster, but switching to TFMessage publishing has cleared that up. https://answers.ros.org/question/304033/transformbroadcaster-as-member-of-ros2-node/

@lucasw
Copy link
Author

lucasw commented Dec 4, 2018

Have to be careful about cyclical shared_ptrs with objects that want a Node passed into them- those object ought to use weak_ptr but don't always.

@lucasw
Copy link
Author

lucasw commented Dec 16, 2018

Crystal

Fresh system with no previous bouncy install.

For image_manip, v4l2ucp, usb_cam, imgui_ros

sudo apt install ros-crystal-cv-bridge libv4l-dev libsdl2-dev libglm-dev ros-crystal-tf2-sensor-msgs

@lucasw
Copy link
Author

lucasw commented Dec 16, 2018

Update bouncy system to crystal

Can keep bouncy around.

sudo apt install ros-crystal-desktop ros-crystal-cv-bridge ros-crystal-tf2-sensor-msgs

Make a new workspace just for crystal, can go to the other for bouncy.

mkdir -p ~/ros/crystal_colcon_ws/src
cd ~/ros/crystal_colcon_ws/src
git clone -b bouncy https://github.com/lucasw/v4l2ucp
git clone -b bouncy https://github.com/lucasw/usb_cam
git clone -b bouncy https://github.com/lucasw/image_manip
git clone -b bouncy https://github.com/lucasw/imgui_ros
cd imgui_ros/imgui_ros
git clone https://github.com/ocornut/imgui

@lucasw
Copy link
Author

lucasw commented Dec 18, 2018

colcon isn't installing scripts properly in crystal, or building packages as expected (probably related).
Changing a script then running colcon build --packages-select imgui_ros doesn't result in the new version of the script getting installed
(symlink install may avoid this).

Go back to bouncy for now.

@lucasw
Copy link
Author

lucasw commented Jan 12, 2019

Using a size_t for set_parameter_if_not_set instead of int results in:

cpp:33:
/opt/ros/crystal/include/rclcpp/parameter.hpp: In instantiation of ‘rclcpp::Parameter::Parameter(const string&, ValueTypeT) [with ValueTypeT = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/opt/ros/crystal/include/rclcpp/node_impl.hpp:222:17:   required from ‘void rclcpp::Node::set_parameter_if_not_set(const string&, const ParameterT&) [with ParameterT = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/lucasw/colcon_ws/src/imgui_ros/imgui_ros/src/test/generate_pointcloud2.cpp:45:55:   required from here
/opt/ros/crystal/include/rclcpp/parameter.hpp:43:21: error: call of overloaded ‘ParameterValue(long unsigned int&)’ is ambiguous
   : Parameter(name, ParameterValue(value))
                     ^~~~~~~~~~~~~~~~~~~~~
In file included from /opt/ros/crystal/include/rclcpp/parameter.hpp:25:0,
                 from /opt/ros/crystal/include/rclcpp/node_interfaces/node_parameters_interface.hpp:26,
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment