本来没有复盘计划的,但是第一遍复现没有成功,故重新审核一遍,顺便把教程捞一下
案例1 BubbleRob tutorial
- 0 想到什么补充什么
- 1 We will start with the body (主体)
- 2 we will add a proximity sensor(接近传感器)
- 3 we will take BubbleRob's wheels(建轮子)
- 4 We now need to add joints(添加电机)
- 5 We need third contact point to the floor(支点)
- 6 we define a collection of objects(信息采集)
- 7 track the minimum distance between BubbleRob and any other object.(测距)
- 8 we add a graph object(添加显示图)
- 9 We add cylinder (添加柱子)
- 10 We now need to finish BubbleRob as a model definition****
- 11 we will add a vision sensor,
- 12 问题与解决
0 想到什么补充什么
1.材料: BubbleRob tutorial案例
1.项目拆分
- 建立球体
- 建立
2.常见不熟词汇
- texture:名词:质地,理 动词:组织,组成
1 We will start with the body (主体)
- We add a primitive sphere of diameter 0.2 to the scene
- We adjust the X-size item to 0.2,
- be dynamic and respondable (这样球体可以在环境运动)
- we enable Collidable, Measurable, Renderable and Detectable (可被其他模块检测处理)
- BubbleRob’s body – enter 0.02 for Along Z
- we double-click the sphere’s name — edit its name
2 we will add a proximity sensor(接近传感器)
- so that BubbleRob knows when it is approaching obstacles
- we select [Menu bar --> Add --> Proximity sensor --> Cone type]
- on the orientation tab, we enter 90 for Around Y and for Around Z
- on the position tab, we enter 0.1 for X-coord. and 0.12 for Z-coord.
- The proximity sensor is now relative to BubbleRob’s body.
- We adjust items Offset to 0.005, Angle to 30 and Range to 0.15.
- We uncheck item Don’t allow detections if distance smaller than
- edit its name. We enter bubbleRob_sensingNose
- attaches the sensor to the body of the robot – 建立父子关系
3 we will take BubbleRob’s wheels(建轮子)
- We create a new scene (新环境建好了轮子再复制回去)
- We add a pure primitive cylinder with dimensions (0.08,0.08,0.02)
- we enable Collidable, Measurable, Renderable and Detectable
- we set the cylinder’s absolute position to (0.05,0.1,0.04)
- and its absolute orientation to (-90,0,0)
- We change the name to bubbleRob_leftWheel
- We copy and paste the wheel,set the absolute Y coordinate of the copy to -0.1
- We rename the copy to bubbleRob_rightWheel.
- We copy them, then back to scene 1, then paste the wheels.
4 We now need to add joints(添加电机)
- We click [Menu bar --> Add --> Joint --> Revolute]
- 将电机和轮子位置方向合并 — 并习惯将电机设置到隐藏层
- We rename the joint to bubbleRob_leftMotor
- We enable the motor,
- and check item Lock motor when target velocity is zero(静态锁住电机)
- We now repeat the same procedure for the right motor
- we attach the left wheel to the left motor,right wheel to right motor
- attach the two motors to bubbleRob
5 We need third contact point to the floor(支点)
- We now add a small slider (or caster) with diameter 0.05
- make the sphere Collidable, Measurable, Renderable and Detectable
- rename it to bubbleRob_slider.
- We set the Material to noFrictionMaterial
- we add a force sensor object [Menu bar --> Add --> Force sensor].
- We rename it to bubbleRob_connection and shift it up by 0.05
- We attach the slider to the force sensor
- We then shift the force sensor by -0.07 along the absolute X-axis,
- then attach it to the robot body.
- To avoid strange effects during dynamics simulation — for bubbleRob_slider we set the local respondable mask to 00001111, and for bubbleRob, we set the local respondable mask to 11110000.
设置电机速度,仿真后发现能动 - We select the two wheels and the slider —in the shape dynamics dialog we click three times M=M*2 (for selection)
- we set the Target velocity to 50 for both motors. We run the simulation
6 we define a collection of objects(信息采集)
- we define a collection object. We click [Menu bar --> Tools --> Collections]
- we click Add new collection.
- While the new collection item is selected in the list, select bubbleRob in the scene hierarchy, and then click Add in the collection dialog
- edit the collection name
7 track the minimum distance between BubbleRob and any other object.(测距)
- [Menu bar --> Tools --> Calculation module properties].
- Add new distance object and select a distance pair:
- We rename the distance object to bubbleRob_distance
8 we add a graph object(添加显示图)
- We click [Menu bar --> Add --> Graph]
- rename it to bubbleRob_graph
- We attach the graph to bubbleRob, and set the graph’s absolute coordinates to (0,0,0.005)
- We uncheck Display XYZ-planes,
- then click Add new data stream to record and select Object:
- absolute x-position for the Data stream type, and bubbleRob_graph for the Object / item to record (重复添加yz)
- We are able to track the minimum distance(添加距离数据流)
- we now rename Data to bubbleRob_x_pos, Data0 to bubbleRob_y_pos, Data1 to bubbleRob_z_pos, and Data2 to bubbleRob_obstacle_dist.
- We select bubbleRob_x_pos in the Data Stream recording list and in the Time graph properties section, uncheck Visible. We do the same for bubbleRob_y_pos and bubbleRob_z_pos. (xyz坐标将再3D显示)
- we will set-up a 3D curve that displays BubbleRob’s trajectory ,We rename the newly added curve from Curve to bubbleRob_path
9 We add cylinder (添加柱子)
- We add cylinder with following dimensions: (0.1, 0.1, 0.2)
- we disable Body is dynamic
- We to be Collidable, Measurable, Renderable and Detectable.
- We copy and paste the cylinder a few times, and move them to positions around BubbleRob(复制粘贴,把小球围上)
直接设置速度可以工作 – 应该是代码问题
10 We now need to finish BubbleRob as a model definition****
- We select the model base
- then check items Object is model base and Object/model can transfer or accept DNA
- We select the two joints, the proximity sensor and the graph, then enable item Ignored by model bounding box and click Apply to selection?
- we disable camera visibility layer 2, and enable camera visibility layer 10 for the two joints and the force sensor:(隐藏电机和力传感器)
11 we will add a vision sensor,
- [Menu bar --> Add --> Vision sensor --> Perspective type],
- attach the vision sensor to the proximity sensor,
- set the local position and orientation of the vision sensor to (0,0,0).
- We also make sure the vision sensor is not not visible, not part of the model bounding box
- We add a floating view to the scene,
- [Popup menu --> View --> Associate view with selected vision sensor]
- 注意:千万不要把传感器嵌入到球里,放到表面即可(就像在安装摄像头)
12 问题与解决
- 视觉传感器不显示图像:因为把传感器嵌在球里了
- 小车启动立马翻车:将距离传感器数据打印后发现一直是1,说明距离传感器也嵌在球里了。
- 拉出传感器后后退还是会翻车:猜测是自己支点球放的位置不好,故差速太大就会翻车,减小速度后发现可以正常工作,假设正确