如何修改控制器:
CVector2:
class CVector2 { friend class CRotationMatrix2; friend class CTransformationMatrix2; public: /** The <em>x</em> axis */ static const CVector2 X; /** The <em>y</em> axis */ static const CVector2 Y; /** * Class constructor. * It initializes the vector to (0,0). * @see ZERO */ CVector2() : m_fX(0.0), m_fY(0.0) { } /** * Class constructor. * It initializes the vector from Cartesian coordinates. * @param f_x The <em>x</em> coordinate. * @param f_y The <em>y</em> coordinate. * @see Set() */ CVector2(Real f_x, Real f_y) : m_fX(f_x), m_fY(f_y) { }
/**
* Sums the passed vector to this vector.
* @param c_vector2 The other vector.
* @returns A reference to this vector.
*/
inline CVector2& operator+=(const CVector2& c_vector2) {
m_fX += c_vector2.m_fX;
m_fY += c_vector2.m_fY;
return *this;
}
......
};
1 struct SReading { 2 CRadians Angle; 3 Real Distance; // in cm from the center of the robot (about 10cm from the border) 4 5 SReading() : 6 Angle(0.0f), 7 Distance(0.0f) {} 8 9 SReading(const CRadians& c_angle, 10 Real f_distance) : 11 Angle(c_angle), 12 Distance(f_distance) { 13 } 14 }; 15 typedef std::vector<SReading> TReadings;
参考:https://git.mistlab.ca/isvogor/e-pucky/tree/260fc947afde2a04132b71c79d4204629419b576/swarms/controllers/cpp/collision_avoidance
锁定修改文件:footbot_diffusion_reference.cpp
读懂每个文件的函数意义:
Swarmanoid hardware
Foot-bots
The foot-bot is a particular configuration of modules based on the marXbot robotic platform. The foot-bot configuration includes a top CPU and vision module, a distance scnaner, a range and bearing module, a self-assembling module and a basic (mobility & battery) module.
Foot-bot Features:
- Compact size: 直径17 cm x 29 cm, 1.8 kg
- Modular system
- High computational power including float processing
- Distance scanner measuring distance up to 1.5m
- Two cameras, one mounted as omnicamera
- Self-assembling mechanism
- Hot-swappable battery
- Treel mobility system
IR-sensor:https://www.electronicshub.org/ir-sensor/
有8个IR-sensor,搞不明白怎么测量的角度?
The returned data of each sensor is
- A reading (a decaying exponential) that depends on the distance between the sensor and the object being detected. This reading is 0 when nothing is detected, and it increases exponentially to 1 when detected objects are closer.
- The angle is measured between the nose of the robot (local X axis) and the angle at which the sensor is located on the body of the robot.
所以,靠的是机器人身上的传感器的位置来计算的正面与障碍物的角度。