0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Webots備忘録 差動二輪の作成

0
Last updated at Posted at 2025-12-17

目的

webotsが使えるようになる!

参考サイト

車体を作る

今回は差動二輪を作っていく(従動輪はなし)
image.png
完成するとこんな感じになります

手順1

image.png
RectangleArena → + → Basenodes → Robot → 追加

手順2

translationを0 0 0.06に設定
children → + → Basenodes → Shape → 追加
children → + → Basenodes → HingeJoint → 追加
children → + → Basenodes → HingeJoint → 追加

手順3

image.png
Shapeを選択してDEFのとこにBODYと打ち込む(BODYの部分はわかりやすければ何でもいい)

手順4

image.png
USE BODYはboundingobjectを選択して+押してUSE押してBODYってやつがあると思います(設定の使いまわしてきなもの)

手順5

image.png
めっちゃ作るの大変だった...

それぞれの中身

image.png
image.png
image.png
image.png
こんな感じに設定する

手順6

image.png
新しいコントローラー作ります
言語はC言語にしました

c.con
#include <webots/robot.h>

// Added a new include file
#include <webots/motor.h>

#define TIME_STEP 64

#define MAX_SPEED 6.28

int main(int argc, char **argv) {
  wb_robot_init();

  // get a handler to the motors and set target position to infinity (speed control)
  WbDeviceTag left_motor = wb_robot_get_device("motor1");
  WbDeviceTag right_motor = wb_robot_get_device("motor2");自分で決めたモーターの名前を入れる
  wb_motor_set_position(left_motor, INFINITY);
  wb_motor_set_position(right_motor, INFINITY);

  // set up the motor speeds at 10% of the MAX_SPEED. スピード指定
  wb_motor_set_velocity(left_motor, 0.6 * MAX_SPEED);
  wb_motor_set_velocity(right_motor, 1.0 * MAX_SPEED);

  while (wb_robot_step(TIME_STEP) != -1) {
  }

  wb_robot_cleanup();

  return 0;
}

コピペ

手順7

image.png
上手くいったらなんか出てくるからresetを押して終わり!

手順8

image.png
Robot → controllerで自分がさっき作ったやつを選択

動かす

image.png
ここで保存したりシミュレーションを開始させたりできます

おわり

思ってたよりだいぶ雑になった気がするけどだれかの役に立ちますように主に未来の私
今後はWebotsを活用して強化学習に手を出していきたいと思います

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?