还是接上面的固定四轮小车,这里修改了一下脚本代码,使得小车可以转弯,是一个简单应用程序:
还是在script文件编写如下,这里就不写注解了:
function sysCall_init()
--注解可以参考前面一章
xml = [[
<ui closeable="true" onclose="closeEventHandler" resizable="true" size="220,200">
<label text="Car control pan" wordwrap="true" />
<group>
<label text="Set speed(0.1deg/s):" wordwrap="true" />
<spinbox minimum="-5000" maximum="5000" onchange = "speed_set" />
<stretch />
</group>
<group>
<button text="Start move" onclick = "Start_move" />
<button text="Stop move" onclick = "Stop_move" />
<stretch />
</group>
<group>
<button text="Front" onclick = "Front_move" />
<button text="Back" onclick = "Back_move" />
<button text="Left" onclick = "Left_move" />
<button text="Right" onclick = "Right_move" />

本文介绍了一种通过修改脚本代码实现四轮小车转弯的方法。通过设置不同轮子的速度,小车能够向前、后、左、右移动。代码中详细展示了如何使用sim.setJointTargetVelocity函数来控制各轮子的转速。
最低0.47元/天 解锁文章





