|
1 | 1 | from dataclasses import dataclass |
2 | 2 | import datetime |
3 | 3 | import time |
4 | | -import serial |
5 | 4 | import json |
6 | 5 | import os |
7 | 6 | import uuid |
@@ -84,32 +83,33 @@ def pub_mode_status(self, status): |
84 | 83 | self.mode_status_pub_.publish(msg) |
85 | 84 |
|
86 | 85 | def send_data(self, data_key): |
87 | | - command_data = [] |
88 | | - self.node.get_logger().info(str(data_key)) |
89 | | - if data_key == "auto": |
90 | | - command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x07"] |
91 | | - elif data_key == "mrm": |
92 | | - command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x01"] |
93 | | - elif data_key == "experiment": |
94 | | - command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x03"] |
95 | | - elif data_key == "null": |
96 | | - command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x00"] |
97 | | - |
98 | | - self.node.get_logger().info(str(command_data)) |
99 | | - command_data = ["sudo", "ls", "/home/makotoyabuta"] |
100 | | - |
101 | | - if len(command_data) == 0: |
102 | | - return |
103 | | - result = subprocess.run( |
104 | | - command_data, |
105 | | - capture_output=True, |
106 | | - text=True |
107 | | - ) |
108 | | - |
109 | | - self.node.get_logger().info(str(result.stdout)) |
110 | | - self.node.get_logger().info(str(result.stderr)) |
111 | | - self.node.get_logger().info(str(result.returncode)) |
112 | | - |
| 86 | + try: |
| 87 | + command_data = [] |
| 88 | + if data_key == "auto": |
| 89 | + command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x07"] |
| 90 | + elif data_key == "mrm": |
| 91 | + command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x01"] |
| 92 | + elif data_key == "experiment": |
| 93 | + command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x03"] |
| 94 | + elif data_key == "null": |
| 95 | + command_data = ["sudo", "i2cset", "-y", "0", "0x40", "0x01", "0x00"] |
| 96 | + |
| 97 | + self.node.get_logger().info(str(command_data)) |
| 98 | + command_data = ["sudo", "ls", "/home/makotoyabuta"] |
| 99 | + |
| 100 | + if len(command_data) == 0: |
| 101 | + return |
| 102 | + result = subprocess.run( |
| 103 | + command_data, |
| 104 | + capture_output=True, |
| 105 | + text=True |
| 106 | + ) |
| 107 | + |
| 108 | + self.node.get_logger().info(str(result.stdout)) |
| 109 | + self.node.get_logger().info(str(result.stderr)) |
| 110 | + self.node.get_logger().info(str(result.returncode)) |
| 111 | + except Exception as e: |
| 112 | + self.node.get_logger().error(str(e)) |
113 | 113 |
|
114 | 114 | # 出力コマンド一覧 |
115 | 115 | # sudo i2cset -y 0 0x40 0x01 0x00 #空欄 |
@@ -171,7 +171,7 @@ def sub_operation_mode_callback(self, msg): |
171 | 171 | try: |
172 | 172 | # operation modeが変わったときにautowareが起動したと判断する |
173 | 173 | self.is_autoware_launch = True |
174 | | - self.node.get_logger().info(str(msg.data)) |
| 174 | + self.node.get_logger().info(str(msg.mode)) |
175 | 175 | except Exception as e: |
176 | 176 | self.node.get_logger().error("Unable to get the operation mode, ERROR: " + str(e)) |
177 | 177 |
|
|
0 commit comments