a flag added to the interface classes to indicate if it's simulated or real
This commit is contained in:
parent
1226e32616
commit
8b550c33c3
|
@ -29,7 +29,7 @@ class GO2Real():
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
if self.mode == 'highlevel':
|
if self.mode == 'highlevel':
|
||||||
raise NotImplementedError('DDS interface for the highlevel commands is not implemented yet. Please use our ROS2 interface.')
|
raise NotImplementedError('DDS interface for the highlevel commands is not implemented yet. Please use our ROS2 interface.')
|
||||||
|
self.simulated = False
|
||||||
self.highcmd_topic_name = "rt/go2/twist_cmd"
|
self.highcmd_topic_name = "rt/go2/twist_cmd"
|
||||||
self.lowcmd_topic_name = "rt/go2/lowcmd"
|
self.lowcmd_topic_name = "rt/go2/lowcmd"
|
||||||
self.lowstate_topic_name = "rt/lowstate"
|
self.lowstate_topic_name = "rt/lowstate"
|
||||||
|
|
|
@ -66,6 +66,7 @@ class GO2Real(Node):
|
||||||
ωz_max=0.5,
|
ωz_max=0.5,
|
||||||
):
|
):
|
||||||
assert mode in ['highlevel', 'lowlevel'], "mode should be either 'highlevel' or 'lowlevel'"
|
assert mode in ['highlevel', 'lowlevel'], "mode should be either 'highlevel' or 'lowlevel'"
|
||||||
|
self.simulated = False
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.node_name = "go2py_highlevel_subscriber"
|
self.node_name = "go2py_highlevel_subscriber"
|
||||||
self.highcmd_topic = "/go2/twist_cmd"
|
self.highcmd_topic = "/go2/twist_cmd"
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Go2Sim:
|
||||||
self.model = mujoco.MjModel.from_xml_path(
|
self.model = mujoco.MjModel.from_xml_path(
|
||||||
os.path.join(ASSETS_PATH, 'mujoco/go2.xml')
|
os.path.join(ASSETS_PATH, 'mujoco/go2.xml')
|
||||||
)
|
)
|
||||||
|
self.simulated = True
|
||||||
self.data = mujoco.MjData(self.model)
|
self.data = mujoco.MjData(self.model)
|
||||||
self.dt = dt
|
self.dt = dt
|
||||||
_render_dt = 1/60
|
_render_dt = 1/60
|
||||||
|
|
|
@ -184,7 +184,8 @@
|
||||||
" self.running = True\n",
|
" self.running = True\n",
|
||||||
" self.fsm_thread = threading.Thread(target = self.update)\n",
|
" self.fsm_thread = threading.Thread(target = self.update)\n",
|
||||||
" self.fsm_thread.start()\n",
|
" self.fsm_thread.start()\n",
|
||||||
"\n",
|
" # if the robot is a simulation, create a thread for stepping it\n",
|
||||||
|
" if robot.simulated:\n",
|
||||||
" self.sim_thread = threading.Thread(target=self.simUpdate)\n",
|
" self.sim_thread = threading.Thread(target=self.simUpdate)\n",
|
||||||
" self.sim_thread.start()\n",
|
" self.sim_thread.start()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -228,6 +229,10 @@
|
||||||
" time.sleep(self.dT)\n",
|
" time.sleep(self.dT)\n",
|
||||||
" self.updateCommands()\n",
|
" self.updateCommands()\n",
|
||||||
" \n",
|
" \n",
|
||||||
|
" def close(self):\n",
|
||||||
|
" self.running = False\n",
|
||||||
|
"\n",
|
||||||
|
" # The following functions each are the states of the FSM\n",
|
||||||
" def damping(self):\n",
|
" def damping(self):\n",
|
||||||
" # print('damping')\n",
|
" # print('damping')\n",
|
||||||
" if self.remote.standUpDownSeq():\n",
|
" if self.remote.standUpDownSeq():\n",
|
||||||
|
@ -288,10 +293,7 @@
|
||||||
" def switch_back_to_locked_stance(self):\n",
|
" def switch_back_to_locked_stance(self):\n",
|
||||||
" if time.time()-self.timer > 0.5:\n",
|
" if time.time()-self.timer > 0.5:\n",
|
||||||
" # print(\"going back to locked stance\")\n",
|
" # print(\"going back to locked stance\")\n",
|
||||||
" self.state = \"locked_stance\"\n",
|
" self.state = \"locked_stance\""
|
||||||
" \n",
|
|
||||||
" def close(self):\n",
|
|
||||||
" self.running = False"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue