-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotflix: fms and negative distance 2.2.2 (#133)
* Fix/seperate fms client (#130) * seperate fms client Signed-off-by: tkhmy <[email protected]> * add ignore disconnect Signed-off-by: tkhmy <[email protected]> * remove some colcon build warning Signed-off-by: tkhmy <[email protected]> * change naming Signed-off-by: tkhmy <[email protected]> * change time out, minor fix Signed-off-by: tkhmy <[email protected]> * remove old logger Signed-off-by: tkhmy <[email protected]> * fix Signed-off-by: tkhmy <[email protected]> --------- Signed-off-by: tkhmy <[email protected]> * add handle negative goal distance (#131) Signed-off-by: tkhmy <[email protected]> * fix package Signed-off-by: tkhmy <[email protected]> --------- Signed-off-by: tkhmy <[email protected]>
- Loading branch information
Showing
15 changed files
with
178 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name="signage_param" default="$(find-pkg-share signage)/config/signage_param.yaml" /> | ||
<arg name="fms_client_param" default="$(find-pkg-share signage_fms_client)/config/fms_client_param.yaml" /> | ||
<node pkg="signage" exec="signage" output="screen"> | ||
<param from="$(var signage_param)"/> | ||
</node> | ||
|
||
<node pkg="signage_fms_client" exec="signage_fms_client" output="screen" > | ||
<param from="$(var fms_client_param)"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[develop] | ||
script-dir=$base/lib/signage | ||
script_dir=$base/lib/signage | ||
[install] | ||
install-scripts=$base/lib/signage | ||
install_scripts=$base/lib/signage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
signage: | ||
ros__parameters: | ||
post_request_time: 8.0 # second |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name="fms_client_param" default="$(find-pkg-share signage)/config/fms_client_param.yaml" /> | ||
<node pkg="signage_fms_client" exec="signage_fms_client" output="screen" > | ||
<param from="$(var signage_param)"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<name>signage_fms_client</name> | ||
<version>0.1.0</version> | ||
<description>The fms client for signage</description> | ||
|
||
<maintainer email="[email protected]">tkhmy</maintainer> | ||
|
||
<license>Apache License 2.0</license> | ||
<exec_depend>ament_index_python</exec_depend> | ||
|
||
<depend>rclpy</depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/signage_fms_client | ||
[install] | ||
install_scripts=$base/lib/signage_fms_client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
|
||
from setuptools import setup | ||
|
||
|
||
def package_files(directory): | ||
paths = [] | ||
for (path, directories, filenames) in os.walk(directory): | ||
for filename in filenames: | ||
paths.append(os.path.join(path, filename)) | ||
return paths | ||
|
||
|
||
package_name = "signage_fms_client" | ||
setup( | ||
name=package_name, | ||
version="0.1.0", | ||
package_dir={"": "src"}, | ||
packages=[package_name], | ||
data_files=[ | ||
("share/ament_index/resource_index/packages", ["resource/" + package_name]), | ||
("share/" + package_name, ["package.xml"]), | ||
("share/" + package_name + "/launch", ["launch/signage_fms_client.launch.xml"]), | ||
("share/" + package_name + "/config", ["config/fms_client_param.yaml"]), | ||
], | ||
install_requires=["setuptools"], | ||
zip_safe=True, | ||
author="Kah Hooi Tan", | ||
maintainer="Kah Hooi Tan", | ||
maintainer_email="[email protected]", | ||
keywords=["ROS"], | ||
classifiers=[ | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Programming Language :: Python", | ||
"Topic :: Software Development", | ||
], | ||
description=("for fms client with signage"), | ||
license="TODO", | ||
entry_points={ | ||
"console_scripts": [ | ||
"signage_fms_client = signage_fms_client.signage_fms_client:main", | ||
] | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This Python file uses the following encoding: utf-8 | ||
|
||
# if__name__ == "__main__": | ||
# pass |
57 changes: 57 additions & 0 deletions
57
src/signage_fms_client/src/signage_fms_client/signage_fms_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This Python file uses the following encoding: utf-8 | ||
import os | ||
|
||
import rclpy | ||
from rclpy.node import Node | ||
|
||
import requests | ||
from std_msgs.msg import String | ||
|
||
|
||
class FMSClient(Node): | ||
def __init__(self, node): | ||
self._node = node | ||
node.declare_parameter("post_request_time", 8.0) | ||
self._post_request_time = ( | ||
node.get_parameter("post_request_time").get_parameter_value().double_value | ||
) | ||
self._fms_payload = { | ||
"method": "get", | ||
"url": "https://" | ||
+ os.getenv("FMS_URL", "fms.web.auto") | ||
+ "/v1/projects/{project_id}/environments/{environment_id}/vehicles/{vehicle_id}/active_schedule", | ||
"body": {}, | ||
} | ||
self.AUTOWARE_IP = os.getenv("AUTOWARE_IP", "localhost") | ||
self.schedule_pub_ = node.create_publisher(String, "/signage/active_schedule", 10) | ||
self.timer = node.create_timer(self._post_request_time + 0.5, self.pub_schedule) | ||
|
||
def pub_schedule(self): | ||
try: | ||
msg = String() | ||
respond = requests.post( | ||
"http://{}:4711/v1/services/order".format(self.AUTOWARE_IP), | ||
json=self._fms_payload, | ||
timeout=self._post_request_time, | ||
) | ||
msg.data = respond.text | ||
self.schedule_pub_.publish(msg) | ||
except Exception as e: | ||
self._node.get_logger().warning( | ||
"Unable to get the task from FMS, ERROR: " + str(e), throttle_duration_sec=5 | ||
) | ||
|
||
|
||
def main(args=None): | ||
|
||
rclpy.init(args=args) | ||
node = Node("signage_fms_client") | ||
|
||
signage_fms_client = FMSClient(node) | ||
|
||
while True: | ||
rclpy.spin_once(node, timeout_sec=0.01) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |