Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Merge Fetch15 branch #715

Open
wants to merge 177 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
e6312ba
add before and after hook for state machine execution
knorth55 Oct 18, 2022
8c52eb3
add catch loop for global exit
knorth55 Oct 18, 2022
ad849b6
Make sure that there is no subscriber when (one-shot-subscribe) is ca…
708yamaguchi May 20, 2021
8a66576
Use pointer closures for callback function so that they can be access…
708yamaguchi May 20, 2021
fd432e3
Use if statement instead of when ... unless ...
708yamaguchi May 20, 2021
694371f
Changes to 'print-ros-msg'
Affonso-Gui Mar 6, 2019
57501eb
Update sigint and error handlers
Affonso-Gui Apr 14, 2021
680ed2d
Update script handlers
Affonso-Gui Apr 14, 2021
d532be8
Always use ROSCONSOLE_DEFAULT_NAME on set-logger-level
Affonso-Gui Apr 14, 2021
ab61509
Give ros::spin-once more meaningful return values
Affonso-Gui Apr 14, 2021
e1540fb
Allow interruptions on ROS sleep functions
Affonso-Gui Apr 14, 2021
847f55a
Define gc-proof symbols as constants
Affonso-Gui Apr 16, 2021
1bf4246
Fix possible memory faults when registering subscribers
Affonso-Gui May 28, 2021
009bc73
Shutdown ros before clearing static data on exit to avoid eventual locks
Affonso-Gui Aug 16, 2021
3a8db49
Use ros::get-topic-subscriber instead of ros::get-num-publishers in o…
Affonso-Gui Apr 13, 2022
d51c1bd
Add quotations to topic name in one-shot-subscribe error message
Affonso-Gui Apr 13, 2022
68b5ead
Add roseus_bt package
Affonso-Gui Jun 16, 2021
26a8f08
(roseus_bt) Parse to service files
Affonso-Gui Jun 16, 2021
bff6c54
(roseus_bt) Add EusActionNode and EusConditionNode
Affonso-Gui Jun 16, 2021
4152fe5
(roseus_bt) Add euslisp roseus_bt package and utilities
Affonso-Gui Jun 16, 2021
f199f52
(roseus_bt) Parse header
Affonso-Gui Jun 16, 2021
f66d59b
(roseus_bt) Parse action classes
Affonso-Gui Jun 16, 2021
fe0bc07
(roseus_bt) Parse condition classes
Affonso-Gui Jun 16, 2021
aee6eae
(roseus_bt) Parse main function
Affonso-Gui Jun 16, 2021
6cb4a61
(roseus_bt) Fix namespace of eus nodes
Affonso-Gui Jun 16, 2021
ff365ca
(roseus_bt) Add generate_cpp_file
Affonso-Gui Jun 16, 2021
1e0e155
(roseus_bt) Add generate_cmake_lists
Affonso-Gui Jun 17, 2021
96a844a
(roseus_bt) Add generate_package_xml
Affonso-Gui Jun 17, 2021
8db457d
(roseus_bt) Change action/service file generator
Affonso-Gui Jun 17, 2021
170e170
(roseus_bt) Keep xml_filename in class variable
Affonso-Gui Jun 17, 2021
47f6ef0
(roseus_bt) Fix comment in xml_parser.h
Affonso-Gui Jun 17, 2021
45e5ca6
(roseus_bt) Add create_bt_package executable
Affonso-Gui Jun 17, 2021
c650e21
(roseus_bt) Fix compilation errors
Affonso-Gui Jun 17, 2021
a1636f0
(roseus_bt) Remove test executable
Affonso-Gui Jun 18, 2021
bdebe18
(roseus_bt) Print warnings on non-global lambda-closures
Affonso-Gui Jun 18, 2021
ee068c3
(roseus_bt) Copy model file and use absolute path
Affonso-Gui Jun 18, 2021
5dfda3f
(roseus_bt) Add roseus_bt:spin
Affonso-Gui Jun 20, 2021
e7e1b55
(roseus_bt) Add generate_eus_action_server
Affonso-Gui Jun 20, 2021
c19a0d7
(roseus_bt) Add generate_eus_condition_server
Affonso-Gui Jun 20, 2021
8d0fbdf
(roseus_bt) Add separate template generator class
Affonso-Gui Jun 20, 2021
f31e111
(roseus_bt) Replace const char* with std::string
Affonso-Gui Jun 20, 2021
eb44cfe
(roseus_bt) Use external symbol roseus_bt:spin in template
Affonso-Gui Jun 20, 2021
7c7ca2f
(roseus_bt) Add command line arguments
Affonso-Gui Jun 20, 2021
f7c353b
(roseus_bt) Fix bugs in euslisp file generation
Affonso-Gui Jun 20, 2021
ac7b5a7
(roseus_bt) Query before overwriting files
Affonso-Gui Jun 20, 2021
8feb2c0
(roseus_bt) Use const strings on function arguments
Affonso-Gui Jun 20, 2021
9b5ba83
(roseus_bt) Add subscriber nodes
Affonso-Gui Jun 21, 2021
9bb4e6a
(roseus_bt) Add roseus_bt/eus_nodes.h header file
Affonso-Gui Jun 21, 2021
f11665a
(roseus_bt) Add eus-like function names
Affonso-Gui Jun 30, 2021
5ad4705
(roseus_bt) Add comments on roseus_bt:set-output usage
Affonso-Gui Jun 30, 2021
0394133
(roseus_bt) Add hyphen-spelled package nickname
Affonso-Gui Jun 30, 2021
1a67a2c
(roseus_bt) Add maybe_push_message_package as common utility
Affonso-Gui Jun 30, 2021
c114318
(roseus_bt) Don't write eus files if not needed
Affonso-Gui Jun 30, 2021
008b58d
(roseus_bt) Skip copy_xml_file if source is equal to destination
Affonso-Gui Jun 30, 2021
89eb54c
(roseus_bt) Use model filename as default executable name
Affonso-Gui Jul 6, 2021
2f44250
(roseus_bt) Allow to assign multiple model files
Affonso-Gui Jul 6, 2021
9d37b22
(roseus_bt) Add euslisp sample files
Affonso-Gui Jul 6, 2021
41fe61b
(roseus_bt) Update euslisp sample task
Affonso-Gui Jul 7, 2021
fda9fe2
(roseus_bt) Add sample model files
Affonso-Gui Jul 7, 2021
0de4468
(roseus_bt) Suppress return value on eus_condition_server template
Affonso-Gui Jul 7, 2021
c7d896f
(roseus_bt) Avoid extra newline after comment on eus_action_server te…
Affonso-Gui Jul 7, 2021
a4c147c
(roseus_bt) Fix bug on server_name/service_name formatting
Affonso-Gui Jul 7, 2021
68ec60f
(roseus_bt) Search in all BehaviorTrees for server_name/service_name
Affonso-Gui Jul 7, 2021
e0db84c
(roseus_bt) Update target xml_filename location
Affonso-Gui Jul 7, 2021
fa3ecd9
(roseus_bt) Avoid extra newlines after registering on cpp main function
Affonso-Gui Jul 7, 2021
0d64821
(roseus_bt) Ensure valid package name
Affonso-Gui Jul 7, 2021
0811816
(roseus_bt) Use different IDs when initializing demo task with broom …
Affonso-Gui Jul 8, 2021
d40eae9
(roseus_bt) Add create_bt_tutorials executable
Affonso-Gui Jul 8, 2021
1bf6da1
(roseus_bt) Rename function port_node_to_message_description -> forma…
Affonso-Gui Jul 8, 2021
4c9b66b
(roseus_bt) Add load guard in package_generator.h
Affonso-Gui Jul 8, 2021
36ac459
(roseus_bt) Only split euslisp server files for reactive conditions
Affonso-Gui Jul 8, 2021
516eb3d
(roseus_bt) Ensure newline after load_files in eus_server_template
Affonso-Gui Jul 8, 2021
c05bafb
(roseus_bt) Wait for topic message on t04_subscriber
Affonso-Gui Jul 8, 2021
2937e12
(roseus_bt) Add roseus_bt.rosinstall
Affonso-Gui Jul 8, 2021
9f3d1ca
(roseus_bt) Add README files
Affonso-Gui Jul 9, 2021
1f30481
(roseus_bt) Move server_name/service_name definition to node pallete
Affonso-Gui Jul 9, 2021
b20ddb4
(roseus_bt) Avoid pushing duplicates on collect_eus_actions/conditions
Affonso-Gui Jul 9, 2021
5c3bc7b
(roseus_bt) Verify the xml file syntax
Affonso-Gui Jul 9, 2021
577dc5a
(roseus_bt) Fix bug when dealing with multiple duplicated nodes
Affonso-Gui Jul 10, 2021
92595ef
(roseus_bt) Add t07_xacro tutorial
Affonso-Gui Jul 10, 2021
b64163a
(roseus_bt) Spell check README.md
Affonso-Gui Jul 10, 2021
cd59f35
(roseus_bt) Verify root and TreeNodesModel in check_xml_file
Affonso-Gui Jul 10, 2021
3000d3f
(roseus_bt) Add custom exceptions
Affonso-Gui Jul 12, 2021
c29a6b6
(roseus_bt) Add logging
Affonso-Gui Jul 12, 2021
a6931ff
(roseus_bt) Declare template as static member variable
Affonso-Gui Jul 12, 2021
d0ebddb
(roseus_bt) Downgrade cmake minimum required version
Affonso-Gui Aug 13, 2021
5e2799b
(roseus_bt) Update README title case
Affonso-Gui Aug 13, 2021
06b96bd
(roseus_bt) Update .rosinstall
Affonso-Gui Aug 16, 2021
ff4a3c8
(roseus_bt) Fix trailing whitespace in nodes.l
Affonso-Gui Aug 16, 2021
67ad63e
(roseus_bt) Add checks for accept-cb
Affonso-Gui Aug 16, 2021
57e2bc6
(roseus_bt) Add additional checks for local context on global callbacks
Affonso-Gui Aug 24, 2021
6de184b
(roseus_bt) Add groupname option to condition servers
Affonso-Gui Sep 21, 2021
67365f1
(roseus_bt) Use classes instead of macros
Affonso-Gui Sep 21, 2021
26a7679
(roseus_bt) Call set-succeeded from the :execute-cb method
Affonso-Gui Sep 22, 2021
58c4d40
(roseus_bt) Use :is-active to evaluate ongoing requests
Affonso-Gui Sep 22, 2021
cacc955
(roseus_bt) Use trace level on verbose option
Affonso-Gui Oct 8, 2021
89f08cd
(roseus_bt) Format tracing messages
Affonso-Gui Oct 8, 2021
2dcfc4b
(roseus_bt) Add port name to trace log
Affonso-Gui Oct 8, 2021
abbf3f2
(roseus_bt) Fix fmt::format indexing in format_node_body
Affonso-Gui Oct 8, 2021
4892325
(roseus_bt) Add monitor-groupname for separate goal and cancel handlers
Affonso-Gui Sep 22, 2021
aa77097
(roseus_bt) Add groupname option to condition nodes
Affonso-Gui Feb 24, 2022
980a526
(roseus_bt) Check server connections at init time
Affonso-Gui Apr 18, 2022
b004e63
(roseus_bt) Stablish persistent connection with service client at ini…
Affonso-Gui Apr 18, 2022
f27e4ab
(roseus_bt) Add sleep in sample task loop
Affonso-Gui Apr 18, 2022
8af94a8
(roseus_bt) Increase default spin rate
Affonso-Gui Apr 18, 2022
c08a19d
(roseus_bt) Update RetryUntilSuccessful name
Affonso-Gui Apr 18, 2022
49c39db
(roseus_bt) Add rosbridgecpp submodule
Affonso-Gui Apr 18, 2022
b2bb0ca
(roseus_bt) Add eus_remote_action_node.h
Affonso-Gui Apr 18, 2022
432f893
(roseus_bt) Add EusRemoteAction generation code
Affonso-Gui Apr 18, 2022
48abde8
(roseus_bt) Add t08_multimaster
Affonso-Gui Apr 18, 2022
fe7de02
(roseus_bt) Add ws_action_client base
Affonso-Gui Apr 21, 2022
4107e61
(roseus_bt) Subscribe remote action results
Affonso-Gui Apr 21, 2022
0be68a4
(roseus_bt) Enable halting remote actions
Affonso-Gui Apr 21, 2022
76ee5e5
(roseus_bt) Fix message type parameter in EusRemoteActionNode
Affonso-Gui Apr 25, 2022
be59054
(roseus_bt) Enable input and output ports in remote actions
Affonso-Gui Apr 25, 2022
70ba8d0
(roseus_bt) Allow to set host_name and host_port dynamically
Affonso-Gui Apr 25, 2022
483ecab
(roseus_bt) Add EusRemoteCondition node
Affonso-Gui Apr 25, 2022
e53cd40
(roseus_bt) Indent
Affonso-Gui Apr 25, 2022
916a6a0
(roseus_bt) Reduce duplicate formatting functions
Affonso-Gui Apr 25, 2022
0d7992d
(roseus_bt) Add default file logger
Affonso-Gui Apr 25, 2022
635fc22
(roseus_bt) Add 'update_field_name' to set output ports once at a time
Affonso-Gui Apr 25, 2022
1c86e7c
(roseus_bt) Move #DEBUG definition to generated files
Affonso-Gui Apr 25, 2022
7f1c934
(roseus_bt) Add generate_eus_remote_action_server and generate_eus_re…
Affonso-Gui Apr 25, 2022
492d25a
(roseus_bt) Split euslisp files for each host
Affonso-Gui Apr 25, 2022
140abda
(roseus_bt) Enable splitting eus files in tutorials
Affonso-Gui Apr 25, 2022
6aee87d
(roseus_bt) Fix file splitting with mixed remote and local nodes
Affonso-Gui Apr 25, 2022
ee35e8c
(roseus_bt) Enable non-ROS input ports in remote nodes
Affonso-Gui Apr 26, 2022
8950c7a
(roseus_bt) Avoid unnecessary declarations at sendGoal and sendRequest
Affonso-Gui Apr 26, 2022
d41fda1
(roseus_bt) Update t08_multimaster
Affonso-Gui Apr 26, 2022
1d6da77
(roseus_bt) Add submodule directory
Affonso-Gui Apr 26, 2022
7a6897e
(roseus_bt) Update submodules at build time
Affonso-Gui Apr 26, 2022
5da902b
(roseus_bt) Add basic_types.h
Affonso-Gui Apr 27, 2022
d20d4a1
(roseus_bt) Change subscriber port names
Affonso-Gui Apr 28, 2022
8742e87
(roseus_bt) Allow to set default topic_name at Subscriber nodes
Affonso-Gui Apr 28, 2022
ba405cb
(roseus_bt) Add RemoteSubscriber
Affonso-Gui Apr 28, 2022
2267f71
(roseus_bt) Fix bug in convertFromString
Affonso-Gui Apr 28, 2022
9daa78a
(roseus_bt) Explicitly add subscriber and subtree ports in model files
Affonso-Gui Apr 28, 2022
a9d7a18
Add single-threaded resumable-action-node
Affonso-Gui Jan 6, 2022
d41c172
Add resume-cb option to resumable-action-nodes
Affonso-Gui Jan 6, 2022
037ab99
(roseus_bt) Default action-node's preemption callback to 'signals-can…
Affonso-Gui May 27, 2022
a5fcbe3
(roseus_bt) Update the reactive sample code and documentation to use …
Affonso-Gui May 27, 2022
a27c107
(roseus_bt) Fix typo in warning
Affonso-Gui May 27, 2022
efa07d2
(roseus_bt) Log and return final tree status on completion
Affonso-Gui May 27, 2022
4749d6a
(roseus_bt) Add received_port in Subscriber nodes to differentiate re…
Affonso-Gui May 27, 2022
46031e6
(roseus_bt) Update samples to use received_port in subscribers
Affonso-Gui May 27, 2022
3a934ed
(roseus_bt) Update the subscriber documentation
Affonso-Gui May 27, 2022
67a8098
(roseus_bt) Add more documentation on reactive nodes
Affonso-Gui May 27, 2022
c31655b
(roseus_bt) Update the remote tutorial documentation
Affonso-Gui May 27, 2022
64d0a8e
(roseus_smach) Adapt to updated assoc key (see EusLisp/436)
Affonso-Gui Jun 7, 2022
6a5c943
set userdata as same as mydata
knorth55 Oct 19, 2022
e5e739c
pass userdata as arguments
knorth55 Oct 20, 2022
5802b75
Allow optional argument on set-logger-level for backward compability
Affonso-Gui Aug 11, 2022
cbb1871
Fix typos in ros::roseus warning
Affonso-Gui Sep 7, 2022
f05e39a
(roseus_bt) Update create_bt_tutorials help description
Affonso-Gui Sep 26, 2022
8b6a8b0
(roseus_bt) Remove check-fn-closure
Affonso-Gui Sep 26, 2022
62135c4
(roseus_bt) Add missing resume-cb slot in resumable-action-node
Affonso-Gui Sep 26, 2022
a9ef966
(roseus_bt) Always wait for result in RemoteCondition
Affonso-Gui Oct 10, 2022
335c75c
(roseus_bt) Fix misspell: SetUInt -> SetUint
Affonso-Gui Oct 10, 2022
642ba9e
(roseus_bt) Generate server launch files
Affonso-Gui Oct 20, 2022
17676bd
(roseus_bt) Force hyphens in euslisp file names
Affonso-Gui Oct 20, 2022
3f9bc2a
(roseus_bt) Add CopyDocument class to avoid unnecessary dumping and p…
Affonso-Gui Oct 21, 2022
600bbe9
(roseus_bt) Allow to parse to basic ros types in remote action
Affonso-Gui Oct 21, 2022
8c07fa5
(roseus_bt) Add command line arguments for initializing blackboard va…
Affonso-Gui Oct 21, 2022
ee09f2b
(roseus_bt) Standardize namespaces and loadguards
Affonso-Gui Oct 21, 2022
d4cd7d2
(roseus_bt) Add positional argument check and negative number support…
Affonso-Gui Oct 21, 2022
077a337
(roseus_bt) Add implicit blackboard conversions for int8, int16, and …
Affonso-Gui Oct 21, 2022
b3645fa
(roseus_bt) Decrease sleep time in remote nodes
Affonso-Gui Oct 22, 2022
84cef5d
(roseus_bt) Use CopyDocument in remote subscriber
Affonso-Gui Oct 23, 2022
1918a4d
(roseus_bt) Inform topic type in remote subscribers
Affonso-Gui Oct 23, 2022
2aa2927
(roseus_bt) Add single variable constructor in CopyDocument
Affonso-Gui Oct 23, 2022
775e813
(roseus_bt) Avoid duplicated header generation
Affonso-Gui Oct 23, 2022
80c86c9
(roseus_bt) Drop support for type unsafe message_field subscriber option
Affonso-Gui Oct 23, 2022
5fcea9a
(roseus_bt) Increase server unregister_timeout (https://github.com/kn…
Affonso-Gui Oct 23, 2022
ad414e5
Merge branch 'master' into fetch15
knorth55 Nov 18, 2022
551b51e
add dynamic-reconfigure-server
knorth55 Nov 11, 2022
6ceae78
add dynamic_reconfigure_server test
knorth55 Nov 14, 2022
42e0c20
add dynamic reconfigure client test
knorth55 Nov 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule ".travis"]
path = .travis
url = https://github.com/jsk-ros-pkg/jsk_travis
[submodule "roseus_bt/include/rosbridgecpp"]
path = roseus_bt/include/rosbridgecpp
url = https://github.com/ppianpak/rosbridgecpp
2 changes: 2 additions & 0 deletions roseus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,6 @@ if(CATKIN_ENABLE_TESTING)
add_rostest(test/test-geneus.test)
add_rostest(test/test-compile-message.test)
add_rostest(test/test-print-ros-msg.test)
add_rostest(test/test-dynamic-reconfigure-server.test)
add_rostest(test/test-dynamic-reconfigure-client.test)
endif()
2 changes: 1 addition & 1 deletion roseus/cmake/roseus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ macro(generate_eusdoc _lispfile)
get_filename_component(_name ${_lispfile} NAME_WE)
set(_lisppath "${CMAKE_CURRENT_SOURCE_DIR}/${_lispfile}")
set(_mdfile "${_name}.md")
set(_generate_eusdoc_command "\\\"(setq lisp::*error-handler* 'exit)\\\" \\\"(load \\\\\\\"${_lisppath}\\\\\\\")\\\" \\\"(make-document \\\\\\\"${_lisppath}\\\\\\\" \\\\\\\"${_mdfile}\\\\\\\" \\\\\\\"${_pkg_name}\\\\\\\")\\\" \\\"(exit)\\\" ")
set(_generate_eusdoc_command "\\\"(install-handler error #'(lambda (c) (lisp::print-error-message c) (exit 1)))\\\" \\\"(load \\\\\\\"${_lisppath}\\\\\\\")\\\" \\\"(make-document \\\\\\\"${_lisppath}\\\\\\\" \\\\\\\"${_mdfile}\\\\\\\" \\\\\\\"${_pkg_name}\\\\\\\")\\\" \\\"(exit)\\\" ")
separate_arguments(_generate_eusdoc_command_list WINDOWS_COMMAND "${_generate_eusdoc_command}")
#set(_roseus_exe roseus)
find_program(_roseus_exe roseus)
Expand Down
306 changes: 306 additions & 0 deletions roseus/euslisp/dynamic-reconfigure-server.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
(ros::load-ros-manifest "dynamic_reconfigure")
;;
;; refer to dynamic_reconfigure/src/dynamic_reconfigure/encoding.py
;;
(defun encode-description (descr) ;; description -> msg
(let ((msg (instance dynamic_reconfigure::ConfigDescription :init)))
(send msg :max (encode-config (get descr :max)))
(send msg :min (encode-config (get descr :min)))
(send msg :dflt (encode-config (get descr :defaults)))
(let (lst)
(dolist (param (get descr :config_description))
(let ((pmd (instance dynamic_reconfigure::ParamDescription :init
:name (cdr (assoc :name param))
:type (cdr (assoc :type param))
:level (cdr (assoc :level param))
:description (cdr (assoc :description param))
:edit_method (cdr (assoc :edit_method param)))))
(push pmd lst)))
;; TODO: default group is only supported
(send msg :groups
(list (instance dynamic_reconfigure::Group :init
:name "Default"
:parameters (nreverse lst)))))
msg))


