From 7b1c8dedd0fa8f67dd0b4c1c486394d82e9d8570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=B6ldi=20Tam=C3=A1s?= Date: Mon, 26 Feb 2024 12:51:00 +0100 Subject: [PATCH 1/2] fix: cast int arrays to float --- go2_robot_sdk/go2_robot_sdk/webrtc_driver.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py b/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py index dede919..1d98fbb 100644 --- a/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py +++ b/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py @@ -405,7 +405,7 @@ async def connect(self): "sdp": offer, "id": "STA_localNetwork", "type": "offer", - "token": "", + "token": os.getenv("GO2_TOKEN") or "", } async with session.post(url, json=data, headers=headers) as resp: if resp.status == 200: @@ -681,22 +681,23 @@ def publish_joint_state(self): def publish_robot_state(self): if self.robot_sport_state: go2_state = Go2State() + print(self.robot_sport_state) go2_state.mode = self.robot_sport_state["data"]["mode"] go2_state.progress = self.robot_sport_state["data"]["progress"] go2_state.gait_type = self.robot_sport_state["data"]["gait_type"] go2_state.position = self.robot_sport_state["data"]["position"] go2_state.body_height = self.robot_sport_state["data"]["body_height"] go2_state.velocity = self.robot_sport_state["data"]["velocity"] - go2_state.range_obstacle = self.robot_sport_state["data"]["range_obstacle"] + go2_state.range_obstacle = list(map(float, self.robot_sport_state["data"]["range_obstacle"])) go2_state.foot_force = self.robot_sport_state["data"]["foot_force"] go2_state.foot_position_body = self.robot_sport_state["data"]["foot_position_body"] - go2_state.foot_speed_body = self.robot_sport_state["data"]["foot_speed_body"] + go2_state.foot_speed_body = list(map(float, self.robot_sport_state["data"]["foot_speed_body"])) self.go2_state_pub.publish(go2_state) imu = IMU() imu.quaternion = self.robot_sport_state["data"]["imu_state"]["quaternion"] - imu.accelerometer = self.robot_sport_state["data"]["imu_state"]["accelerometer"] - imu.gyroscope = self.robot_sport_state["data"]["imu_state"]["gyroscope"] + imu.accelerometer = list(map(float,self.robot_sport_state["data"]["imu_state"]["accelerometer"])) + imu.gyroscope = list(map(float,self.robot_sport_state["data"]["imu_state"]["gyroscope"])) imu.rpy = self.robot_sport_state["data"]["imu_state"]["rpy"] imu.temperature = self.robot_sport_state["data"]["imu_state"]["temperature"] self.imu_pub.publish(imu) @@ -759,4 +760,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() From 1c5dca55c3ed0ad6ae0a97e1652b6a6d18a35b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=B6ldi=20Tam=C3=A1s?= Date: Mon, 26 Feb 2024 12:52:05 +0100 Subject: [PATCH 2/2] chore: remove print debug log --- go2_robot_sdk/go2_robot_sdk/webrtc_driver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py b/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py index 1d98fbb..120ef1e 100644 --- a/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py +++ b/go2_robot_sdk/go2_robot_sdk/webrtc_driver.py @@ -681,7 +681,6 @@ def publish_joint_state(self): def publish_robot_state(self): if self.robot_sport_state: go2_state = Go2State() - print(self.robot_sport_state) go2_state.mode = self.robot_sport_state["data"]["mode"] go2_state.progress = self.robot_sport_state["data"]["progress"] go2_state.gait_type = self.robot_sport_state["data"]["gait_type"]