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

[pr2eus] Add key topic-name to :send-cmd-vel-raw #481

Merged
merged 4 commits into from May 28, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions pr2eus/robot-interface.l
Expand Up @@ -1592,17 +1592,23 @@ Return value is a list of interpolatingp for all controllers, so (null (some #'i
(send self :move-to-wait :retry 1 :frame-id base-frame-id :no-wait nil)
))
(:send-cmd-vel-raw
(x y d) ;; [m] [m] [degree]
(x y d &key topic-name) ;; [m] [m] [degree]
(when (send self :simulation-modep)
(return-from :send-cmd-vel-raw t))
(unless (ros::get-topic-publisher (if namespace (format nil "~A/~A" namespace cmd-vel-topic) cmd-vel-topic))
(ros::advertise (if namespace (format nil "~A/~A" namespace cmd-vel-topic) cmd-vel-topic) geometry_msgs::Twist 1)
(let ((vel-topic
(if topic-name
(if namespace
(if (eq (char "/" 0) (char topic-name 0)) topic-name (format nil "~A/~A" namespace topic-name))
topic-name)
(if namespace (format nil "~A/~A" namespace cmd-vel-topic) cmd-vel-topic))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  (:send-cmd-vel-raw
   (x y d &key (topic-name cmd-vel-topic) ((:namespace ns) namespace)) ;; [m] [m] [degree]
    (if ns (setq topic-name (format nil "~A/~A" ns topic-name)))
    ;; ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the helpful advice. It's simple and easy to understand.

(unless (ros::get-topic-publisher vel-topic)
(ros::advertise vel-topic geometry_msgs::Twist 1)
(unix:sleep 1))
(let ((msg (instance geometry_msgs::Twist :init)))
(send msg :linear :x x)
(send msg :linear :y y)
(send msg :angular :z d)
(ros::publish (if namespace (format nil "~A/~A" namespace cmd-vel-topic) cmd-vel-topic) msg)))
(ros::publish vel-topic msg))))
(:go-velocity
(x y d ;; [m/sec] [m/sec] [rad/sec]
&optional (msec 1000) ;; msec is total animation time [msec]
Expand Down