(defun encode-config (config)
(let ((msg (instance dynamic_reconfigure::Config :init)))
(dolist (cf config)
(let ((k (car cf))
(v (cdr cf)))
(cond
((integerp v)
(send msg :ints
(append (send msg :ints) (list (instance dynamic_reconfigure::IntParameter :init
:name k :value v)))))
((or (eq v nil)
(eq v t))
(send msg :bools
(append (send msg :bools) (list (instance dynamic_reconfigure::BoolParameter :init
:name k :value v)))))
((stringp v)
(send msg :strs
(append (send msg :strs) (list (instance dynamic_reconfigure::StrParameter :init
:name k :value v)))))
((floatp v)
(send msg :doubles
(append (send msg :doubles) (list (instance dynamic_reconfigure::DoubleParameter :init
:name k :value v)))))
)))
msg
))
(defun decode-description (msg) ;; msg -> description
(let (descr
(mins (decode-config (send msg :min)))
(maxes (decode-config (send msg :max)))
(defaults (decode-config (send msg :dflt))))
(dolist (pm (send msg :parameters))
(let ((nm (send pm :name)))
(push
(list
(cons :name nm)
(cons :min (cdr (assoc nm mins :test #'equal)))
(cons :max (cdr (assoc nm maxes :test #'equal)))
(cons :default (cdr (assoc nm defaults :test #'equal)))
(cons :type (send pm :type))
(cons :description (send pm :description))
(cons :edit_method (send pm :edit_method)))
descr)
))
(nreverse dscr)
))
(defun decode-config (msg)
(let ((lst
(append (send msg :bools)
(send msg :ints)
(send msg :strs)
(send msg :doubles)))
ret)
(dolist (l lst)
(push
(cons (send l :name)
(send l :value)) ret))
(nreverse ret)))

;;
;; refer to dynamic_reconfigure/src/dynamic_reconfigure/server.py
;;
(defclass reconfigure_server
:super propertied-object
:slots (type
config
description
callbackfunc ;; (defun func (cfg level) (setting-parameter cfg) cfg)
param-desc-topic
param-updates-topic
service-name
)
)

(defmethod reconfigure_server
(:init
(init_type cbfunc)
(setq type init_type)
(setq callbackfunc cbfunc)
(setq config (get init_type :defaults))
(setq description (encode-description init_type))
(send self :copy-from-parameter-server)
(send self :clamp config)

(let ((nname (ros::get-name)))
(setq param-desc-topic (format nil "~A/parameter_descriptions" nname))
(ros::advertise param-desc-topic
dynamic_reconfigure::ConfigDescription 1 t)
(setq param-updates-topic (format nil "~A/parameter_updates" nname))
(ros::advertise param-updates-topic
dynamic_reconfigure::Config 1 t)
(ros::publish param-desc-topic description)
(send self :change-config config (get init_type :all_level))
(setq service-name (format nil "~A/set_parameters" nname))
(ros::advertise-service service-name dynamic_reconfigure::Reconfigure
#'send self :set-callback))
)
(:update-configuration
(changes)
(let ((new-config (copy-object config)))
(dolist (cf changes)
(let ((elm
(assoc (car cf) new-config :test #'equal)))
(setf (car elm) (car cf))
(setf (cdr elm) (cdr cf))))
(send self :clamp new-config)
(send self :change-config new-config
(send self :calc-level new-config config))
))
(:change-config
(cfg level)
(setq config (funcall callbackfunc cfg level))
(unless config
(warn ";; callbackfunc(~A) did not return config..." callbackfunc))
(send self :copy-to-parameter-server)
(let ((ret-cfg
(encode-config config)))
(ros::publish param-updates-topic ret-cfg)
ret-cfg))
(:copy-from-parameter-server
()
;; not implemented yet
)
(:copy-to-parameter-server
()
;; not implemented yet
)
(:calc-level
(cfg1 cfg2)
(let ((lv 0)
(desclst (get type :config_description)))
(dolist (l desclst)
(when (not (equal (cdr (assoc (cdr (assoc :name l)) cfg1 :test #'equal))
(cdr (assoc (cdr (assoc :name l)) cfg2 :test #'equal))))
(setq lv (logior lv (cdr (assoc :level l))))
))
lv))
(:clamp
(cfg) ;; destructive
(let ((maxlst (get type :max))
(minlst (get type :min))
(desclst (get type :config_description)))
(dolist (l desclst)
(let ((maxval (cdr (assoc (cdr (assoc :name l)) maxlst :test #'equal)))
(minval (cdr (assoc (cdr (assoc :name l)) minlst :test #'equal)))
(val (cdr (assoc (cdr (assoc :name l)) cfg :test #'equal))))
(if (and (not (equal maxval ""))
(and (numberp val)
(numberp maxval)
(> val maxval)))
(setf (cdr (assoc (cdr (assoc :name l)) cfg :test #'equal)) maxval)
(if (and (not (equal minval ""))
(and (numberp val)
(numberp maxval)
(< val minval)))
(setf (cdr (assoc (cdr (assoc :name l)) cfg :test #'equal)) minval)
))))
))
(:set-callback
(req)
(let ((res (send req :response)))
(send res :config
(send self :update-configuration (decode-config (send req :config))))
res))
)

;;
;; dynamic_reconfigure setting for roseus
;;
;; TODO: cfg file load is not supported
(defmacro def-dynamic-reconfigure-server (descriptions callback)
`(instance
reconfigure_server :init
(make-description-obj
(list ,@(mapcar #'(lambda (x) `(make-parameter-desc ,@x)) descriptions)))
,callback))
(defmacro make-parameter-desc (&rest args)
(let* ((tp (elt args 1))
(tpstr (cond
((eq 'int_t tp) "int")
((eq 'double_t tp) "double")
((eq 'str_t tp) "str")
((eq 'bool_t tp) "bool")
(t (warn ";; unknown type ~A" tp))))
ret)
(setq ret
(list
(cons :name (elt args 0))
(cons :type tpstr)
(cons :level (elt args 2))
(cons :description (elt args 3))))
(setq ret (append ret (list (cons :default
(if (> (length args) 4)
(cond
((eq 'int_t tp) (round (elt args 4)))
((eq 'double_t tp) (float (elt args 4)))
((eq 'str_t tp) (string (elt args 4)))
((eq 'bool_t tp) (if (elt args 4) t nil)))
(cond
((eq 'int_t tp) 0)
((eq 'double_t tp) 0.0)
((eq 'str_t tp) "")
((eq 'bool_t tp) nil))
)))))
(setq ret (append ret (list (cons :min
(if (> (length args) 5)
(cond
((eq 'int_t tp) (round (elt args 5)))
((eq 'double_t tp) (float (elt args 5)))
((eq 'str_t tp) (string (elt args 5)))
((eq 'bool_t tp) (if (elt args 5) t nil)))
(cond
((eq 'int_t tp) lisp::most-negative-fixnum)
((eq 'double_t tp) lisp::most-negative-float)
((eq 'str_t tp) "")
((eq 'bool_t tp) nil))
)))))
(setq ret (append ret (list (cons :max
(if (> (length args) 6)
(cond
((eq 'int_t tp) (round (elt args 6)))
((eq 'double_t tp) (float (elt args 6)))
((eq 'str_t tp) (string (elt args 6)))
((eq 'bool_t tp) (if (elt args 6) t nil)))
(cond
((eq 'int_t tp) lisp::most-positive-fixnum)
((eq 'double_t tp) lisp::most-positive-float)
((eq 'str_t tp) "")
((eq 'bool_t tp) t))
)))))
(setq ret (append ret (list (cons :edit_method
(if (> (length args) 7)
(elt args 7) "")))))
`',ret
))


(defun make-description-obj (lst)
(let ((obj (instance propertied-object))
max-lst
min-lst
level-lst
type-lst
default-lst
(clevel 0))
(setf (get obj :config_description) lst)
(dolist (l lst)
(let ((nm (cdr (assoc :name l))))
(push (cons nm (cdr (assoc :max l))) max-lst)
(push (cons nm (cdr (assoc :min l))) min-lst)
(push (cons nm (cdr (assoc :level l))) level-lst)
(push (cons nm (cdr (assoc :type l))) type-lst)
(push (cons nm (cdr (assoc :default l))) default-lst)
(setq clevel (logior clevel (cdr (assoc :level l))))
))
(setf (get obj :max) (nreverse max-lst))
(setf (get obj :min) (nreverse min-lst))
(setf (get obj :level) (nreverse level-lst))
(setf (get obj :type) (nreverse type-lst))
(setf (get obj :defaults) (nreverse default-lst))
(setf (get obj :all_level) clevel)
obj))
#|
;; sample usage
(ros::roseus "reconfigure_server")
(setq *reconfigure-server*
(def-dynamic-reconfigure-server
;;; ((name type level description (default) (min) (max) (edit_method)) ... )
(("int_param" int_t 1 "Int parameter" 0 -10 10)
("double_param" double_t 2 "double parameter" 0.0 -2.0 10.0)
("str_param" str_t 4 "String parameter" "foo")
("bool_param" bool_t 8 "Boolean parameter" nil))
;;; callbackfunc (defun func (config level) ) -> return updated-config
#'(lambda (cfg level)
(pprint cfg)
;; have to set parameter to user application
cfg)))
(while (ros::ok)
(ros::spin-once))
|#
Loading